instagraminstagram-graph-api

Get IG_MEDIA_ID from Instagram post link


I have a link to some instagram post/reel (e.g. https://www.instagram.com/reel/C0w1dkGr4fi/). I need it's ig_media_id to query the Instagram Graph API, how am I supposed to obtain this, it doesn't show up in the docs as far as I'm aware.


Solution

  • You can use the /{instagram-business-account-id}/media endpoint with the relevant fields to get the ig_media_id. Use the following:

    graph.facebook.com/{instagram-business-account-id}/media?fields=id, ig_id, permalink
    

    You would need to map your reel url with the permalinks presented in the responses and then pick up the respective ig_id.

    Pro Tip: You can use the Facebook Graph API explorer to test the endpoints quickly:

    https://developers.facebook.com/tools/explorer/