Ashvini Panwar
Ashvini Panwar

Reputation: 105

Instagram follower count endpoint in 2020

I have been struggling with the Instagram APIs and can't find a solution to fetch the follower count a user on Instagram. I too have APIs where I fetch user's media and username using Instagram basic display Graph API, but I can see nowhere how to get the follower count.

I tried the https://www.instagram.com/<username>/?__a=1 url as well but it worked on my local system but when I pushed this on server it stopped working after a while, similarly I also tried

request.get(url, function(err, response, body){
    if(response.body.indexOf(("meta property=\"og:description\" content=\"")) != -1){
        console.log("followers:", response.body.split("meta property=\"og:description\" content=\"")[1].split("Followers")[0])
    }
 });

This didn't work either on my server.

Upvotes: 0

Views: 1989

Answers (1)

Aditya Kurkure
Aditya Kurkure

Reputation: 422

This will give you the followers count from the endpoint you have mentioned.

const axios = require('axios').default;

axios.get("https://www.instagram.com/username/?__a=1")
.then(res=>{
console.log("res="+JSON.stringify(res.data.graphql.user.edge_followed_by.count));
})
.catch(err=>{
console.log("error:\n"+err);
})
.finally(()=>
console.log("end"));

Check out this website to learn how to make request with axios

Here we make a simple get request to the server and it return an Object (res.data). We then simply access the required data.

Upvotes: 1

Related Questions