dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.99k stars 1.14k forks source link

Getting followers and followings in multiple of 5 or less than the actual followers #1653

Open nfarooq17 opened 2 years ago

nfarooq17 commented 2 years ago

const followerFeed = ig.feed.accountFollowers(req.body.pk);

do {
    let flwrs = await followerFeed.items()
    followers.push(...flwrs)
    Bluebird.delay(2000)
} while (followerFeed.isMoreAvailable())

If the use have number of followers 267, I am getting 265 same goes 

following users, I have read all the related issues but did not get any answer, please if anyone knows, help me out. Thanks

wlerin commented 2 years ago

I know very little about this library, but the fact you're ending up with a round(ish) number suggests you're not getting the last batch of followers. What happens if you attempt to read followerFeed.items() one last time after exiting the do-while?

Something similar happens to me but the difference usually is 10-20 followers and followings.

That sounds more like you're missing the first set.

The other option is it may not be returning some private accounts.

nfarooq17 commented 2 years ago

I know very little about this library, but the fact you're ending up with a round(ish) number suggests you're not getting the last batch of followers. What happens if you attempt to read followerFeed.items() one last time after exiting the do-while?

Something similar happens to me but the difference usually is 10-20 followers and followings.

That sounds more like you're missing the first set.

The other option is it may not be returning some private accounts.

I tried to check how many followers i am getting on every request, so if the total followers are 267 it is getting 99 100 66 SO is there any way or any solution for this problem.

wlerin commented 2 years ago

Sounds like it's the third option then, private accounts aren't shown. It's not really a "problem", nor is there a solution. You wouldn't be able to do anything with them even if they did show up.

nfarooq17 commented 2 years ago

Sounds like it's the third option then, private accounts aren't shown. It's not really a "problem", nor is there a solution. You wouldn't be able to do anything with them even if they did show up.

But there are almost 80% of the followers are private accounts and they are being shown but only 1 or 2. I need there pk to check somethings. If you can spare some time I can show you the whole code and if you can figure out whatsa the problem.

wlerin commented 2 years ago

If you're not getting the full amount with some requests but you are with others then the problem is on Instagram's end not with your code. Twitter does this sometimes when stuff has been deleted but I'm not sure if the same applies to Instagram.

Do you ever get a different number from the same account? And it's not new followers?

nfarooq17 commented 2 years ago

If you're not getting the full amount with some requests but you are with others then the problem is on Instagram's end not with your code. Twitter does this sometimes when stuff has been deleted but I'm not sure if the same applies to Instagram.

Do you ever get a different number from the same account? And it's not new followers?

I figured it out that it has to something with nextMaxId so I tried to play with nextMaxId and I did succeed but again on the following side that solution didn't work. Yes some times I am getting the same number and sometimes even less.

wlerin commented 2 years ago

At a glance, AccountFollowersFeed does not use a rank_token, while AccountFollowingFeed does. It is my understanding that such a token is required to make sure you are paging through the same feed (and it doesn't randomly mutate). That should make the latter more reliable? But it doesn't sound like it is from your experiments.

nfarooq17 commented 2 years ago

At a glance, AccountFollowersFeed does not use a rank_token, while AccountFollowingFeed does. It is my understanding that such a token is required to make sure you are paging through the same feed (and it doesn't randomly mutate). That should make the latter more reliable? But it doesn't sound like it is from your experiments.

Yes, I didn't get into rank_token, I just used NextMaxId and make it 100 at the beginning of the requests so in this way I was able to get followers same amount, but this didn't work with followings. Can we assign some limi per request or something like this??

wlerin commented 2 years ago

I just used NextMaxId and make it 100 at the beginning of the requests so in this way I was able to get followers same amount, but this didn't work with followings.

Are they actually unique followers (not repeats from the previous 100) though?

I'm not aware of any way to change the results per request. If the mobile app doesn't have that option it's unlikely to exist in the private (and undocumented) API.

nfarooq17 commented 2 years ago

I just used NextMaxId and make it 100 at the beginning of the requests so in this way I was able to get followers same amount, but this didn't work with followings.

Are they actually unique followers (not repeats from the previous 100) though?

I'm not aware of any way to change the results per request. If the mobile app doesn't have that option it's unlikely to exist in the private (and undocumented) API.

Yes they are unique, do you mind if you check my code and give a helpful suggestion to make it right