13

is there possibility to get other pages follower count number in Instagram? I can get only my profile followers count number, but I want to get other followers too? (for example in php)

Any ideas?

eMKa
  • 131
  • 1
  • 1
  • 4

6 Answers6

48

Yes, it's possible with ?__a=1 queries which return json.

$otherPage = 'nasa';
$response = file_get_contents("https://www.instagram.com/$otherPage/?__a=1");
if ($response !== false) {
    $data = json_decode($response, true);
    if ($data !== null) {
        $follows = $data['graphql']['user']['edge_follow']['count'];
        $followedBy = $data['graphql']['user']['edge_followed_by']['count'];
        echo $follows . ' and ' . $followedBy;
    }
}
flex
  • 3
  • 2
rNix
  • 2,457
  • 1
  • 22
  • 28
27

Jumping through hoops to get an app approved for quickly checking follower counts seemed excessive so I had a look at network requests on Instagram's web search and saw that typing in the search box fires off requests to this URL:

https://www.instagram.com/web/search/topsearch/?query={searchquery}

That returns a JSON feed which has a bunch of info on the user including a value for follower_count. If you are logged in, the results are weighted by relevance to your account, but you don't have to be authenticated or even logged in to get a result:

{
"has_more": false, 
"status": "ok", 
"hashtags": [], 
"users": [
            {
            "position": 0, 
            "user": {
                "username": "thenativepaul", 
                "has_anonymous_profile_picture": false, 
                "byline": "457 followers", 
                "mutual_followers_count": 0.0, 
                "profile_pic_url": "https://scontent-lhr3-1.cdninstagram.com/t51.2885-19/11373838_482400848607323_1803683048_a.jpg", 
                "full_name": "Paul Almeida-Seele", 
                "follower_count": 457, 
                "pk": 21072296, 
                "is_verified": false, 
                "is_private": false
                }
            }, 
            {
            "position": 1, 
            "user": {
                "username": "the_native_warrior", 
                "has_anonymous_profile_picture": false, 
                "byline": "251 followers", 
                "mutual_followers_count": 0.0, 
                "profile_pic_url": "https://scontent-lhr3-1.cdninstagram.com/t51.2885-19/s150x150/14473927_312669442422199_4605888521247391744_a.jpg", 
                "profile_pic_id": "1352745514521408299_1824600282", 
                "full_name": "Paul Carpenter", 
                "follower_count": 251, 
                "pk": 1824600282, 
                "is_verified": false, 
                "is_private": true
                }
            }
        ], 
"places": [ ]
}
NativePaul
  • 696
  • 7
  • 4
3

Using yahoo query language

https://query.yahooapis.com/v1/public/yql?q=select * from html where url='https://www.instagram.com/USERNAME/' and xpath='/html/body/script[1]'&format=json
  • 1
    html (or html table) not supported by YQL ! try htmlstring ! + insta blocked by yahoobot `Redirected to a robots.txt restricted URL` – Vladimir Ch Jul 12 '17 at 12:00
  • 1
    Hello everyone, indeed the API url is no longer available that way. URLs and calling methods change over the years – Gabriel Intriago Jun 21 '20 at 21:00
1

you can get any user's followers count but you cant get the user's followers details, you can only get your follower list.

This is API to get follower count of any user:

https://api.instagram.com/v1/users/{user-id}/?access_token=ACCESS-TOKEN

https://www.instagram.com/developer/endpoints/users/#get_users

UPDATE: I noticed that didn't work and I just tried this: https://api.instagram.com/v1/users/self/?access_token=XXXXX and got some good info ... MQ

Mike Q
  • 6,716
  • 5
  • 55
  • 62
krisrak
  • 12,882
  • 3
  • 32
  • 46
  • Thank you Krisrak, but I'm already tried above code to get other user page followers but it does not work. Error: {"meta":{"error_type":"OAuthAccessTokenException","code":400,"error_message":"The access_token provided is invalid."}} – eMKa Jan 22 '16 at 12:43
  • like it says there, you access_token is invalid, try here: http://www.gramfeed.com/accounts/sandbox – krisrak Jan 22 '16 at 19:00
  • 1
    well, access_token works fine only for my profile followers count :/ but not for others :S Is there requirement to be a Sandbox user to get other profiles followers count? – eMKa Jan 22 '16 at 21:26
  • add the other user to sandbox, and after they accept, u can make api call and get count – krisrak Jan 22 '16 at 21:32
  • but I want anonymously get that information. Is it possible? for example I want get followers count (10.7k) from here: https://www.instagram.com/marketer.ge/ – eMKa Jan 22 '16 at 22:39
  • after your app gets reviewed and goes live, u can access any user except if they are private – krisrak Jan 23 '16 at 00:06
  • Does anyone ever had a 404 error for such a call? It seems this is what I have – PIIANTOM Aug 05 '16 at 22:12
  • @PIIANTOM you are probably passing `username` instead of `user-id` – krisrak Aug 05 '16 at 22:19
0

There are a few analytics tools that allow you to get the follower count without an access token other than your own. If you login to Crowdbabble and add an Instagram account, you will be asked to login to your Instagram account. After that, though, you can add any Instagram account and get the number of followers. This will give you the follower list, most engaging followers, and most influential followers for any account.

If you apply for the Instagram API (now requires a written application and a video submission), you can set up an app like this yourself. You can make calls to different accounts using just one access token.

km13oj
  • 54
  • 5
0

I've used yahoo API, in my case I figured out like this,

hope this helps someone because I've searched a lot for this.

$url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url=%27https://www.instagram.com/USERNAME/%27%20and%20xpath=%27/html/body/script[1]%27&format=json";
$json = file_get_contents($url);
$obj = json_decode($json, true);
$content = $obj['query']['results']['script']['content'];
$content = str_replace("window._sharedData =", "", $content);
$content = str_replace(";", "", $content);
$content = trim($content);
$json = json_decode($content);
$instagram_follower_count = $json->entry_data->ProfilePage{0}->user->followed_by->count;

anyone know better way get directly with JSON object, without replacing special characters ? please correct me if yes.

Harsha
  • 377
  • 1
  • 8
  • 21