Search code examples
instagram

get another user's follower numbers from new (2021) instagram API


I like to get an instagram user's followers number. I.e. https://www.instagram.com/robertdowneyjr has 50.8 million followers.

First I've tried the simplest way where you get the https://www.instagram.com/robertdowneyjr/?__a=1 URL and parse followers from the JSON format but it's only works when you already signed in instagram at current browser or u'll be redirected to the login page.

I also have instagram API credentials (appId, secret, redirect URL) for the Instagram Basic Display (facebook API product) and I can set up the connection and can use API's endpoints, but with that I'm unable to get a 3rd user's followers number but my own/or the user's who authorized the app (documentation https://developers.facebook.com/docs/instagram-basic-display-api/).

So I like to get anyone's followers number only by their instagram username I.e. robertdowneyjr. Where would I search for?


Solution

  • The right way to do this is with business discovery API (although it has its problems. IG API has never fully recovered from their sudden deprecation of the legacy API).

    https://developers.facebook.com/docs/instagram-api/guides/business-discovery

    Refer to the documentation for the necessary permissions. Here is an example of the call you will need to make:

    https://graph.facebook.com/v3.3/xxxx?fields=business_discovery.username(USERNAME){followers_count}&access_token=TOKEN

    WHERE xxxx is the Instagram ID of the account that has the permissions, USERNAME is the instagram username that you are trying to retrieve followers for, and TOKEN is an access_token that has the appropriate permissions.

    This will only get followers for business or creator accounts. Individual accounts will not work, even if they are public.