29

Facebook recently introduced Instagram Graph API, which allows to fetch data from Instagram page that is connected to your Facebook company page, instagram.com/developers states:

The Instagram Graph API is Now Available to All Developers.
For Non-Business Instagram Accounts please continue to use the existing Instagram API.

So, for example, if my company has account instagram.com/my_first_company, I can only retrieve its feed and no one else.

Using old Instagram API to retrieve public_content permission (access to any feed) is no longer an option too, from old API documetation:

public_content - to read any public profile info and media on a user’s behalf (applications no longer accepted)


  • What will happen to existing tools that have public_content permission? (for example, there are tons of plugins for various CMS that allow to display recent Instagram photos)
  • Is there any valid way to access public_content (access to any feed) right now (besides fetching HTML pages of Instagram website)?
  • Are there any plans to enable Graph API for non-business customers, of so when?

UPD. There seem to be ?__a=1 endpoint that allows to get access to recent photos of any public feed without any tokens. But it's not official and no one knows when/if Instagram will close it. If you do - please let me know.

UPD 2. Instagram removed ?__a=1 endpoint, not sure for how long, probably forever. Currently the only way to access instagram feed is to scrap instagram.com website, which is a horror.

Marvin3
  • 5,741
  • 8
  • 37
  • 45
  • 1
    I have two theories for why they're no longer accepting applications for public_content. 1. GDPR is going to be very difficult task to solve for most companies in 2018. 2. They're working on moving the complete API to Facebook, which makes a lot of sense since their website is already using GraphQL for querying data.. – Jón Trausti Arason Dec 16 '17 at 21:51
  • It's very hard to integrate Instagram Graph API. Facebook asking many settings in there developer section so it should be easy for everyone not so complicated. – bhavik Jan 09 '20 at 07:45

2 Answers2

6

Prerequisite: You first need the business Instagram account to be linked with FB Page. https://help.instagram.com/356902681064399 - That one can do from the profile page of Instagram account.

  • Get the Instagram business account id: graph.facebook.com/v2.8/<fbPageId>?fields=instagram_business_account. (the fbPageId is the page id of the facebook page the account is linked)

  • To fetch instagram media feed: graph.facebook.com/v2.8/<igBusinessId>/media to fetch the media feed of the Instagram account. (the igBusinessId is the id returned in above linked instagram_business_account) - This is still owned media as per the page access_token. Not any other user's feed.

  • All other endpoints (such as comments moderation, detailed insights API) mentioned here works on the business media list returned on above call.

Please note: This still does not allow to fetch un-authenticated user's Instagram feed. That is not possible via API now. There is no valid way via API to get to public_content scope. There can be few Instagram Marketing partners for which this is enabled. But, in general the scope is deprecated now!

Currently, for FB graph API to work we need linked business page to Instagram account. As above apis uses page tokens.

enator
  • 2,431
  • 2
  • 28
  • 46
  • 1
    When i triggered this link, The error i got like this. error": { "message": "An access token is required to request this resource.", "type": "OAuthException", "code": 104, "fbtrace_id": "B/FAne8n7Kq" } – Arish Khan Mar 05 '18 at 06:35
  • you need to get token via OAuth2 and pass it along – enator Mar 05 '18 at 07:48
  • @enator can you clear things a little like how to get & than which will be the call along with access_token? – Muhammad Faisal Iqbal Mar 07 '18 at 10:05
  • you need to ask user to select the linked fb page to get the fbPageId. generally, facebook graph API's `me/accounts` whould give the pages of current user. this can be multiple pages - any one of them could be linked page that user had associated to business account. I am not sure if from instagram account id we could get this linked fbPageId. – enator Mar 13 '18 at 10:17
  • I already have my Instagram Business Account connected to my page on Facebook.. but when I use Facebook's Graph Explorer to try to get the "instagram_business_account" it returns no results.. but when I query "instagram_accounts" it returns the ID of my instagram account, but this means I cannot use it to get "/comments, /media, etc.." .. Do you have any idea why this is happening? P.S I also tried the unlinking and linking again thing and it still didnt work.. Thanks! – RJiryes Sep 30 '18 at 11:24
4

You can get information about any IG business account using your FB access_token using the business_discovery API as given here.

  • You must have an IG business account to read other users data like user_info or media details using the id of your IG business account as a node.

Ex:

GET graph.facebook.com/[YOUR-IG-BUSINESS-ACCOUNT-ID]?fields=business_discovery.username(USERNAME){media{caption,media_url,media_type,like_count,comments_count,id}}

rakeshpatra
  • 683
  • 8
  • 24
  • This is still valid as of 1/28/20. After going through [AppReview](https://developers.facebook.com/docs/app-review) via Facebook directly, you can supply your IG-BUSINESS-ACCOUNT-ID and your access token to retrieve other account info. – Corey Byrum Jan 28 '21 at 16:28