How to access Instagram feed of any user with new Graph API?

Marvin3 picture Marvin3 · Oct 8, 2017 · Viewed 23.7k times · Source

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.

Answer

enator picture enator · Nov 14, 2017

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.