Possible to pull Insights data via Instagram API?

我的梦境 提交于 2019-12-03 08:41:57

Quick update for this question: the Instagram Platform API now offers an endpoint for insights.

Endpoint

GET graph.facebook.com
    /{media_id}/insights?metric={engagement|impressions|reach|saved|video_views}

Example

GET graph.facebook.com
    /17895695668004550/insights?metric=impressions,reach

Example Response

{
  "data": [
    {
      "name": "impressions",
      "period": "lifetime",
      "values": [
        {
          "value": 264
        }
      ],
      "title": "Impressions",
      "description": "Total number of times the media object has been seen",
      "id": "17855590849148465/insights/impressions/lifetime"
    },
    {
      "name": "reach",
      "period": "lifetime",
      "values": [
        {
          "value": 103
        }
      ],
      "title": "Reach",
      "description": "Total number of unique accounts that have seen the media object",
      "id": "17855590849148465/insights/reach/lifetime"
    }
  ]
}

Having faced this very problem (analytics being confined to the mobile app), I decided to use the Android app SSL Packet Capture (NO root required) to capture the requests (you must manually fetch a post's insights in the app whilst recording). The correct GET request will be listed inside one of the Instagram entries and it's long!

The necessary access token is already embedded in the request and the instagram post id can be substituted to fetch post-level analytics: Reach, Impressions & Engagement. Moreover the GET request must be made over https.

The request (in URL decoded form) will look something like this:

https://graph.facebook.com/graphql?access_token=<ACCESS_TOKEN>&query_id=<QUERY_ID>&locale=en_US&strip_nulls=true&strip_defaults=true&querparams={"0":{"id":"<POST_ID>", "access_token":"<ACCESS_TOKEN_2>:{"_token_ver":2,"_auth_user_id":<USER_ID>,"_token":"<TOKEN>","asns":{"<ASNS>,"time":1476466064},"_auth_user_backend":"accounts.backends.CaseInsensitiveModelBackend","last_refreshed":1476396104.372065,"_platform":1,"_auth_user_hash":""}"}}'
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!