12

If I have a instagram post is there anyway to get the facebook id for an instagram post? To be clear, if I were to look at https://www.instagram.com/p/Bcqn51ynrd5/ I am able to find the instagram media-id by doing one of two things:

However, neither of these are the media-id associated with facebook's new instagram graph insights. If I already have the facebook media-id I am able to get the instagram media-id through facebook graph by calling graph.facebook.com/{facebook-media-id}?fields=ig_id but I am unable to find the inverse. Is this possible?

Alex Harris
  • 6,172
  • 2
  • 32
  • 57

2 Answers2

4

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

which returns a list of both Facebook and Instagram media-ids:

{
  "data": [
    {
      "ig_id": "1729885037886968354",
      "id": "16961190105043123"
    },
    {
      "ig_id": "1714698694055731973",
      "id": "16949739045077321"
    }
    ...

then find corresponding Facebook's media-id you can get the insights for.

Also, instead of ig_id use shortcode field in graph.facebook.com/{instagram-business-account-id}/media?fields=shortcode and traverse list searching directly for short code, so you may skip "finding Instagram media-id by short code" step.

Victor Stagurov
  • 4,566
  • 1
  • 15
  • 15
  • This answer solved my problem. I was able to convert the Instagram short code to its id using a python script, and then I sent a request to this API to get the media_id for Facebook. Thanks! – Fateme Fouladkar Aug 22 '23 at 07:04
2

I don't think it is possible. It is listed as limitation in the Insights API documentation.

To list current limitations:

  • We only store 2 years worth of metrics data.
  • You can only get insights for a single Instagram Business account at a time.
  • You cannot get insights for Facebook Pages.
  • Stories insights are only available for 24 hours, even if the stories are archived or highlighted. If you want to get the latest insights for a story before it expires, set up a Webhook for the Instagram topic and subscribe to the story_insights field.
tukan
  • 17,050
  • 1
  • 20
  • 48
  • tukan, can you elaborate how Facebook page is related to Instagram media-id? I agree with Alex's point: the Instagram post's media-id returned via Instagram API is different from the one returned via Facebook Graph API. – Victor Stagurov Jul 30 '18 at 15:36
  • @VictorStagurov what you have posted below is what Alex already did. He knows that facebook's `media-id` can get him instagram `media-id`. What he wanted is *...to find the inverse...*, he wants to have instangram's ` media_id/insights` to get him facebook's `media-id` which is listed as limitation and currently not possible. – tukan Jul 31 '18 at 12:21
  • you didn't answer my question: why you highlighted **insights for Facebook pages** as the limitation and how it's related to Instagram insights/media-id? My solution is a valid one. Alex needs Instagram insights for a particular post. He has Instagram post URL, using which he finds `instagram-media-id`. Facebook Graph API doesn't provide any insights for `instgram-media-id`, so he needs to find `facebook-media-id`. There is no endpoint to do so either. The solution below allows to find `facebook-media-id` by `instgram-media-id` - and this is the _inverse_ he's asking about. – Victor Stagurov Jul 31 '18 at 13:54