API reference
Everything the builder does goes through this API. Requests and responses are JSON. The base URL is https://scraper.tools.
Extract data from a page
Send a url and an extract description. The response has columns, rows, a per-page report in pages, and an outcome of complete, partial or failed.
To parse HTML you already have, send html (and optionally baseUrl) instead of url. No request is made to any site in that case.
This endpoint needs no key. It is limited to 40 page fetches per 5 minutes per address, or 200 with a key.
curl -X POST https://scraper.tools/api/v1/extract \
-H "Content-Type: application/json" \
-d '{
"url": "https://quotes.toscrape.com/",
"extract": {
"kind": "fields",
"row": { "type": "css", "value": "div.quote" },
"fields": [
{ "name": "text", "selector": "span.text" },
{ "name": "author", "selector": ".author" },
{ "name": "tags", "selector": "a.tag", "multiple": true },
{ "name": "about", "selector": ".//a[contains(@href, \"/author/\")]",
"selectorType": "xpath", "extract": "attr", "attr": "href" }
]
},
"pagination": {
"kind": "next-link",
"selector": { "type": "css", "value": "li.next > a" },
"maxPages": 3
}
}'The extract object
kind: "fields"
One output row per element matched by row. Leave row out to get a single record for the page. Each field has:
name: the column name.selector: evaluated inside each row. Empty means the row element itself.selectorType:css(default) orxpath. Start a relative XPath with.//.extract:text(default),htmlorattrwith anattrname. URL attributes such ashrefandsrcare returned as absolute URLs.multiple: return every match as a list instead of the first.
Other kinds
{ "kind": "table", "index": 0 }: the nth HTML table, with header detection and merged cells expanded.{ "kind": "links" }: every URL on the page. Optionaltypes(link,image,script,stylesheet,media,frame),sameHostOnlyandcontains.{ "kind": "structured" }: JSON-LD, Microdata and Open Graph. The full nested output is indata.
Pagination
next-link: aselectorfor the link to the next page andmaxPages. The link must stay on the same host.url-pattern: atemplatecontaining{page}, withfrom,toand optionalstep.
A run fetches at most 25 pages and returns at most 10,000 rows.
Authentication
Endpoints marked “Key” need an API key from Settings, sent as a bearer token. A key belongs to one workspace and can read and change everything in it.
Call the API from a server or a script. Browsers on other sites cannot call it, because cross-origin requests are not enabled.
curl -H "Authorization: Bearer st_your_key" \
"https://scraper.tools/api/v1/scrapers/scr_123/latest?format=csv" \
-o latest.csvEndpoints
| Request | Auth | What it does |
|---|---|---|
| POST/api/v1/extract | None | Fetch a URL (or take HTML you send) and extract data. Nothing is stored. |
| POST/api/v1/fetch | None | Fetch one page and return its HTML with a fetch report. |
| GET/api/v1/robots?url=…&agent=… | None | What robots.txt says about a URL for a user agent. |
| GET/api/v1/scrapers | Key | List saved scrapers with their last run. |
| POST/api/v1/scrapers | Key | Save a scraper: name, config and optional scheduleMinutes. |
| GET/api/v1/scrapers/{id} | Key | One scraper. |
| PATCH/api/v1/scrapers/{id} | Key | Change name, config or scheduleMinutes (null turns the schedule off). |
| DELETE/api/v1/scrapers/{id} | Key | Delete a scraper and its results. |
| POST/api/v1/scrapers/{id}/run | Key | Run now. Responds when the run has finished, with its rows. |
| GET/api/v1/scrapers/{id}/runs | Key | Run history without row data. |
| GET/api/v1/scrapers/{id}/latest | Key | Newest run that produced data. Add ?format=csv|xlsx|json to download. |
| GET/api/v1/runs/{id} | Key | One run with rows. Add ?format=csv|xlsx|json to download. |
| GET/api/v1/workspace | Key | Workspace details, usage and limits. |
Errors
Failures return a matching HTTP status and a body with a stable code and a readable message.
A multi-page run that fails part-way still answers 200: check outcome and error in the body, and use the rows that were collected.
{
"error": {
"code": "ROBOTS_DISALLOWED",
"message": "example.com's robots.txt does not allow fetching this page."
}
}| Code | Status | Meaning |
|---|---|---|
| INVALID_REQUEST | 400 | The body or a parameter is malformed. The message names the field. |
| INVALID_SELECTOR | 400 | A CSS selector or XPath expression could not be parsed. |
| INVALID_URL | 400 | Not an http(s) URL, or it contains credentials. |
| BLOCKED_HOST | 400 | The address is on a private or reserved network. |
| UNAUTHENTICATED | 401 | The endpoint needs an API key and none was sent. |
| INVALID_API_KEY | 401 | The key is wrong or was deleted. |
| ROBOTS_DISALLOWED | 403 | The site's robots.txt does not allow this URL. |
| ACCESS_RESTRICTED | 403 | The site answered 401, 403, 407 or 451, or showed a bot check. |
| UNSUPPORTED_CONTENT | 415 | The URL returned something other than HTML or text. |
| RATE_LIMITED | 429 | Too many API calls. See the Retry-After header. |
| RATE_LIMITED_BY_SITE | 429 | The target site answered 429. |
| HOST_BUSY | 429 | The target site is already being fetched at its polite rate. |
| ROBOTS_UNREACHABLE | 502 | robots.txt returned a server error or timed out, so the site is off limits for now. |
| HTTP_ERROR | 502 | The target site answered with another 4xx or 5xx status. |
| NETWORK | 502 | DNS, connection or TLS failure reaching the target site. |
| TIMEOUT | 504 | The target site did not respond in time. |