Tutorial · Instagram · cURL, Python, Node.js, PHP, Go, Ruby

Get an Instagram profile with the API

Profile by username or id. Complete code for GET /v1/instagram/users/{user} in six languages and both official SDKs, each tested against the documented response.

Short answer. One call returns a public profile: id, username, full_name, biography, external_url, category, verified and business flags, and counts for followers, following and posts. Three routes return the same object: by username, by numeric id, or {user} for either.

Facts checked 2 December 2026. Prices change: follow the links before you decide.

Why call it

  • Show follower, following and post counts on creator cards in an influencer-marketing or analytics tool.
  • Turn a handle into its numeric id once and store the id: it stays the same when the account renames itself.
  • Check is_verified, is_business and category before you add an account to a campaign list or report.

The request

GET https://api.handlehaul.com/v1/instagram/users/{user} with your key in the X-Api-Key header. Profile by username or id. Same as the two routes above; accepts either. 1 credit.

Parameters for Profile by username or id
ParameterInDescription
user requiredpathNumeric user id (skips the lookup credit) or Instagram username. All digits = an id; write "@12345" for an all-digit username. On list and user endpoints, a username we have to look up costs 1 extra credit (meta.lookup_credits).
byqueryOptional: says whether user is a username or an id, instead of guessing from the digits. One of: username, id.
freshquerytrue skips the cache (full price).

Code in 6 languages

Each sample is a complete program: it reads the key from HANDLEHAUL_API_KEY, waits and retries when the API answers 429 (using Retry-After), stops with the error code on anything else. The SDK versions do the retries for you.

instagram-profile.sh

# Profile by username or id. --retry waits out a 429 using its Retry-After header;
# --fail exits with code 22 on any other error (drop it to read the error JSON).
curl -sS --fail --retry 3 "https://api.handlehaul.com/v1/instagram/users/natgeo" \
  -H "X-Api-Key: $HANDLEHAUL_API_KEY"
Generated from the OpenAPI spec (2026-12-02); every sample was syntax-checked and run against a local mock serving the response below. Language guides: Python, Node.js, PHP, Go, Ruby, cURL.

Response

One object in data and meta with what the call cost. Example values, from the API docs. Lists are cut to two rows here.

200 · application/json
{
  "data": {
    "id": "787132",
    "username": "natgeo",
    "full_name": "National Geographic",
    "is_private": false,
    "is_verified": true,
    "profile_pic_url": "https://scontent.cdninstagram.com/…",
    "biography": "Experience the world through the eyes of our photographers.",
    "external_url": "https://www.nationalgeographic.com",
    "category": "Media/news company",
    "is_business": true,
    "profile_pic_url_hd": "https://scontent.cdninstagram.com/…",
    "counts": {
      "followers": 280000000,
      "following": 160,
      "posts": 30500
    }
  },
  "meta": {
    "request_id": "req_Zt0q…",
    "cached": true,
    "cache_age_seconds": 141,
    "credits_charged": 0.5,
    "credits_remaining": 26948.5
  }
}

Cost, cache and limits

  • 1 credit per call. At $1.40 to $0.80 per 1,000 calls. Cache hits, failed calls and 429 answers are free; meta.credits_charged says what each call cost.
  • No lookup credit. The profile call is the lookup. Store the id it returns for the other endpoints.
  • Cache. Answers are cached for 60 seconds, so polling once a minute or less often always gets a live answer. Add fresh=true to force a live call (billed).
  • Speed. Over your plan's requests-per-second limit the API answers 429 rate_limited with Retry-After; the samples wait that long and retry.
  • Private accounts. The profile still comes back, with is_private: true; their lists and posts answer 403 private_account (free).
  • Testing. A kd_test_ key returns sample data in this exact shape at no cost, so you can run the code before you spend anything.

Things to know

  • No lookup credit on the profile routes: the profile call is the lookup itself.
  • On the {user} route an all-digit value is read as an id. Write @12345 or add by=username for an all-digit username. The by-username route always reads a username.
  • id is a string because Instagram ids can be larger than 2^53. Store it as text, not as a number.
  • A private account still returns its public profile fields, with is_private: true. Its lists and posts are not available.

Same answer, other routes

These routes return the same object as GET /v1/instagram/users/{user}, so they share this page. Pick the one that matches the input you have.

Alias routes
RouteUse it whenSDK
GET /v1/instagram/users/by-username/{username}Profile by usernameinstagram.profileByUsername() (Node), instagram.profile_by_username() (Python)
GET /v1/instagram/users/by-id/{id}Profile by user idinstagram.profileById() (Node), instagram.profile_by_id() (Python)
curl -sS --fail --retry 3 "https://api.handlehaul.com/v1/instagram/users/by-username/natgeo" \
  -H "X-Api-Key: $HANDLEHAUL_API_KEY"

Next steps

Instagram profile API: questions

How do I get an Instagram follower count with an API?
Call the profile route with the username or id. The count is in data.counts.followers, next to following and posts.
Should I look up Instagram profiles by username or by id?
By id once you have it stored, because ids never change when an account renames itself. Use by-username when you only have a handle, and {user} when your input can be either.

Run it on real data

One key for Instagram and TikTok. $1.40 to $0.80 per 1,000 calls; failed calls and cache hits are free.

Want to test first? Sandbox keys are free and unlimited, with sample data in the live schema.