I'm using the following query
https://www.instagram.com/graphql/query/?query_id=17851374694183129&id={acountId}&first=1000&after={cursor}
to get an user followers. The information I need is the followed_by_count
index that's only available per user on https://www.instagram.com/{username}?__a=1
Is there a query_id
that includes the followed_by_count
in the result?
This is because Instagram first loads the layout and all the data it needs from its internal GraphQL API and then puts the data in the correct layout. We could scrape this data directly if we queried Instagrams GraphQL endpoint directly by adding "/?__a=1" onto the end of the URL. For example:
The Instagram Graph API allows Instagram Professionals — Businesses and Creators — to use your app to manage their presence on Instagram.
Open Inspector in Chrome, visit Instagram and scroll through the posts, you'll see the same GraphQL queries with query_hash. I'm not sure what query_hash value means exactly, but they're static for each type of query it seems.
If you are building an app for consumers or you only need to get an app user's basic profile information, photos, and videos, consider the Instagram Basic Display API instead. The API is built on the Facebook Graph API.
This query_id
code https://www.instagram.com/graphql/query/?query_id=17851374694183129&id=<user_id>&first=1000&after=<end_cursor>
is designed to return ONLY media data it does NOT include user profile data.
The simplest solution is to use what IG uses on initial page requests:
https://www.instagram.com/<ig_username>/?__a=1
Here is my RubyOnRails setup:
profile = JSON.parse(open("https://www.instagram.com/<ig_username>/?__a=1").read)
... now grab your variables:
profile.['graphql']['user']['profile_pic_url']
profile.['graphql']['user']['biography']
profile.['graphql']['user']['external_url']
profile.['graphql']['user']['edge_followed_by']['count']
profile.['graphql']['user']['edge_follow']['count']
profile.['graphql']['user']['id']
profile.['graphql']['user']['edge_owner_to_timeline_media']['count']
profile.['graphql']['user']['profile_pic_url']
profile.['graphql']['user']['profile_pic_url_hd']
And your followed_by_count
is now ['graphql']['user']['edge_followed_by']['count']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With