I am trying to retrieve the follower count only just using a user's instagram handle (aka @myusername). I read in several answers that you can access the "https://www.instagram.com/{username}/?__a=1" to retrieve the block of json that has all the details. However, when I try to do that now in 2020 after the api change, the url simply redirects me to the login page.
I also looked at instagram basic display/graph api but I can't seem to find a way to get other users' follower counts.
From the official ig basic display api documentation: https://developers.facebook.com/docs/instagram-basic-display-api/reference/user
This api only allows you to get the account_type, id, ig_id (about to be deprecated), media count and username. (no sign of follower count)
From the official ig graph api documentation:
https://developers.facebook.com/docs/instagram-api
"The API cannot access Intagram consumer accounts (i.e., non-Business or non-Creator Instagram accounts). If you are building an app for consumer users, use the Instagram Basic Display API instead."
Since my program is suppose to retrieve the follower count from accounts that are not necessarily professional, I can't seem to figure out what to do...
In conclusion:
Does anyone have a solution for this?
Thank you!
In 2018, Instagram shut down its public API. Meaning, third-party apps can no longer access the API from Instagram without permission. Third-party apps now need to be approved by Instagram before they can access the API.
Instagram announced a depreciation of the Basic Permission for its Legacy API Platform. Update: Instagram made the API change on the 29th of June, 2020 and not on the initially announced date – 2nd of March, 2020.
The API can be used to get and publish their media, manage and reply to comments on their media, identify media where they have been @mentioned by other Instagram users, find hashtagged media, and get basic metadata and metrics about other Instagram Businesses and Creators.
Instagram blocked your IP ... you need to use undetected proxies to scrape that from Instagram, usually, Residential IPs passed.
send HTTP request to IG API end > if got JSON response it's good and not detected, else it's detected proxy and not good for Instagram.
code for that (in c# but could follow the same logic in python) :
var httpClientHandler = new HttpClientHandler()
{
Proxy = new WebProxy("127.0.0.1:8080", false),
UseProxy = true
};
var client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
var response = await client.GetAsync("https://www.instagram.com/instagram/?__a=1");
if ( response.Content.Headers.ContentType.MediaType == "application/json")
{
// Not detected proxy and good for Instagram
}
else
{
// Detected proxy and not good for Instagram
}
If you ask why Instagram is blocking some IPs? simply Instagram has a huge database that contains past IPs who sent more than the allowed limit requests ... they are doing that to prevent scraping.
You can use Instaloader Python module. Here is a quic example:
import instaloader
L = instaloader.Instaloader()
user = "IG_USERNAME"
password = "IG_PASSWORD"
L.login(user, password)
profile = instaloader.Profile.from_username(L.context, user)
print(profile.followees) #number of following
print(profile.followers) #number of followers
print(profile.full_name) #full name
print(profile.biography) #bio
print(profile.profile_pic_url) #profile picture url
print(profile.get_posts()) #list of posts
print(profile.get_followers()) #list of followers
print(profile.get_followees()) #list of followees
Had the same problem. I ended up inspecting instagram network and found this:
https://i.instagram.com/api/v1/users/web_profile_info/?username=<USERNAME>.
Make sure you put a user-agent
header in the request with this value:
Instagram 76.0.0.15.395 Android (24/7.0; 640dpi; 1440x2560; samsung; SM-G930F; herolte; samsungexynos8890; en_US; 138226743)
you can get the follower count on data.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