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.

How to get all followers of a user with a lot of followers?

See original GitHub issue

Form

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

Question

I would like to get all the followers of a user, but as there are many, I think the only alternative would be to split requests between multiple accounts.

For example, one account would have followers from 0 to 10,000, while another would have followers between 10,000 and 20,000. But I couldn’t find any way to do this in the documentation, is it possible?

Code

async function getFollowers(
  username: string,
  ig: IgApiClient,
  { delay, limit, savePath }: GetFollowersOptions
): Promise<AccountFollowersFeedResponseUsersItem[]> {

  const id = await ig.user.getIdByUsername(username);
  const followersFeed = await ig.feed.accountFollowers(id);

  let followers: AccountFollowersFeedResponseUsersItem[] = [];
  let reqId = 0;
  do {
    reqId += 1;
    const items = await followersFeed.items();
    followers = [...followers, ...items];

    if (limit && limit !== -1) {
      if (followers.length >= limit) {
        break;
      }
    }

    await waitInSeconds(delay);
  } while (followersFeed.isMoreAvailable());
return followers
}

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
iitsurajcommented, Jun 7, 2021

You can use recursion Like this @khanakhun

  const id = await ig.user.getIdByUsername(username);
  const followersFeed = await ig.feed.accountFollowers(id);
  const followers = [];
  const e = async () => {
    let items = await followersFeed.items();
    // Save to database or append in json file
    followers.push(items);
    const isMore = await followersFeed.isMoreAvailable();
      if (isMore) {
        await delay(20 * 1000)  // delay 20 sec anti ban mode
        e();
      } else {
        console.log("=====> All Followers Extracted");
      }
  };
  await e()
};

0reactions
iitsurajcommented, Jun 7, 2021

Duplicate #988

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Get More Followers On Instagram: 22 Tips To Try
Learn how to get more Instagram followers without having to pay by following our 22 tried and tested tips that work.
Read more >
Get More Real Instagram Followers in 10 Steps | Sprout Social
Trying to figure out how to get more real followers on Instagram? This guide breaks down 10 tactics that can help boost your...
Read more >
23 Ways to Get More Followers on Instagram [Updated for 2022]
There are three types of Instagram users that can help you to get more followers: influencers, your customers and followers, and your ...
Read more >
How to Gain Your First (or Next) 1000 Instagram Followers
On Instagram, a hashtag ties conversations from different users who wouldn't already be connected into a single stream. If you use relevant ...
Read more >
How To Get Followers On Instagram – Step By Step Guide To ...
The personal approach of the direct message in combination with regular engagement will increase is a great tactic to get followers on Instagram ......
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