How to get an Instagram follower count in Node.js

Checked on 2026-11-24.

From Node.js there are three ways to read an Instagram follower count. Meta's official API answers a plain fetch call, but only for business and creator accounts and only after you set up an app and a token. The npm package instagram-private-api logs in as an Instagram account of yours. An HTTP API reads the public profile of any username with one key.

1. Meta's official API, with fetch

The official route is the Instagram Platform. It is a plain HTTPS API, so fetch, built into Node.js 18 and newer, is all the code needs. Its overview states the condition up front: "To use the APIs, your app users must have an Instagram professional account." For somebody else's numbers there is Business Discovery, which its reference describes as a way "to get data about other Instagram Business or Creator IG Users". You send the request to your own account's ID and name the other account inside the fields parameter. This is the request from Meta's guide, in JavaScript:

JavaScript
const ME = process.env.IG_ACCOUNT_ID; // the ID of your own professional account
const url = new URL(`https://graph.facebook.com/v27.0/${ME}`);
url.searchParams.set('fields', 'business_discovery.username(bluebottle){followers_count,media_count}');
url.searchParams.set('access_token', process.env.IG_ACCESS_TOKEN);

const body = await (await fetch(url)).json();
if (body.error) {
  console.log(body.error.message);
} else {
  const { followers_count, media_count } = body.business_discovery;
  console.log(followers_count, media_count);
}

bluebottle is the account Meta's own example reads. Before the first call you need an Instagram professional account of your own, a Meta app and an access token. The reference asks for a Facebook User access token with the permissions instagram_basic, instagram_manage_insights and pages_read_engagement, and the guide says the API "is available with both the Instagram API with Facebook Login and the Instagram API with Unified Login", the setup the overview recommends for new integrations. If the app serves only your own account, "Standard Access is all your app needs". An app that other people connect their accounts to needs Advanced Access, which "requires App Review and Business Verification". Long-lived tokens are "valid for 60 days and can be refreshed before they expire".

Where it stops: at personal accounts, because the Platform is for professional accounts and Business Discovery reads business and creator accounts only, and at age-gated ones: "Data about age-gated Instagram professional accounts will not be returned." A username does not tell you which kind of account it belongs to, so a list of usernames will have gaps. And it is a lot of setup for one number: an app, a professional account and a token to keep fresh.

2. npm packages that read Instagram directly

On npm, instagram-private-api calls itself an "Instagram private API wrapper for full access to instagram". It works as a logged-in user: the example in its README logs in with an Instagram username and password (ig.account.login(...)) before it reads anything, and its user.usernameinfo() method then returns a user with follower_count.

Where it stops: at the login. It needs an Instagram account of yours, and every request is made as that account. Use one you can afford to lose, never one that is not yours, and read Instagram's Terms of Use before you automate an account. The package is not new either: the latest version on npm is 1.46.1, published on 7 March 2024, and its README says the next major version "is hosted in a private repository and access is paid". Older tutorials use instagram-web-api, whose latest version, 2.2.2, came out on 6 August 2020.

If you work in Python, the Python version of this guide covers the Instaloader library, and the guide to its 401, 429 and login errors covers what happens when Instagram refuses.

3. An HTTP API, with fetch or the npm client

With Pipefetch the profile is one HTTPS request with one key. It reads the public profile, so there is no Instagram account, no Meta app and no token, and it makes no difference whether the account is personal, business or creator. A plain fetch call:

JavaScript
const url = new URL('https://pipefetch.com/v1/instagram/profile');
url.searchParams.set('username', 'nasa'); // a username, an @handle or a profile URL
url.searchParams.set('posts', 'false'); // leave the latest posts out; same price

const res = await fetch(url, {
  headers: { 'x-api-key': process.env.PIPEFETCH_API_KEY },
  signal: AbortSignal.timeout(90_000),
});
if (res.status === 404) {
  console.log('No such account'); // not charged
} else if (!res.ok) {
  throw new Error(`Pipefetch answered ${res.status}`); // a 502 is not charged and can be sent again
} else {
  const { data } = await res.json();
  console.log(data.username, data.followerCount, data.followingCount, data.postCount);
}

Or with the client from npm, pipefetch, which has no dependencies, includes TypeScript types and retries a 502 by itself:

JavaScript
// npm install pipefetch
import Pipefetch, { NotFoundError } from 'pipefetch';

const pf = new Pipefetch(); // reads PIPEFETCH_API_KEY

try {
  const profile = await pf.instagramProfile('nasa', { posts: false });
  console.log(profile.followerCount, profile.isPrivate, profile.accountType);
  console.log(pf.credits); // what the request cost and what is left
} catch (error) {
  if (error instanceof NotFoundError) console.log('No such account'); // not charged
  else throw error;
}

followerCount, followingCount and postCount are the exact numbers, not the rounded ones Instagram displays (104M). A private account returns its counts, name and bio with isPrivate true. One profile costs 2 credits, an account that does not exist answers 404 and costs nothing, and a new account has 100 free credits and needs no card. The reference lists every field, including the latest posts you get when you leave posts on.

Where it stops: this is not an official API, and Pipefetch is not affiliated with Instagram or Meta. It returns what a profile shows to a visitor who is not logged in: no follower lists, no stories, no posts of private accounts. Every request is read live, so it takes a few seconds (most take 2 to 9 seconds), and when Instagram does not answer you get a 502 that is not charged.

Which one should you use?

SituationUse
Your own account, or business and creator accounts, and you want Meta's own numbersThe official API with fetch
You need what only a logged-in user sees, with your own account and at your own riskinstagram-private-api
Any public username, whatever the account type, from a server or a scheduled jobAn HTTP API such as Pipefetch

Keep tokens and keys on the server

Whichever route you take, the call belongs in server code: a Node.js process, an API route or a serverless function. An Instagram access token or a Pipefetch key that ships to the browser can be read by anyone who opens the page. Read the count on the server and send only the number to the page.

If you only know what a business is called, the search endpoint finds business and creator accounts by the words in their name, with their follower counts, for 1 credit. It asks the advertiser search of Meta's Ad Library, so it is not the search of the Instagram app, and a personal account with no Facebook Page behind it is not found.

Try it with 100 free credits. No card needed. No login, cookies or proxies. Get an API key or read the docs.

Every source

YouTube

Websites

TikTok

Facebook

Google

Threads

LinkedIn

App stores

Steam

X

Pinterest

Airbnb

Real estate

Keywords

Job boards

Eventbrite

Shopify stores

Public tenders

All guides