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
- An InstaGapi API key. The free plan is enough to follow this guide — create one from the dashboard.
- The username, numeric user ID or profile URL of a public Instagram account.
- No Instagram login, Facebook app or access token. Requests are authenticated with the X-Api-Key header only.
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:
{
"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/..."
}
}- pk is the numeric user ID. It never changes, even when the account changes its username, so store it as the account’s key.
- follower_count, following_count and media_count give the account’s size and activity.
- is_private, is_verified and is_business tell you what kind of account it is before you make further calls.
- public_email and contact_phone_number are filled only when the account chooses to show them publicly.
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")) # nikePost 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
- 404 — the username does not exist, or the account was renamed or removed. Do not retry.
- 429 — read detail.code in the body. RATE_LIMITED means slow down; QUOTA_EXCEEDED means your monthly plan quota is used up.
- 5xx — a temporary upstream problem. Retry after a short pause. Failed 5xx requests are not counted against your quota.
- Private accounts still return their public profile fields with is_private set to true.
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.
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.