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

Turn an Instagram link into its type and ids

Instagram URL → type and ids (free). Complete code for GET /v1/instagram/resolve in six languages and both official SDKs, each tested against the documented response.

Short answer. One call turns any Instagram link into its type (user, post, story, highlight, hashtag, place or audio), its ids, and api: the route to call next. It is free because no data is fetched.

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

Why call it

  • Route links that users paste into your app to the right endpoint without writing your own URL parser.
  • Convert post shortcodes to numeric media ids in bulk imports.
  • Give an AI agent one step that turns any link into the next API call.

The request

GET https://api.handlehaul.com/v1/instagram/resolve with your key in the X-Api-Key header. Instagram URL → type and ids (free).

Parameters for Instagram URL → type and ids (free)
ParameterInDescription
url requiredquery

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-url-resolver.sh

# Instagram URL → type and ids (free). --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 -G "https://api.handlehaul.com/v1/instagram/resolve" \
  -H "X-Api-Key: $HANDLEHAUL_API_KEY" \
  --data-urlencode "url=https://www.instagram.com/p/C9xYzAbCdEf/"
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": {
    "type": "post",
    "shortcode": "C9xYzAbCdEf",
    "id": "3500000000000000123",
    "api": "/v1/instagram/posts/C9xYzAbCdEf"
  },
  "meta": {
    "request_id": "req_…",
    "credits_charged": 0
  }
}

Cost, cache and limits

  • Free. Resolving a link costs nothing; the call it points to is billed as usual.
  • Cache. Identical calls that arrive while an answer is cached are served from it. 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.
  • 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

  • A post shortcode is converted exactly to its numeric media id.
  • Pass the link URL-encoded in url (for example with curl -G --data-urlencode).
  • Free, with meta.credits_charged: 0, but it still needs an API key.

Next steps

Instagram url resolver API: questions

How do I convert an Instagram shortcode to a media id?
Call GET /v1/instagram/resolve?url= with the post link: id is the numeric media id. The conversion is exact and costs nothing.
Which Instagram links does the resolver understand?
Profiles, posts, reels, stories, highlights, hashtags, places and audio. type is one of user, post, story, highlight, hashtag, place or audio.

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.