How to get Instagram account information by username

Updated 2026-10-24

You have an Instagram handle — or a profile URL — and you need the account behind it: its numeric user ID, bio, follower count, verification status and links. This guide shows how to do that with one REST call, in cURL, Python and Node.js, and how to handle profile URLs, private accounts and accounts that do not exist.

What you need

Step 1 — Request the profile

The endpoint is GET /api/user/info. Its username_or_id parameter accepts either a username (nike) or a numeric user ID (13460080).

curl -H "X-Api-Key: sk_live_your_key_here" \
  "https://api.instagapi.com/api/user/info?username_or_id=nike"

Step 2 — Read the fields you need

The profile comes back under a data key:

Response
{
  "data": {
    "pk": "13460080",
    "username": "nike",
    "full_name": "Nike",
    "biography": "Just Do It. #nike",
    "is_private": false,
    "is_verified": true,
    "is_business": true,
    "category": "Sportswear",
    "media_count": 1284,
    "follower_count": 302145678,
    "following_count": 132,
    "external_url": "https://nike.com",
    "profile_pic_url_hd": "https://scontent.cdninstagram.com/..."
  }
}

Step 3 — Accept profile URLs as input

Users often paste a full link such as https://www.instagram.com/nike/?hl=en instead of a handle. The handle is the first path segment after instagram.com. Extract it before calling the API:

from urllib.parse import urlparse

def handle_from_input(value: str) -> str:
    value = value.strip()
    if "instagram.com" in value:
        if not value.startswith("http"):
            value = "https://" + value
        path = urlparse(value).path.strip("/")
        value = path.split("/")[0]
    return value.lstrip("@")

print(handle_from_input("https://www.instagram.com/nike/?hl=en"))  # nike
print(handle_from_input("@nike"))                                  # nike

Post and reel links (instagram.com/p/… or /reel/…) do not contain the handle. Fetch the post with the Posts API instead — its response includes the owner’s user object.

Step 4 — Handle errors

Enrich a list of usernames

To turn a CSV of handles into full profiles, loop over them with a small pause and write the fields you need. Keep the requests sequential and stay within your plan’s per-minute rate limit.

Python
import csv, time, requests

API_KEY = "sk_live_your_key_here"

with open("handles.txt") as f, open("profiles.csv", "w", newline="") as out:
    writer = csv.writer(out)
    writer.writerow(["username", "user_id", "followers", "following", "posts", "verified"])
    for line in f:
        handle = line.strip().lstrip("@")
        if not handle:
            continue
        res = requests.get(
            "https://api.instagapi.com/api/user/info",
            params={"username_or_id": handle},
            headers={"X-Api-Key": API_KEY},
            timeout=60,
        )
        if res.status_code != 200:
            print(handle, "->", res.status_code)
            continue
        d = res.json()["data"]
        writer.writerow([d["username"], d["pk"], d["follower_count"],
                         d["following_count"], d["media_count"], d["is_verified"]])
        time.sleep(2)

Related

Try it with a free API key

Create a free account, copy your key into the examples above, and make your first request in minutes. No credit card required.