Docs / Instagram API Errors and Error Codes
Instagram API Errors and Error Codes
Every response tells you what happened and how many credits it cost. Billing depends on actual scraper resource use, not the HTTP status; check credits_charged on each response.
Maintained by the InScrape API team · Last reviewed 2026-09-19
How errors are billed
A request is billed only when scraping actually uses an Instagram or H API resource. Validation, authentication, and failures before resource use are free; check credits_charged on every response.
The permanent ones: 400, 401, 404
None of these get better on their own, and retrying them just delays the moment you find out. A 400 means a required parameter is missing or the wrong type and the message names the parameter. A 401 means the key is unknown, mistyped or revoked; check the header name before you check the key, because a wrong header name produces the identical response. Confirmed private accounts return 200 with available profile details. Profile also returns 200 with data.profile=null when the account cannot be found. A 404 is reserved for missing API routes. Confirmed missing targets on list endpoints return HTTP 200 with empty arrays.
402 is not a failure, it is a balance
INSUFFICIENT_CREDITS means the balance is below this endpoint's cost. The request itself was fine and can be replayed unchanged once you top up. Because credits_remaining is on every response including this one, you can catch a 402 before it happens by watching that number in ordinary traffic and alerting when it dips below a day of expected usage.
The retryable ones: 500 and 504
SCRAPE_FAILED means the upstream fetch failed. UPSTREAM_TIMEOUT means it exceeded the 25 second budget the gateway allows a single scrape. Both are transient, both are free, and both are worth retrying with exponential backoff. What is not worth doing is retrying immediately in a tight loop: if the upstream is under pressure, a fast retry loop makes the situation worse for everyone including you. Three or four attempts with backoff starting around half a second is a sensible default; anything still failing past that is an upstream condition rather than a blip, and is better surfaced than retried harder.
A retry policy in twenty lines
Retry 500 and 504 with exponential backoff. For 429, respect Retry-After. Raise other errors immediately so invalid requests are not retried unchanged.
const RETRYABLE = new Set([429, 500, 504]);
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function call(path, params, attempts = 4) {
const url = new URL(path, "https://api.inscrape.dev");
for (const [k, v] of Object.entries(params)) url.searchParams.set(k, String(v));
for (let attempt = 0; attempt < attempts; attempt++) {
const res = await fetch(url, {
headers: { "x-api-key": process.env.INSCRAPE_KEY },
});
const body = await res.json();
if (res.ok) return body;
if (!RETRYABLE.has(res.status)) {
throw new Error(`${body.error.code}: ${body.error.message}`);
}
await sleep(res.status === 429 ? Number(res.headers.get("Retry-After") || 60) * 1000 : 500 * 2 ** attempt);
}
throw new Error("upstream still failing after retries");
}Handling lookup outcomes in a batch job
If you are processing a list of handles, private accounts are a normal outcome rather than an exception. A completed lookup returns 200 and is billed at the profile endpoint rate. Record the handle as unreadable and move on; do not retry it unless its privacy status may have changed.
const results = [];
const skipped = [];
for (const handle of handles) {
const body = await call("/v1/instagram/profile", { handle });
if (body.data?.profile === null) {
skipped.push({ handle, profile: body.data.profile });
continue;
}
results.push(body);
}429: team request limit
All API keys and Playground requests in one team share 300 requests per 60-second window and a maximum of 6 requests in progress. Exceeding either limit returns 429 RATE_LIMITED with Retry-After: 60. Wait before retrying. These rejections happen before scraping or billing and have credits_charged: 0.
Error reference
| Status | Code | Cause | Retry |
|---|---|---|---|
| 400 | INVALID_PARAMS | A required parameter is missing or the wrong type | No. Fix the request |
| 401 | INVALID_API_KEY | Key unknown, mistyped or revoked, or wrong header name | No. Check the header, then the key |
| 402 | INSUFFICIENT_CREDITS | Balance is below this endpoint's cost | No. Top up, then replay unchanged |
| 404 | ENDPOINT_NOT_FOUND | The API endpoint does not exist; no credits charged | No. Correct the API URL and endpoint path |
| 429 | RATE_LIMITED | Team minute quota or concurrent request limit reached | Wait for Retry-After before retrying |
| 500 | SCRAPE_FAILED | The upstream fetch failed | Yes, with exponential backoff |
| 504 | UPSTREAM_TIMEOUT | The scrape exceeded the 25 second budget | Yes, with exponential backoff |
FAQ
Am I charged for failed requests?
Requests are billed only when scraping actually uses an Instagram or H API resource, including private-account and not-found results discovered after resource use. Validation and authentication failures are free; service failures are free only if they happen before resource use.
The Instagram API is not working, what should I check first?
Read error.code rather than the status alone. A 401 is nearly always the header name or a revoked key, a 404 means a missing API route. Profile returns available profile details or data.profile=null on a 200 response. Only 500 and 504 indicate anything on our side.
Why can profile details be available while posts are inaccessible?
Your Instagram account may have permission to view content that this API does not provide. Private content is not returned; available public profile details may still be included.
Should I retry a 402?
Not immediately. The request will fail identically until the balance covers the endpoint cost. Top up first, then replay.
How many retries are sensible?
Three or four with exponential backoff on 500 and 504. For 429, wait for Retry-After before retrying. Retrying permanent errors without fixing their cause achieves nothing.

