跳转到内容

兼容性数据 API

发布于

兼容性数据 API 以 JSON 提供兼容性浏览器中展示的数据,沿用页面所在的同一组 URL。响应标头带 Access-Control-Allow-Origin: *,你可以直接从浏览器调用,不需要 key 或注册,也没有频率限制。

构建目标检查器、linter、编辑器插件、看板,或需要回答 「PWA 里能不能用 X」 的应答引擎,都可以使用这些数据。

Terminal window
curl https://openpwa.net/compatibility/index.json

索引列出每个特性的类别、溯源信息,以及一个 data_url:

{
"name": "OpenPWA compatibility dataset",
"licence": "CC BY 4.0",
"attribution": "OpenPWA — https://openpwa.net",
"count": 61,
"features": [
{
"slug": "web-share",
"name": "Web Share API",
"category": "Capabilities",
"confidence": "high",
"verified_at": "2026-10-03",
"support_rows": 9,
"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 按地区、按特性的国家加权有效可达率
Terminal window
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,不改变编辑侧的支持值。

Terminal window
curl https://openpwa.net/compatibility/by-country.json

reach 在构建时由「支持度 × 浏览器市场份额」计算得出,不手工存储。每个地区都带有市场份额的 source、source_url 和 as_of 日期,载荷中也写明了推导方法,便于你复现或否定它。它是加权估算的近似值,没有实测。

份额取自 StatCounter Global Stats 的全平台浏览器市场份额,月份见 as_of(2026 年 10 月更新时为 2026-09)。每个地区还带有归并后的 shares、读取数据所用的 CSV data_url、retrieved_at 以及 source_licence(CC BY-SA 3.0)。载荷的 reach_data_licence 为 CC BY-SA 4.0,并给出应使用的署名;其中的支持数据仍适用下文的 CC BY 4.0 条款(support_data_licence)。

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>

索引与逐特性载荷都带有 licence、licence_url、attribution 和 attribution_html,消费方无需硬编码即可渲染出署名。by-country.json 以 support_data_licence 携带同一组字段;其中的可达率不在许可范围内(见上文)。

特性 slug 是稳定的:slug 就是数据集的身份,一旦它与源文件不再匹配,构建会直接失败。字段只增不删、不改用途。数据在发布时重建,所以某行的 verified_at 告诉你的是人最后一次核验该行的时间,而不是文件重新生成的时间。

报告错误的数值时,请附上更正所依据的来源。

← 返回兼容性浏览器。