Preview
The API is in early access. Ask for a key; the examples use
api.socialscrape.io.Set up
You need Node 18 or newer. It has fetch built in, so there is nothing to install.
export SOCIALSCRAPE_API_KEY=ss_live_...The script
Save as scrape.mjs and run node scrape.mjs. It calls GET /v1/instagram/post/transcript.
scrape.mjs
import { writeFileSync } from "node:fs";
const BASE = "https://api.socialscrape.io/v1/instagram/post/transcript";
const KEY = process.env.SOCIALSCRAPE_API_KEY;
const PARAMS = {
url: "https://www.instagram.com/reel/C8rKmYvsrck/",
};
// Follow a path through nested objects; undefined if any step is missing or null.
const pick = (obj, ...path) => path.reduce((o, k) => (o == null ? undefined : o[k]), obj);
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
// One request. Failures cost nothing; retry the ones the API marks retryable.
async function get(params) {
for (let attempt = 0; attempt < 3; attempt++) {
const url = new URL(BASE);
url.search = new URLSearchParams(params).toString();
const body = await (await fetch(url, { headers: { "x-api-key": KEY } })).json();
if (body.ok) return body;
const { code, message, retryable } = body.error;
if (!retryable || attempt === 2) throw new Error(`${code}: ${message}`);
await sleep(2 ** attempt * 1000);
}
}
const body = await get(PARAMS);
const data = body.data;
writeFileSync("out.json", JSON.stringify(data, null, 2));
console.log("text:", String(pick(data, "text")).slice(0, 200));
console.log(`saved out.json, credits left: ${body.credits_remaining}`);How it works
get()sends one request and retries the failures the API marksretryable. A failed request costs nothing.- The result is one object in
data. pick()reads nested fields and givesundefinedinstead of crashing when the platform returnednull.- The whole object goes to
out.jsonand a few fields are printed.
What you get back
These fields come from a recorded sample. The full field list is on the endpoint page.
Fields in the scriptSample
{
"text": "This is a canned transcript for the fixture."
}The short version
Without paging, saving or retries, the request is this.
const url = new URL("https://api.socialscrape.io/v1/instagram/post/transcript");
url.search = new URLSearchParams({
url: "https://www.instagram.com/reel/C8rKmYvsrck/",
}).toString();
const res = await fetch(url, {
headers: { "x-api-key": process.env.SOCIALSCRAPE_API_KEY },
});
const body = await res.json();
if (body.ok) {
console.log(body.data);
} else {
console.error(body.error.code, body.error.message);
}With the SDK
The JavaScript client does the retries for you. It is in preview and not published yet.
import { SocialScrape } from "socialscrape";
const client = new SocialScrape(); // reads SOCIALSCRAPE_API_KEY
const res = await client.instagram.postTranscript({ url: "https://www.instagram.com/reel/C8rKmYvsrck/" });
console.log(res.data);
console.log(res.credits_charged, res.credits_remaining);What it costs
1 credit for captions; AI transcription 1 up to 2 minutes, then 1 per started minute. A failed request costs nothing. Add max_age_days to reuse a cached result for 0 credits. Results are kept 30 days.
Next
- The same request in nine languages.
- Instagram reel transcript API: sample response and every parameter.
- The Python version.
- All Instagram endpoints.