1. Tutorials
  2. How to scrape Instagram post or reel details

How to scrape Instagram post or reel details

Get Instagram post or reel details as JSON with one request. It costs 1 credit.

Get an API key; the examples use api.socialscrape.dev.

Before you start

Step 1: Send the request

GET /v1/instagram/post. Pick your language; each one reads the key from SOCIALSCRAPE_API_KEY.

1curl -G "https://api.socialscrape.dev/v1/instagram/post" \2  -H "x-api-key: $SOCIALSCRAPE_API_KEY" \3  --data-urlencode 'url=https://www.instagram.com/reel/DfF3eqGSKKc/'

Step 2: Read the response

The result is in data. Here is what the object gives you, from a recorded sample.

1print(body["data"]["text"])2print(body["data"]["id"])3print(body["data"]["stats"]["views"])
SampleFields printed above
1{2  "text": "More power loading. 🔋\n\nToday, NASA astronaut Anil Menon and CSA (Canadian Space Agency) astronaut Joshua Kutryk conducted a spacewalk to install the 7th of ...",3  "id": "DfF3eqGSKKc",4  "stats": {5    "views": 903566  }7}

A field the platform does not give comes back as null. The full field list is on the endpoint page.

Step 3: Handle errors

Check ok, then branch on error.code and error.retryable, never on the message.

1body = res.json()2if not body["ok"]:3    err = body["error"]4    if err["retryable"]:5        ...  # wait a moment and send the same request again6    else:7        raise RuntimeError(f'{err["code"]}: {err["message"]}')
CodeHTTPRetryMeaning
invalid_params400noA parameter is missing, unknown or has the wrong type.
unsupported_url400noThe URL is not one this endpoint accepts (wrong platform or form).
not_found404noThe platform says this profile, post or item does not exist.

Other errors, such as unauthorized or rate_limited, are on the errors page.

With the SDK

The Python and TypeScript clients wrap all of this: typed errors, retries. Install them with pip install socialscrape-sdk or npm install socialscrape.

1from socialscrape import SocialScrape23client = SocialScrape()  # reads SOCIALSCRAPE_API_KEY45res = client.instagram.post(url="https://www.instagram.com/reel/DfF3eqGSKKc/")6print(res.data)7print(res.credits_charged, res.credits_remaining)

What it costs

1 credit. A failed request costs nothing. Add max_age_days to reuse a cached result for 0 credits. Results are kept 30 days.

Next

Questions

Which language should I use?

Any. It is plain HTTP and JSON, so every language with an HTTP client works. The tabs show the same request nine ways.