Guide · Python

Scrape Instagram usernames and user IDs with Python

Collect accounts from a keyword, a follower list or a post's comments with the numeric ID behind every handle, convert a mixed list both ways, and find the accounts that changed their name.

ScrapingBot 10 min read
Endpoints
/user/by_username, /user/by_id
Cost
5 credits per call
Language
Python 3.9+
Needs
requests
On this page

"Scrape Instagram usernames" is two jobs. One is collecting accounts: everyone who follows a brand, everyone who commented on a post, every account that shows up for a keyword. The other is the number behind each handle. Every Instagram account has a numeric user ID, the list endpoints are keyed on it, and it is the only part of an account that never changes.

This guide does both. It shows the two lookups, username to ID and ID to username, then a script that collects usernames with their IDs from five kinds of list without looking a single account up, a second one that converts a mixed list of handles, links and IDs, and a third that finds renamed accounts. Every response and output below is real, collected on November 24, 2026.

Before you start

  • A ScrapingBot API key. Create a free account for 100 credits, enough for 20 calls: 20 lookups, or 20 list pages of about 49 accounts each. No card needed.
  • Python 3.9 or newer and pip install requests.
  • Somewhere to start: a keyword, an account, a post link or a list of handles.

Why you want the ID, not the handle

A handle is a label the owner can change in a few taps. The ID is assigned once. Here is one account, seven years apart:

WhenUser IDUsernameSource
June 1, 20191495338308@oculusThe page source of the Internet Archive's copy of instagram.com/oculus
November 24, 20261495338308@metavr/user/by_id

A spreadsheet that stored "oculus" lost the account: looking that handle up today returns 404, "Instagram user was not found." A table keyed on 1495338308 follows it through the rename, and through the next one. So whatever you collect, store the ID with it.

Username to user ID: /user/by_username

Every Instagram call is a POST to https://scrapingbot.io/api/v1/instagram with the endpoint and its parameters in the body:

curl -X POST https://scrapingbot.io/api/v1/instagram \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"endpoint": "/user/by_username", "params": {"username": "nasa"}}'
{
  "success": true,
  "data": {
    "id": "528817151",
    "pk": "528817151",
    "username": "nasa",
    "full_name": "NASA",
    "is_private": false,
    "is_verified": true,
    "follower_count": 104233038,
    "following_count": 91,
    "fbid_v2": "17841401474538262",
    …
  },
  "duration": "0.43",
  "statusCode": 200,
  "creditsUsed": 5
}

data.id is the user ID, as a string; pk holds the same value. The lookup is not fussy about how the handle is written. Every way of writing @nasa below returned ID 528817151; the last row is a handle that does not exist:

Sent as usernameResult
nasa, NASA, @NASAFound. Case and the @ do not matter.
https://www.instagram.com/nasa/?hl=enFound. A profile link works, tracking parameters included.
instagram.com/nasaFound.
thishandledoesnotexist_zz9q404, "Instagram user was not found." Not charged.

A private account is found like any other: you get its ID, handle, name and counts with is_private: true. Its posts and its follower lists come back empty.

Handles made only of digits

Some handles are numbers. @433, a football account with 79.6 million followers, is one. Sent bare, 433 is read as a user ID, and the lookup answers with a different account: the one whose ID is 433. Write it as @433 or as https://www.instagram.com/433/ and you get the account with that handle, ID 253625977. The same goes for user_id on the list endpoints. Below, ig_ids.py always sends a handle with its @; ig_collect.py passes the account on as you type it, so type @433.

User ID to username: /user/by_id

The other direction takes the number as user_id and returns the same profile object:

curl -X POST https://scrapingbot.io/api/v1/instagram \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"endpoint": "/user/by_id", "params": {"user_id": "1495338308"}}'
{
  "success": true,
  "data": {
    "id": "1495338308",
    "username": "metavr",
    "full_name": "Meta VR",
    "is_private": false,
    "is_verified": true,
    "follower_count": 903229,
    "following_count": 115,
    …
  },
  "duration": "0.58",
  "statusCode": 200,
  "creditsUsed": 5
}

username is the handle the account uses now. An ID that belongs to no account returns the same free 404 as a missing handle. One trap: fbid_v2, the longer number that starts with 17841 in the first response, is not a user ID for these endpoints. We sent NASA's to /user/by_id and got a 404.

Lists already carry the ID

Looking accounts up one at a time is the expensive way to build a list. Every response that lists accounts already has each one's id and username. Here are three of the 46 accounts on one page of @specialtycoffeeassociation's following list:

{
  "success": true,
  "data": {
    "users": [
      …,
      { "id": "1034466", "username": "starbucks", "full_name": "Starbucks", "is_private": false, "is_verified": true, … },
      …,
      { "id": "1822638", "username": "reuters", "full_name": "Reuters", "is_private": false, "is_verified": true, … },
      …,
      { "id": "224665345", "username": "nespressousa", "full_name": "Nespresso USA", "is_private": false, "is_verified": true, … },
      …
    ],
    "page_size": 46,
    "user_count": 2155,
    "has_more": true,
    "next_max_id": "QVHz_GZ-wt6UsQAAAC63aauycyW8EBl3",
    …
  },
  "duration": "2.35",
  "statusCode": 200,
  "creditsUsed": 5
}

Five sources, with what each gave us in one run and what that works out to per 1,000 accounts:

SourceEndpointAccounts in our runAlso returnedCredits per 1,000
Followers of an account/followers/by_user_id244 from 5 pagesprivate, verifiedabout 100
Accounts it follows/following/by_user_id148 from 3 pagesprivate, verifiedabout 100
Accounts for a keyword/search/users_by_keyword17 from the one page there isverifiedabout 290
Commenters on a post/comments/media_comments_by_id59 from 4 pagesprivate, verifiedabout 340
Authors of top posts for a keyword/search/posts7 from one page of 8 postsprivate, verified, follower countabout 710
One lookup per account/user/by_username1 per callthe full profile5,000

A follower list gives you an account, its ID and whether it is private for a tenth of a credit. Save the 5-credit lookup for the accounts you need follower counts or a bio for.

The list endpoints take the account in user_id. A number is used as the ID; a handle is looked up first, inside the same call and for the same 5 credits. So you can pass a handle and never convert it yourself.

The collector

Save this as ig_collect.py. It reads one of the five sources and adds every account it has not seen to ig_accounts.csv, keyed on the user ID.

import csv
import os
import sys
import time
from datetime import date

import requests

API = "https://scrapingbot.io/api/v1/instagram"
HEADERS = {"x-api-key": "YOUR_API_KEY"}
OUT = "ig_accounts.csv"
FIELDS = ["user_id", "username", "full_name", "private", "verified", "followers",
          "source", "first_seen"]
credits = {"used": 0}


def call(endpoint, params, tries=4):
    """One Instagram call: 5 credits on success. Failed calls are refunded."""
    error = "no answer"
    for attempt in range(tries):
        try:
            res = requests.post(API, headers=HEADERS, timeout=90,
                                json={"endpoint": endpoint, "params": params})
            body = res.json()
            if not isinstance(body, dict):
                raise ValueError("unexpected response")
        except (requests.RequestException, ValueError) as err:
            error = str(err)  # a dropped connection or a non-JSON answer: try again
        else:
            if body.get("success"):
                credits["used"] += body.get("creditsUsed", 0)
                return body["data"]
            error = body.get("error") or f"HTTP {res.status_code}"
            if res.status_code in (400, 401, 402, 403, 404):
                raise RuntimeError(error)  # bad input, key or balance: retrying will not help
        time.sleep(2 ** attempt)  # 408, 429 or 5xx: wait and try again
    raise RuntimeError(f"kept failing: {error}")


def search(keyword, pages):
    """Accounts Instagram suggests for a keyword. One page per keyword."""
    data = call("/search/users_by_keyword", {"keyword": keyword})
    for hit in data.get("users") or []:
        yield hit["user"]


def follow_list(kind):
    """Followers or following of an account, about 45 per page."""
    def read(account, pages):
        params = {"user_id": account}
        for _ in range(pages):
            data = call(f"/{kind}/by_user_id", params)
            yield from data.get("users") or []
            if not data.get("has_more") or not data.get("next_max_id"):
                break
            params = {"user_id": account, "max_id": data["next_max_id"]}
    return read


def commenters(post, pages):
    """Everyone who commented on a post or reel (shortcode or link)."""
    params = {"code_or_id_or_url": post}
    for _ in range(pages):
        data = call("/comments/media_comments_by_id", params)
        for comment in (data.get("data") or {}).get("items") or []:
            yield comment["user"]
        if not data.get("pagination_token"):
            break
        params = {"code_or_id_or_url": post, "pagination_token": data["pagination_token"]}


def post_authors(keyword, pages):
    """Authors of the top posts for a keyword. These come with a follower count."""
    data = call("/search/posts", {"query": keyword})
    for item in (data.get("data") or {}).get("items") or []:
        yield item["user"]


SOURCES = {"search": search, "followers": follow_list("followers"),
           "following": follow_list("following"), "commenters": commenters,
           "posts": post_authors}


def text(value):
    """Names are free text: keep a spreadsheet from running one as a formula."""
    value = " ".join(str(value or "").split())
    return "'" + value if value[:1] in ("=", "+", "-", "@") else value


def load(path):
    if not os.path.exists(path):
        return {}
    with open(path, newline="", encoding="utf-8") as f:
        return {row["user_id"]: row for row in csv.DictReader(f)}


def save(path, accounts):
    with open(path + ".tmp", "w", newline="", encoding="utf-8") as f:
        writer = csv.DictWriter(f, fieldnames=FIELDS)
        writer.writeheader()
        writer.writerows(accounts.values())
    os.replace(path + ".tmp", path)  # the old file stays whole if the run is cut short


if __name__ == "__main__":
    if len(sys.argv) < 3 or sys.argv[1] not in SOURCES:
        sys.exit("usage: python ig_collect.py search|followers|following|commenters|posts "
                 "<keyword, account or post> [pages]")
    source, target = sys.argv[1], sys.argv[2]
    pages = int(sys.argv[3]) if len(sys.argv) > 3 else 1

    accounts = load(OUT)
    seen = new = 0
    stopped = None
    try:
        for user in SOURCES[source](target, pages):
            seen += 1
            user_id = str(user.get("id") or user.get("pk") or "")
            if not user_id or not user.get("username"):
                continue
            known = accounts.get(user_id)
            if known:
                if known["username"] != user["username"]:  # same ID, new handle
                    print(f"renamed: @{known['username']} is now @{user['username']}")
                    known["username"] = user["username"]
                if known["followers"] == "" and user.get("follower_count") is not None:
                    known["followers"] = user["follower_count"]
                continue
            new += 1
            accounts[user_id] = {
                "user_id": user_id, "username": user["username"],
                "full_name": text(user.get("full_name")),
                "private": user.get("is_private", ""), "verified": user.get("is_verified", ""),
                "followers": user.get("follower_count", ""),
                "source": f"{source}:{target}", "first_seen": date.today().isoformat()}
    except RuntimeError as err:
        stopped = err  # keep what was read before the page that failed
    save(OUT, accounts)
    print(f"{source} {target}: {seen} accounts read, {new} new, "
          f"{credits['used']} credits; {len(accounts)} in {OUT}")
    if stopped:
        sys.exit(f"stopped early: {stopped}")
  • The file is keyed on user_id. An account that shows up in two sources, or on two pages, is stored once. If a known ID comes back under a new handle, the script prints the rename and updates the row.
  • pages caps the spend. Each page is one call and 5 credits. Keyword search and post search return a single page, so the number is ignored there.
  • The account goes out as you typed it. A handle, an @handle or a numeric ID all work for followers and following. A bare number is taken as an ID, so give a handle made only of digits its @: python ig_collect.py following @433.
  • Nothing read is lost. If a page fails for good, the accounts from the pages before it are still written, and the file is replaced in one step, so a run cut short cannot leave half a file.
  • Names are cleaned. Display names are free text. Line breaks are flattened, and a name that starts with =, +, - or @ gets a leading apostrophe so a spreadsheet does not run it as a formula.
  • Errors. A bad key, an empty balance or a missing account stops the run with the reason. Timeouts, 429 and server errors are retried with a growing pause. Failed calls are refunded.

Run it

The source, then a keyword, an account or a post, then the number of pages:

python ig_collect.py search "specialty coffee"
python ig_collect.py posts "specialty coffee"
python ig_collect.py followers specialtycoffeeassociation 5
python ig_collect.py following specialtycoffeeassociation 3
python ig_collect.py commenters Dcgza21gR2n 4
search specialty coffee: 17 accounts read, 17 new, 5 credits; 17 in ig_accounts.csv
posts specialty coffee: 8 accounts read, 7 new, 5 credits; 24 in ig_accounts.csv
followers specialtycoffeeassociation: 244 accounts read, 244 new, 25 credits; 268 in ig_accounts.csv
following specialtycoffeeassociation: 148 accounts read, 148 new, 15 credits; 416 in ig_accounts.csv
commenters Dcgza21gR2n: 60 accounts read, 59 new, 20 credits; 475 in ig_accounts.csv

475 accounts with their IDs for 70 credits, in 62 seconds. The first rows:

user_id,username,full_name,private,verified,followers,source,first_seen
250893765,specialtycoffee,Specialty Coffee • Community,,False,,search:specialty coffee,2026-11-24
38670956936,specialty.coffee,Gayo Arabica Specialty Coffee,,False,,search:specialty coffee,2026-11-24
…
1107960223,blackmarket.coffee,Black Market Coffee - Sydney Coffee Roaster,False,False,37498,posts:specialty coffee,2026-11-24

What the run showed:

  • Followers are often private. 101 of the 244 followers were private accounts, against 1 of the 148 accounts the association follows and 21 of the 59 commenters. The list still gives you their handle and ID; their posts are closed to everyone who does not follow them.
  • Search results are the thinnest. Keyword search returns the handle, ID, name and verified badge, with no private flag and no counts. Only post search includes a follower count.
  • Pages are a bit under 50. The follower pages averaged 49 accounts and the comment pages 15. On a busy post, people comment more than once: 60 comments came from 59 people.
  • Long lists have their own quirks. Instagram cuts some accounts' follower lists off at about 50, and a full read can leave a few accounts out. Exporting followers and following shows how to spot both, and exporting comments covers replies.

Convert a mixed list both ways

The other common starting point is a list someone else made: handles, @handles, profile links and bare IDs in one column. Save this as ig_ids.py. It works out what each line is, looks it up the right way, and writes one row per line with the ID and the current handle.

import csv
import re
import sys
import threading
import time
from concurrent.futures import ThreadPoolExecutor

import requests

API = "https://scrapingbot.io/api/v1/instagram"
HEADERS = {"x-api-key": "YOUR_API_KEY"}
CONCURRENCY = 1  # your plan's limit: Free 1, Starter 10, Startup 50
FIELDS = ["input", "type", "user_id", "username", "full_name", "private", "verified",
          "followers", "status"]
LINK = re.compile(r"(?:https?://)?(?:www\.|m\.)?instagram\.com/([^?#]*)", re.I)
HANDLE = re.compile(r"[a-z0-9._]{1,30}")
NOT_PROFILES = {"p", "reel", "reels", "tv", "stories", "explore"}
credits = {"used": 0}
stopped = {"why": None}
lock = threading.Lock()


class NotFound(Exception):
    pass


def call(endpoint, params, tries=4):
    """One Instagram call: 5 credits on success. Failed calls are refunded."""
    error = "no answer"
    for attempt in range(tries):
        try:
            res = requests.post(API, headers=HEADERS, timeout=90,
                                json={"endpoint": endpoint, "params": params})
            body = res.json()
            if not isinstance(body, dict):
                raise ValueError("unexpected response")
        except (requests.RequestException, ValueError) as err:
            error = str(err)  # a dropped connection or a non-JSON answer: try again
        else:
            if body.get("success"):
                with lock:
                    credits["used"] += body.get("creditsUsed", 0)
                return body["data"]
            error = body.get("error") or f"HTTP {res.status_code}"
            if res.status_code == 404:  # no such account: retrying will not help
                raise NotFound(error)
            if res.status_code in (401, 402):  # bad key or out of credits
                raise PermissionError(error)
            if res.status_code in (400, 403):
                raise RuntimeError(error)
        time.sleep(2 ** attempt)  # 408, 429 or 5xx: wait and try again
    raise RuntimeError(f"kept failing: {error}")


def parse(line):
    """('username', handle), ('id', digits) or ('skip', reason) for one line of the list."""
    s = line.strip()
    link = LINK.match(s)
    if link:  # a profile link has one thing after the domain: the handle
        parts = [part for part in link.group(1).split("/") if part]
        if len(parts) != 1 or parts[0].lower() in NOT_PROFILES:
            return "skip", "not a profile link"
        s = "@" + parts[0]
    if s.isascii() and s.isdigit():
        return "id", s.lstrip("0") or "0"  # a bare number is an account ID; write @433 for the handle
    handle = s.lstrip("@").lower()
    return ("username", handle) if HANDLE.fullmatch(handle) else ("skip", "not a handle")


def text(value):
    """Free text bound for a CSV cell: keep a spreadsheet from running it as a formula."""
    value = " ".join(str(value or "").split())
    return "'" + value if value[:1] in ("=", "+", "-", "@") else value


def lookup(item):
    kind, value = item
    if stopped["why"]:
        return {"status": "not checked"}
    try:
        if kind == "id":
            p = call("/user/by_id", {"user_id": value})
        else:
            # The @ makes it a username even when the handle is all digits.
            p = call("/user/by_username", {"username": "@" + value})
    except NotFound:
        return {"status": "not found"}
    except PermissionError as err:
        stopped["why"] = str(err)  # the rest of the list would fail the same way
        return {"status": "not checked"}
    except RuntimeError as err:
        return {"status": f"error: {err}"}
    answered = str(p.get("id")) == value if kind == "id" else str(p.get("username")).lower() == value
    return {"status": "ok" if answered else "answered as another account",
            "user_id": p.get("id"), "username": p.get("username"),
            "full_name": text(p.get("full_name")),
            "private": p.get("is_private"), "verified": p.get("is_verified"),
            "followers": p.get("follower_count")}


def resolve(lines):
    """One row per non-blank line, in the order given. Each account is looked up once."""
    lines = [line.strip() for line in lines if line.strip()]
    items = [parse(line) for line in lines]
    wanted = list(dict.fromkeys(item for item in items if item[0] != "skip"))
    with ThreadPoolExecutor(max_workers=CONCURRENCY) as pool:
        answers = dict(zip(wanted, pool.map(lookup, wanted)))
    rows = []
    for line, (kind, value) in zip(lines, items):
        if kind == "skip":  # the line as written, made safe for a spreadsheet
            rows.append({"line": line, "input": text(line), "type": "", "status": value})
        else:  # the handle or ID it was read as
            rows.append({"line": line, "input": value, "type": kind, **answers[(kind, value)]})
    return rows


if __name__ == "__main__":
    path = sys.argv[1] if len(sys.argv) > 1 else "accounts.txt"
    with open(path, encoding="utf-8") as f:
        rows = resolve(f.readlines())

    for r in rows:
        if r["status"] == "ok":
            print(f"{r['line'][:40]:<24} {str(r['user_id']):>12}  @{r['username']}")
        else:
            print(f"{r['line'][:40]:<24} {r['status']}")
    out = path.rsplit(".", 1)[0] + "_ids.csv"
    with open(out, "w", newline="", encoding="utf-8") as f:
        writer = csv.DictWriter(f, fieldnames=FIELDS, extrasaction="ignore")
        writer.writeheader()
        writer.writerows(rows)
    found = sum(r["status"] == "ok" for r in rows)
    print(f"{found} of {len(rows)} found, {credits['used']} credits; saved to {out}")
    if stopped["why"]:
        sys.exit(f"stopped early: {stopped['why']}")
  • parse() decides the direction. A profile link or an @handle is a username. A bare number is an ID. Anything else that looks like a handle is a username. Links to posts and reels, with or without a username in front, and lines that are not a handle at all are set aside without spending a credit.
  • Handles are sent with their @, so a handle made of digits is never mistaken for an ID.
  • One row per line, one lookup per account. A handle and its profile link in the same file are two rows and one charge.
  • Every answer is checked against the question. If the account that comes back is not the handle or ID that was asked for, the row says "answered as another account" and is not counted as found.
  • The output is safe to open. input holds the handle or ID the line was read as, and type says which. A line that was set aside is copied as written, and like a display name it gets a leading apostrophe if it starts with =, +, - or @, so a list from a stranger cannot put a formula in your spreadsheet.
  • Set CONCURRENCY to your plan's limit. Free allows 1 request in flight, Starter 10 and Startup 50 (the concurrency table lists every plan). Results come back in the order of the input.
  • A bad key or an empty balance stops the list once. The rows already answered are saved and the rest are marked "not checked", so you can run those lines again after topping up.

A test file with one of each kind:

@NASA
https://www.instagram.com/natgeo/
jimseven
971700
@433
1495338308
oculus
https://www.instagram.com/p/Dcgza21gR2n/
https://www.instagram.com/jimseven/reel/DdZOfSWiKJb/
zzzz_no_such_user_8812734
python ig_ids.py accounts.txt
@NASA                       528817151  @nasa
https://www.instagram.com/natgeo/       787132  @natgeo
jimseven                       971700  @jimseven
971700                         971700  @jimseven
@433                        253625977  @433
1495338308                 1495338308  @metavr
oculus                   not found
https://www.instagram.com/p/Dcgza21gR2n/ not a profile link
https://www.instagram.com/jimseven/reel/ not a profile link
zzzz_no_such_user_8812734 not found
6 of 10 found, 30 credits; saved to accounts_ids.csv

Six lookups were charged; the two missing handles and the two post links cost nothing. With CONCURRENCY at 5 the file took about two seconds. jimseven and 971700 are the same account reached from both sides, and the old oculus handle is gone while its ID answers as @metavr. The CSV adds the name, the private and verified flags and the follower count:

input,type,user_id,username,full_name,private,verified,followers,status
nasa,username,528817151,nasa,NASA,False,True,104234908,ok
natgeo,username,787132,natgeo,National Geographic,False,True,267426160,ok
jimseven,username,971700,jimseven,James Hoffmann,False,True,847725,ok
971700,id,971700,jimseven,James Hoffmann,False,True,847725,ok
433,username,253625977,433,433,False,True,79611652,ok
1495338308,id,1495338308,metavr,Meta VR,False,True,903235,ok
oculus,username,,,,,,,not found
https://www.instagram.com/p/Dcgza21gR2n/,,,,,,,,not a profile link
https://www.instagram.com/jimseven/reel/DdZOfSWiKJb/,,,,,,,,not a profile link
zzzz_no_such_user_8812734,username,,,,,,,not found

If follower counts over time are what you are after, the bulk follower count script keeps a dated history of the same lookup.

Find the accounts that renamed

A list of accounts goes stale one rename at a time. To refresh it, look every stored ID up and compare the handle. Save this next to ig_ids.py as ig_renames.py:

import csv
import sys

from ig_ids import resolve, stopped

path = sys.argv[1] if len(sys.argv) > 1 else "ig_accounts.csv"
with open(path, newline="", encoding="utf-8") as f:
    pairs = [((row.get("user_id") or "").strip(), (row.get("username") or "").strip())
             for row in csv.DictReader(f)]
stored = [(user_id, old) for user_id, old in pairs if user_id.isascii() and user_id.isdigit()]

rows = resolve(user_id for user_id, _ in stored)  # one row per stored ID, in the same order
same = 0
for (user_id, old), r in zip(stored, rows):
    if r["status"] == "not found":
        print(f"{user_id}  @{old} is gone or deactivated")
    elif r["status"] != "ok":
        print(f"{user_id}  @{old}: {r['status']}")
    elif r["username"] != old:
        print(f"{user_id}  @{old} is now @{r['username']}")
    else:
        same += 1
print(f"{same} of {len(stored)} unchanged")
if len(stored) < len(pairs):
    print(f"{len(pairs) - len(stored)} rows without a numeric user_id were left out")
if stopped["why"]:
    sys.exit(f"stopped early: {stopped['why']}")

It reads any CSV with user_id and username columns, such as ig_accounts.csv, and leaves out rows whose ID is not a number. We ran it on 12 ID and handle pairs printed in our guides and API reference in October, plus the 2019 pair from the archive:

python ig_renames.py october.csv
1495338308  @oculus is now @metavr
12 of 13 unchanged

One lookup per account, 5 credits each, so check the accounts you still care about, not every row you ever collected. An account that comes back "gone or deactivated" may only be switched off for a while: check it again another day before you delete the row. To follow who an account starts following over time, the following tracker does the same ID bookkeeping on whole lists.

What it costs

JobCallsCreditsOn Starter ($49.99 for 275,000)
1,000 accounts from a follower listabout 21 pagesabout 1052 cents
10,000 accounts from follower listsabout 205 pagesabout 1,02519 cents
1,000 handles converted to IDs1,000 lookups5,00091 cents
1,000 stored IDs checked for renames1,000 lookups5,00091 cents

Missing accounts are free, and so is every failed call. The 100 free credits on a new account cover 20 calls: 20 lookups, or about 980 accounts from a follower list.

Where to go from here

Common questions

How do I get an Instagram user ID from a username?

POST {"endpoint": "/user/by_username", "params": {"username": "nasa"}} to https://scrapingbot.io/api/v1/instagram with your key in the x-api-key header and read data.id: 528817151 for @nasa. It works for any account that exists, public or private, needs no Instagram login and costs 5 credits.

How do I find the username behind an Instagram user ID?

Call /user/by_id with the number as user_id and read data.username. You get the handle the account uses today, so this is also how you find out what a renamed account is called now.

Does an Instagram user ID change when the username changes?

No. The account with ID 1495338308 was @oculus in an archived copy of its profile from June 2019. On November 24, 2026 the same ID answered as @metavr, and a lookup of the old handle returned "Instagram user was not found." Store the ID next to every handle you collect.

Can I scrape Instagram usernames without looking each account up?

Yes, and it is about 50 times cheaper. Follower, following, comment and search responses already carry each account's id and username. Five pages of a follower list gave us 244 accounts for 25 credits, about 100 credits per 1,000 accounts, against 5,000 credits for 1,000 single lookups.

How do I look up an Instagram username made only of digits?

Send it with a leading @, or as its profile link. A bare number such as 433 is read as an account ID, and you get whichever account has that ID. @433 or https://www.instagram.com/433/ returns the account with that handle (ID 253625977).

Which number is the user ID: id, pk or fbid_v2?

id, and pk holds the same value. fbid_v2 is a different, longer number in the same response; the endpoints here do not take it, and /user/by_id answers 404 when you send one.

Start scraping in the next five minutes.

100 free credits, no credit card. One API key works for websites, TikTok, Instagram, Google, Amazon and ChatGPT.