API 文档wechat_mpData获取公众号文章互动数据(H5 版本)
获取公众号文章互动数据(H5 版本)
接口用途
- 传文章 URL,返回**评论数 / 精选评论数**。与 /fetch_article_stats 是**两个独立接口**,
- 各自返回结果,不会自动切换:
- | 接口 | 能取到 | 建议 |
- |---|---|---|
- | /fetch_article_stats | 阅读量 / 点赞 / 在看 / 分享 / 收藏 / 评论数(**全部指标**) | 需要阅读量等指标时用 |
- | /fetch_article_stats_h5(本接口) | **仅评论数 / 精选评论数**;稳定性更好 | 只要评论数、或上面那条报错时用 |
- ⚠️ 阅读量、点赞、在看、分享、收藏这几项**本接口取不到**,一律返回 null 并列在
- $.data.unavailable[],**不会用 0 冒充** —— 调用方可据此区分「这篇文章真的是 0」
- 和「这条路取不到」。需要这些指标请用 /fetch_article_stats。
- 价格:0.01$/次
- ⏱️ 请将客户端超时(timeout)设置为 30 秒。
- ⚠️ 大整数 ID 精度:comment_id / appmsgid 为 64 位大整数,请以**字符串**方式接收 / 传递。
- 💡 **提速**:传 comment_id 可让数据服务跳过整篇文章的抓取解析,实测本接口从 15.10s 降到 6.91s / 评论接口从 8.28s 降到 6.13s。该值取自 /fetch_article_detail 或 /fetch_article_detail_h5 响应的 $.data.content.comment_id,拿它是零成本的
POST
/openapi/api/v1/wechat_mp/v2/fetch_article_stats_h5价格:价格暂不可用 · 实际扣费按免费额度及账户折扣结算
鉴权
所有 API 请求都需要 Bearer 项目 Token,请在 Authorization 请求头中传入
Authorization header
Authorization: Bearer YOUR_API_TOKEN请求参数
- url: 公众号文章链接(https://mp.weixin.qq.com/s/…)。
- raw: 可选,默认 True。True=附带评论接口的原始计数字段;False=仅计数。
- **两者顶层结构一致**,raw 只增减字段。
| 参数名 | 位置 / 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| url | body / string | 是 |
| https://mp.weixin.qq.com/s/TSNQKkRpN1qbKsT7BvzqIw |
| raw | body / boolean | 否 |
| |
| comment_id | body / string | null | 否 |
|
调用示例
curl -X POST "https://api.trmesh.com/openapi/api/v1/wechat_mp/v2/fetch_article_stats_h5" \ -H "Authorization: Bearer sdc_your_project_token"
返回字段
- 评论数 / 精选评论数;其余互动指标为 null 并列在 unavailable[]
公共响应外层
响应状态、请求标识和数据等公共字段
| 字段名 | 类型 | 说明 | 示例 |
|---|---|---|---|
| code | integer |
| |
| request_id | string | null |
| |
| message | string |
| |
| message_zh | string |
| |
| support | string |
| |
| time | string |
| |
| time_stamp | integer |
| |
| time_zone | string |
| |
| docs | string | null |
| |
| cache_message | string | null |
| |
| cache_message_zh | string | null |
| |
| cache_url | string | null |
| |
| router | string |
| |
| params | unknown |
| |
| data | unknown | null |
|
错误码与限流说明
除了成功返回,这里也说明鉴权失败、限流和数据服务异常时的标准行为
| 状态码 | 含义 | 说明 |
|---|---|---|
| 200 | 成功 | 请求处理完成,返回标准结果包裹。 |
| 401 | 未授权 | 缺少令牌、令牌无效或登录状态已失效。 |
| 429 | 触发限流 | 请求速率超过令牌、用户或套餐的限制。 |
| 502 | 服务暂不可用 | 网关未获取到可用结果,建议稍后重试。 |