兼容性数据 API
发布于
兼容性浏览器上渲染的每一样东西,都在页面所在的同一组 URL 上以 JSON 提供。无需 key、无频率限制、
无需注册;响应头带 Access-Control-Allow-Origin: *,可以直接从浏览器调用。
如果你在做构建目标检查器、linter、编辑器插件、看板,或者一个需要回答 「PWA 里能不能用 X」 的应答引擎,这里就是入口。
curl https://openpwa.net/compatibility/index.json索引列出每个特性的类别、溯源信息,以及一个 data_url:
{ "name": "OpenPWA compatibility dataset", "licence": "CC BY 4.0", "attribution": "OpenPWA — https://openpwa.net", "count": 38, "features": [ { "slug": "web-share", "name": "Web Share API", "category": "Capabilities", "confidence": "high", "verified_at": "2026-07-14", "support_rows": 4, "data_url": "https://openpwa.net/compatibility/web-share.json", "page_url": "https://openpwa.net/compatibility/web-share/" } ]}当一个数据集已发布、但对应的正文条目尚未发布时,page_url 为 null,所以跟着它走
永远不会落到 404。
| 端点 | 返回什么 |
|---|---|
/compatibility/index.json |
全部特性:类别、溯源、data_url、page_url |
/compatibility/{slug}.json |
单个特性:支持数据行、生态政策行、溯源 |
/compatibility/by-country.json |
按地区、按特性的国家加权有效可达率 |
curl https://openpwa.net/compatibility/web-nfc.json每条记录都带规范链接与 MDN 链接、一个 confidence 等级,以及该行最后一次核验的
verified_at 日期,所以你可以自己判断某个格子值得多少信任,而不是盲信一个绿勾。
confidence 从不由编辑手填:它按每一行的来源计算(由 browser-compat-data 条目生成的行为
high,厂商文档或发行说明为 medium,其余为 low),特性级别的等级取其最弱的一行。
凡是引用 browser-compat-data 的行,每次部署时还会与线上 BCD 文件逐行比对;与所引来源
不一致、或所引路径已失效的行,会直接阻断部署。
biz_compat 是通用参考站不会收录的部分:广告网络、支付服务商和应用商店在生产环境中
究竟接不接受某项能力。赞助行以 sponsored: true 标记,且永远不会改变编辑侧的支持值。
按国家加权的可达率
Section titled “按国家加权的可达率”curl https://openpwa.net/compatibility/by-country.jsonreach 在构建时由「支持度 × 真实浏览器市场份额」计算得出,从不手工存储。每个地区都带有
市场份额的 source、source_url 和 as_of 日期,载荷中也写明了推导方法,便于你复现或
否定它。请把它当作近似值:这是加权估算,不是实测。
在页面里使用
Section titled “在页面里使用”const { features } = await fetch( 'https://openpwa.net/compatibility/index.json',).then((r) => r.json());
const webShare = await fetch( features.find((f) => f.slug === 'web-share').data_url,).then((r) => r.json());
console.log(webShare.support, webShare.verified_at);数据集采用 CC BY 4.0。可商用、可修改、 可再分发;唯一条件是署名:
数据来源:<a href="https://openpwa.net">OpenPWA</a>,<a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>每个 JSON 载荷都带有 licence、licence_url、attribution 和 attribution_html,
消费方无需硬编码即可渲染出署名。
特性 slug 是稳定的:slug 就是数据集的身份,一旦它与源文件不再匹配,构建会直接失败。
字段只增不删、不改用途。数据在发布时重建,所以某行的 verified_at 告诉你的是人最后一次
核验该行的时间,而不是文件重新生成的时间。
发现某个格子是错的?告诉我们:一条带来源的更正,是你能寄来的 最有价值的东西。
← 返回兼容性浏览器。