You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Graph API拉取Instagram点赞报错需指定metric_type=total_value

报错原因

Graph API v13及以上版本的Instagram Insights接口对指标做了类型区分:impressions、reach属于按时间粒度拆分的时间序列指标,likes(账号维度总点赞)属于汇总类指标,两类指标的请求参数规则不同,混在同一个带period=day的请求里调用时,就会触发你看到的100错误码,提示需要显式指定metric_type=total_value参数。

解决方法
  • 拆分请求调用,不要把两类指标放在同一次请求里拉取:
    1. 拉取分天的曝光、触达数据时,保持原有参数逻辑不变即可:
    # 时间序列类指标请求
    day_metrics_url = 'https://graph.facebook.com/v14.0/ig-business-account-id/insights?metric=impressions,reach&period=day&access_token=你的有效访问令牌'
    day_resp = requests.get(day_metrics_url)
    print(day_resp.text)
    
    1. 拉取点赞类汇总指标时,去掉period=day参数,加上metric_type=total_value参数:
    # 汇总类指标请求
    total_likes_url = 'https://graph.facebook.com/v14.0/ig-business-account-id/insights?metric=likes&metric_type=total_value&access_token=你的有效访问令牌'
    likes_resp = requests.get(total_likes_url)
    print(likes_resp.text)
    
补充说明
  • 只有账号维度的累计交互类指标(总点赞、总评论、总粉丝数等)需要传metric_type=total_value,如果是拉取单条帖子、单条Reels的点赞数据,不需要加这个参数,原有请求逻辑可正常使用。
  • 调用汇总类指标时不要传period相关参数,否则接口会返回空值,返回结果里的total_value字段就是对应统计周期的累计数值。
  • 这部分参数说明没有放在接口通用参数列表中,而是藏在指标分类说明章节,很容易被检索遗漏。

内容的提问来源于stack exchange,提问作者Fakhr Ali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.28 23:48:23