# How to Get Instagram Followers and Following with Python or Node.js (2026)

> A working tutorial: fetch a public Instagram profile, its followers and its following list with Python or Node.js through the Klupt API, page through the results, use the cache, handle errors and watch for new follows.

- Source: https://klupt.io/blog/get-instagram-followers-api-python-nodejs
- Author: Sarah Mitchell
- Publisher: Klupt (https://klupt.io)
- Published: 2026-11-29

**Short answer:** Meta's official API won't give you a followers or following list, so you need a data API. With the [Klupt API](https://klupt.io/api) it's one GET request per page: `/v1/users/{user}/followers` returns a public account's **newest followers first**, `/v1/users/{user}/following` its **latest follows first**, and you page with a cursor. Below is working code in Python and Node.js, plus paging, caching, errors and a loop that spots new follows.

> Start with a sandbox key (`kd_test_...`): it returns sample data in the same schema, so all the code below runs before you spend anything. Switch to a live key (`kd_live_...`) when you're ready. [Get an API key](https://api.klupt.io/signup).

## What you need

- A Klupt API key, stored in an environment variable: `export KLUPT_API_KEY=...`. Sign up with your company, website and use case; sandbox keys with sample data work right away (unlimited), a verified business email adds 25 live test calls and an approved account 50 more.
- Python 3.9+ with `requests`, or Node.js 18+ (built-in `fetch`)
- The username of a **public** Instagram account

Every call goes to `https://api.klupt.io/v1` with an `X-Api-Key` header. Responses have the shape `{ data, pagination, meta }`.

## Step 1: look up the profile

Check the account exists and is public before you pull lists, and read its counts.

```python
import os, requests

API = "https://api.klupt.io/v1"
HEADERS = {"X-Api-Key": os.environ["KLUPT_API_KEY"]}

profile = requests.get(f"{API}/users/natgeo", headers=HEADERS, timeout=30).json()["data"]
print(profile["username"], profile["counts"]["followers"], profile["counts"]["following"])
```

`{user}` can be a username or a numeric Instagram user id. Ids skip a lookup, so store them once you have them.

## Step 2: fetch the first page of followers or following

```python
r = requests.get(f"{API}/users/natgeo/following", headers=HEADERS, timeout=30)
r.raise_for_status()
body = r.json()
for item in body["data"]:
    print(item["position"], item["username"], item["is_verified"])
print(body["meta"]["order"])  # "newest_first"
```

The same in Node.js:

```js
const API = "https://api.klupt.io/v1";
const headers = { "X-Api-Key": process.env.KLUPT_API_KEY };

const res = await fetch(API + "/users/natgeo/followers", { headers });
const body = await res.json();
if (!res.ok) throw new Error(body.error.code);
body.data.forEach((u) => console.log(u.position, u.username));
```

**Position 1 is the newest.** For `following` that's the account they followed most recently; for `followers` it's the account that followed them most recently. A followers page holds up to 25 accounts and a following page up to about 200.

## Step 3: page through the list

Pass `pagination.next_cursor` back as `?cursor=` until `has_more` is false. Cursors are opaque and tied to one endpoint and account.

```python
def iter_list(user, kind="following", max_pages=10):
    cursor = None
    for _ in range(max_pages):
        params = {"cursor": cursor} if cursor else {}
        r = requests.get(f"{API}/users/{user}/{kind}", headers=HEADERS, params=params, timeout=30)
        r.raise_for_status()
        body = r.json()
        yield from body["data"]
        cursor = body["pagination"]["next_cursor"]
        if not body["pagination"]["has_more"]:
            break

latest_100 = [u["username"] for u, _ in zip(iter_list("natgeo", "followers"), range(100))]
```

```js
async function* iterList(user, kind = "following", maxPages = 10) {
  let cursor = null;
  for (let i = 0; i < maxPages; i++) {
    const url = new URL(API + "/users/" + user + "/" + kind);
    if (cursor) url.searchParams.set("cursor", cursor);
    const body = await (await fetch(url, { headers })).json();
    yield* body.data;
    if (!body.pagination.has_more) break;
    cursor = body.pagination.next_cursor;
  }
}
```

Because the list is newest first, you rarely need all of it. If you only care about recent activity, one or two pages is enough, and that's where most of the savings come from.

## Step 4: use the cache instead of fighting it

Answers are cached and shared across customers. Every response tells you what you got:

- `meta.cached` and `meta.cache_age_seconds` (and the `X-Klupt-Cache: HIT` header)
- A cache hit **costs half**
- Add `?fresh=true` (or `Cache-Control: no-cache`) when you need a live read, at full price

A good default: let the cache serve dashboards and reports, and use `fresh=true` only in the job that detects changes.

## Step 5: handle errors

Errors look like `{ "error": { "code": "private_account", "message": "...", "request_id": "..." } }`. **Failed calls are not charged.**

| Status | Code | What to do |
|---|---|---|
| 403 | `private_account` | Skip: only public accounts are covered |
| 404 | `user_not_found` | The username changed or the account is gone |
| 402 | `insufficient_credits` | Top up or move to a plan |
| 429 | `rate_limited` | Wait `Retry-After` seconds |
| 502 / 504 | `upstream_unavailable`, `upstream_timeout` | Retry with backoff |
| 503 | `order_unavailable` | Only with `strict_order=true`: no newest-first list right now |

```python
import time

def get(path, params=None, tries=4):
    for attempt in range(tries):
        r = requests.get(f"{API}{path}", headers=HEADERS, params=params, timeout=30)
        if r.status_code in (429, 502, 503, 504):
            time.sleep(int(r.headers.get("Retry-After", 2 ** attempt)))
            continue
        r.raise_for_status()
        return r.json()
    raise RuntimeError("gave up on " + path)
```

## Step 6: watch a profile for new follows

There are no webhooks in the first version, so poll. Since position 1 is always the newest, you only compare the top of the list with what you saw last time:

```python
import json, pathlib

def new_follows(user):
    seen_file = pathlib.Path(f"seen_{user}.json")
    seen = set(json.loads(seen_file.read_text())) if seen_file.exists() else set()
    page = get(f"/users/{user}/following", params={"fresh": "true"})["data"]
    fresh = [u["username"] for u in page if u["username"] not in seen]
    seen_file.write_text(json.dumps([u["username"] for u in page]))
    return fresh if seen else []  # first run sets the baseline

print(new_follows("natgeo"))
```

Run it from cron or a scheduler. **Instagram doesn't share follow dates**, so the first time your job sees an account is your best timestamp. Anything that shows exact follow dates for someone else's follows is guessing.

## What it costs

Klupt charges per request: **$2.00 per 1,000** pay as you go, down to $1.52 with the largest pack, $1.33 on the Growth plan, and custom from $1.00 at Scale. A following page counts as two requests; cached answers cost half; failed calls are free. Two examples:

- **100 profiles, newest follows once a day:** 100 × 30 days × 2 = 6,000 requests a month, about **$12**.
- **100 profiles, every hour:** 144,000 requests a month at full price, which fits the **Growth plan ($199, 150,000 requests)**, and less once cache hits kick in.

Full prices are on the [Klupt API page](https://klupt.io/api).

## Why not scrape it yourself?

You can, with a logged-in session and a library like instaloader or instagrapi, but you take on the work: login challenges, rotating proxies, rate limits, account bans and, since Instagram's September 2026 update, lists that no longer come back newest first. Using a throwaway account to read data also breaks Instagram's terms more directly than reading public data logged out. More on the ordering problem in [how to get an Instagram following list in chronological order](https://klupt.io/blog/instagram-following-list-chronological-order-api).

## FAQ

### Can I get Instagram followers with Python without logging in?
Yes, for public accounts, through a data API such as the Klupt API. You send an API key, not an Instagram login.

### Does the official Instagram Graph API return a followers list?
No. It returns follower and following counts for professional accounts, never the list.

### How many followers come back per request?
Up to 25 per followers page and up to about 200 per following page. Use the cursor for the next page.

### How much does it cost to fetch followers through the Klupt API?
$2.00 per 1,000 requests pay as you go, less with packs or a plan. A following page counts as two, cached answers cost half and failed calls are free.

### Can I get followers of a private account?
No. The API only covers public accounts.
