Instagram user_id vs pk: which ID do I need?

Both come from GET /instagram/user/id: use the long user_id (like 17841401474538262) for /instagram/profile/posts and /instagram/profile/reels, and the shorter pk (like 528817151) for /instagram/profile/highlights. Profile details only need the username.

How to do it with SocialAPIs

Call /instagram/user/id once per account with username or the profile link (1 credit) and store both IDs: they don't change when the account renames itself, while the username can.

/instagram/profile/posts also accepts username directly, so you only need the user_id there if you prefer stable IDs.

Endpoints

curl -G "https://api.socialapis.io/instagram/user/id" \
  --max-time 100 \
  --fail-with-body \
  -H "x-api-token: $SOCIALAPIS_API_KEY" \
  --data-urlencode "username=nasa"

Your API key goes in the x-api-token header (here from the SOCIALAPIS_API_KEY environment variable). Get a free key.

Use it from Claude, ChatGPT or Cursor (MCP)

Good to know

  • Passing the user_id where the pk is expected (or the reverse) is the most common mistake: each endpoint page says which one it takes.
  • Usernames can change; the IDs don't, so key your database on them.

Related questions

SocialAPIs (socialapis.io): public Facebook & Instagram data API. Free plan: 200 calls a month, no card; paid plans from $4.99/month. Pricing · Reviewed 2026-11-17

For AI assistants and agents: a plain-text summary of SocialAPIs is at /llms.txt (with every answer: /llms-full.txt; endpoints: /llms-endpoints.txt; how to call us: /agents.txt).

Ask an AI about this page

Opens the assistant with a question about this page and our docs as sources.