question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ig.feed.accountFollowers does not yield correct followers list when requesting on another accounnt

See original GitHub issue

Bug Report

Form

Put an [x] if you meet the condition, else leave [ ].

Requirements

  • I’ve searched the Issues
  • I’ve read the basic concepts
  • I’m using the latest version
  • I’ve debugged my code using the DEBUG variable.

Platform

  • I’m using Node.js version 10.13.0
  • I’m using electron
  • I’m using the browser YOUR_BROWSER_AND_VERSION
  • I’m using some other environment YOUR_ENV

Description

YOUR DESCRIPTION HERE Hello, it seems that I’m having an issue while trying to get the full followers list of an account, from a different account. I used the items() function to retrieve the data in a while loop that checks if there’s more availbale data. When I check the resulting followers list, I get the correct number of followers (length of the items array), however, when I inspect the list elements, I get different results from call to call (whilst being sure there are no updates on the real followers list on instagram), with duplicate usernames in the list. However, this issue doesn’t appear when I user this same method to check the followers list of the same account. I tried setting the maxId manually, as I thought there might be an issue with pagination, but it doesn’t seem to solve the problem. I don’t know if this is a bug, or if I’m not using something the right way, so if you could help me, that would be awesome 😃 !

Code

Add a meaningful section of your code here. If you are using TypeScript replace js with typescript.

  const ig = new IgApiClient();
  ig.state.generateDevice(*username*);
  //ig.state.proxyUrl = process.env.IG_PROXY;
  const auth = await ig.account.login(*username*, *password*);
  const followersFeed = ig.feed.accountFollowers(*different account pk*);
  var items = []
  do{
    const a  = await followersFeed.items();
    items = items.concat(a)
  }while(followersFeed.isMoreAvailable())

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:7

github_iconTop GitHub Comments

3reactions
jesusvallezcommented, Dec 22, 2020

Same problem here!

My code:

import { AccountFollowersFeedResponseUsersItem, IgApiClient } from 'instagram-private-api'

async function getFollowers(ig: IgApiClient, id: number) {
  let followers = ig.feed.accountFollowers(id)
  let result: AccountFollowersFeedResponseUsersItem[] = []
  let currentPage: AccountFollowersFeedResponseUsersItem[] = []

  do {
    currentPage = await followers.items()
    result = [...result, ...currentPage]
  } while (followers.isMoreAvailable())

  return result
}

;(async () => {
  const ig = new IgApiClient()
  const auth = await login(ig, IG_USERNAME, IG_PASSWORD)

  if (auth) {
    const userToStalk = 'xxxx'
    const id = await ig.user.getIdByUsername(userToStalk)
    const followersResults = await getFollowers(ig, id)
  }
})()
1reaction
jesusvallezcommented, Dec 24, 2020

It may be a bug, but probably not with this library. Kepp in mind, it just returns the data Instagram returns. It’s probably hard to count in the app, but when looking through the requests of the app, try counting the items. You’ll probably find the same issue. So this library can’t do much about this.

The number of followers is correct but when I list users… some are duplicated

EDIT: @khalilacheche, dirty workaround:

  let iterator = 1
  const times = 3
  let followersResultsLength = 0
  let followersResults: string[] = []

  do {
    const rawData = await getFollowers(ig, idToStalk)
    const rawDataName = rawData.map((user) => user.username).sort()
    followersResultsLength = rawData.length
    followersResults = [...followersResults, ...rawDataName]
    iterator++
  } while (iterator <= times)

  followersResults = followersResults.filter((e, i, a) => a.indexOf(e) === i)
  followersResultsLength === followersResults.length ? console.log('DONE') : console.log('FAIL')
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does one of my followers on Instagram not appear in my ...
If you can't see all of your Instagram followers when you look at your feed, it's possible your former followers' accounts have recently...
Read more >
Instagram Following List Order Algorithm Explained [2023]
No, being a social media “stalker” doesn't propel your client's Instagram account to the top of someone else's followers list.
Read more >
How To Get More Followers On Instagram: 22 Tips To Try
It should be no different when we share photos and videos on a business or brand's Instagram account. It's important to take time...
Read more >
Managing Your Followers - Instagram Help Center
How do I approve or deny a follower request on Instagram? ... How do I remove a follower on Instagram? ... Make your...
Read more >
3 Ways to Stop Auto Following on Instagram - wikiHow
1. Go to https://instagram.com and sign in. Before changing your password, make sure no unauthorized apps have permanent access to your account. You'll...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found