ScrapeNinja Web Scraping API
ScrapeNinja is a plain REST API: you send a POST request with a JSON body, you get JSON back. Three endpoints cover all scraping jobs:
Base URL and authentication
Section titled “Base URL and authentication”ScrapeNinja is sold through two API marketplaces. Pick one, subscribe (there is a free plan), and send the key in a header:
| Marketplace | Base URL | Key header |
|---|---|---|
| APIRoad | https://scrapeninja.apiroad.net |
X-Apiroad-Key |
| RapidAPI | https://scrapeninja.p.rapidapi.com |
X-RapidAPI-Key |
curl https://scrapeninja.apiroad.net/scrape \ -H "Content-Type: application/json" \ -H "X-Apiroad-Key: YOUR_KEY" \ -d '{"url": "https://example.com"}'Which endpoint to use
Section titled “Which endpoint to use”/scrape |
/v2/scrape-js |
/scrape-js |
|
|---|---|---|---|
| Engine | Chrome network stack, no browser | Real Chrome | Real Chrome (same engine as v2) |
| JavaScript on the page | No | Yes | Yes |
| Speed | Fastest | Slower: a full browser loads the page | Slower |
| Wait for an element, screenshots | No | Yes | Yes |
| POST and PUT requests to the target | Yes | No | No |
| Browser steps (click, type, wait) | No | Yes | Yes |
Start with /scrape. Its requests carry the TLS and HTTP/2 fingerprint of a real Chrome, which already passes many protections. Switch to /v2/scrape-js when the data is rendered by JavaScript, or when the site runs a browser challenge.
Response format
Section titled “Response format”Every successful call returns the page and what ScrapeNinja knows about the request:
{ "info": { "statusCode": 200, "finalUrl": "https://example.com/", "headers": ["content-type: text/html; charset=UTF-8"] }, "body": "<!doctype html><html>...</html>", "extractor": { "result": { "title": "Example Domain" }, "executionTime": 4 }}info.statusCodeis the status of the target website, not of ScrapeNinja. A403here means the site refused the request even after the retries.bodyis the page HTML. SetoutputBody: falseif you only need the extractor result.extractorappears when you send anextractorfunction or anextractorPreset. See JS extractors.
Errors
Section titled “Errors”Invalid parameters return HTTP 422 on /scrape and /scrape-js:
{ "status": "fail", "message": "Invalid geo!", "errors": [{ "geo": "Invalid geo!" }] }/v2/scrape-js returns 400 for invalid parameters and a typed error otherwise:
{ "error": { "code": "SELECTOR_TIMEOUT", "message": "...", "request_id": "rv1vyw3jfrp" } }Codes: VALIDATION_ERROR, PROXY_ERROR, TEXT_FOUND_ERROR, STATUS_ERROR, REQUEST_ERROR, SELECTOR_TIMEOUT, INTERNAL_ERROR, FORBIDDEN. Quote the request_id when you contact support.
Retries and timeouts
Section titled “Retries and timeouts”A failed attempt is retried from another proxy: on network and proxy errors, on timeouts, and when the response matches textNotExpected or statusNotExpected. retryNum sets the number of retries after the first attempt, and timeout applies to each attempt, so the worst case is (retryNum + 1) × timeout seconds. Set your HTTP client timeout above that.