4

I'm trying to migrate a custom reporting platform from Instagram's old API to the new Graph API ( https://developers.facebook.com/docs/instagram-api/reference/media/#metadata )

I have a database that has stored a few years worth of post data for reporting purposes and it holds the id of the post in the old format of xxxxxxxxxxxxxxxxxx_yyyyyyyy.

The new Graph API returns two IDs id and ig_id. The ig_id relates to the x part of the original ID above. The new Graph API doesn't allow you to query media by the ig_id, only the id, so my question is - is there a way to convert the ig_id to the id or retrieve the id from the ig_id?

James
  • 3,233
  • 3
  • 40
  • 57

1 Answers1

2

Unfortunately, I don't believe there is a direct method to go from the old id to the new id. The way I have done it is to get the full list of media and then iterate through that to match the old id. I think you already know this, but I'm going to write this out in case someone else finds this post and wants more details.

If you go here, step 6, you will see the endpoint to retrieve all media objects for the specified business account. The url is:

https://graph.facebook.com/v4.0/business-id-here/media?access_token=access-token-here

This will return a list of ids for the new graph api.

At this point, you will need to pull the detailed information for each media object. The documentation is here. The end point is:

https://graph.facebook.com/v4.0/media-id-here?access_token=access-token-here&fields=caption,children,comments,id,ig_id,media_type,media_url,owner,permalink,shortcode,thumbnail_url,timestamp,username

This will give you both the old id and the new id, which can be matched.

joeshmoe301
  • 1,193
  • 2
  • 11
  • 25