@hunt-labs/bytekit-mcp 0.3.26 → 0.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,26 @@ today, see [README.md](./README.md), which remains the authoritative usage guide
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [0.3.28] - 2026-12-01
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Refreshed the bundled documentation snapshot after scrape, fetch, schema, screenshots and sitemap
|
|
18
|
+
gained the `403 proxy_refused` answer (#6180), given when our proxy provider does not allow
|
|
19
|
+
requests to the host. This refresh itself changes no tool, schema or transport.
|
|
20
|
+
- Refreshed the bundled documentation snapshot and the generated scrape contract after
|
|
21
|
+
`/v1/scrape` gained the `422 content_too_large` answer (#6197), given when `markdown` is
|
|
22
|
+
requested and the page is too large to convert. The generated `ScrapeEnvelopeErrorCode` union
|
|
23
|
+
gains `content_too_large`; no tool, schema or transport changes.
|
|
24
|
+
|
|
25
|
+
## [0.3.27] - 2026-12-01
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Refreshed the bundled documentation snapshot after the `/v1/schema` 200 response gained `id` and
|
|
30
|
+
`credits_used` (#6088): the schema extraction guide now lists both in its Response table and says
|
|
31
|
+
where the credit charge is reported. This refresh itself changes no tool, schema or transport.
|
|
32
|
+
|
|
13
33
|
## [0.3.26] - 2026-11-27
|
|
14
34
|
|
|
15
35
|
### Changed
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"api/fetch/getfetch": {
|
|
73
73
|
"title": "Fetch a URL (GET)",
|
|
74
74
|
"section": "API Reference",
|
|
75
|
-
"body": "# Fetch a URL (GET)\n\nDirect HTTP fetch. Metadata is returned in X-Fetch-* headers. What the body holds\ndepends on `X-Fetch-Fast-Path`. When it is `true`, a successful response returns the\nupstream response bytes verbatim. When it is `false` the request fell back to a browser\nrender, and the body is the rendered page rather than the bytes the target sent;\n`X-Fetch-Content-Length` is then the compressed size of that page. Non-2xx upstream\nresponses use the `upstream_error` JSON envelope with the upstream HTTP status.\n\n**GET** `/v1/fetch`\n\n## Parameters\n\n- `url` (query, string, required)\n- `country` (query, string) — Two-letter country code. Either case is accepted; the value is upper-cased.\n- `timeout_ms` (query, integer) — Time budget for the fetch, in milliseconds, from 1000 to 90000 (default 60000). The fetch is bounded by the lower of this value and the server's fast-path limit, a deployment setting that is not part of this contract, so a value above that limit has no effect while a lower value tightens the budget. The response does not report which limit applied.\n- `cache_ttl` (query) — How long a freshly fetched URL may be served from cache. `0` skips the cache read; cache-eligible fresh results are still written with the default 7-day TTL so later non-zero-TTL callers can HIT. Safety-classified WAF husks remain live-only and are not written. Accepts `Nh` (hours, up to 168h), `Nd` (days, up to 7d), or the integer `0`. Examples: `0`, `48h`, `2d`. Invalid values receive a 422 validation_error with an actionable message.\n- `custom` (query, string) — A JSON-encoded object, URL-encoded in the query string. It is echoed back base64-encoded in\nthe `X-Fetch-Custom` response header so callers can correlate the response to caller-side\nstate. Capped at 4096 UTF-8 bytes after JSON serialization, and not part of the cache key.\nA value that is not valid JSON answers `422 validation_error` (\"custom must be a\nJSON-encoded object\"); valid JSON that is not an object is also rejected with `422`.\n\n## Responses\n\n### 200 — Content from upstream.\n\n### 400 — Invalid URL (`invalid_url`) or oversized request.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error (e.g. slow-path-only field), or a fetch that failed for a\ntarget-side reason.\n\nThree distinct conditions answer `422`. Read `error.code` to tell them apart.\n\n- **`validation_error`** — the request itself was rejected.\n- **`blocked`** or **`upstream_error`** — the fetch ran and the target could not\n be read. `blocked` means the target's bot protection refused every attempt;\n `upstream_error` (message `Failed to fetch URL.`) is any other exhausted-retries\n failure, such as a host that does not resolve. This is a result about the URL,\n not an outage of this API, so it is a `4xx` rather than `502` or `503`. No\n upstream HTTP status was received, so `error.http_status` reports `422`,\n mirroring what was served — unlike the relayed `upstream_error` under `503`\n below, whose `error.http_status` is the target's own. A target `502` or `504`\n ends here too whenever it does not meet the condition for `503` below. The\n request transfers no billable bytes and is charged nothing (#4669).\n- **`timeout`** — the fetch ran out of its time limit before the page could be\n fetched (message `The request hit its time limit before the page could be\n fetched.`). It takes precedence over `blocked` and `upstream_error`, and like\n them it is charged nothing and reports `error.http_status` `422`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — Two distinct conditions answer `503`, and they disagree about what the body's\n`error.http_status` reports. Read `error.code` to tell them apart.\n\n- **`upstream_error`** — the target returned HTTP `502` or `504`, relayed here as\n `503`. This happens only when the escalation ladder ended on that answer, or when a\n cached copy of it is served. A `502` or `504` is not terminal, so ByteKit first\n retries it through its proxy tiers and the browser fallback; if the ladder ends any\n other way, or a bot-protection vendor was seen on the way, the request answers\n `422` (`upstream_error` or `blocked`) instead.\n Cloudflare fronts this API and replaces a clean origin 502 or 504 with its\n own generic `text/plain` error page, discarding the envelope before it reaches\n you, while a 503 is passed through unchanged. The body's `error.http_status`\n still reports the **true upstream status**, `502` or `504` — not `503` — and is\n the only surviving record of what the target answered, so the body rather than\n the HTTP status is authoritative here (#3355, #4891). Every other non-2xx\n upstream response is relayed at its own HTTP status with the same\n `upstream_error` envelope, so any other 4xx/5xx the target returns surfaces as an\n Error envelope rather than a raw body (#1462).\n- **`internal_error`** (message `Fetch service unavailable.`) — no fetch service\n endpoint could be resolved on this deployment, a fault of this API and not of the\n target. There is no upstream status to preserve: the `503` is this API's own\n choice of wire status, so the body's `error.http_status` reports `503`, mirroring\n what was served (#3373). A fetch that ran and failed for a target-side reason\n answers `422` instead (#4669).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
|
|
75
|
+
"body": "# Fetch a URL (GET)\n\nDirect HTTP fetch. Metadata is returned in X-Fetch-* headers. What the body holds\ndepends on `X-Fetch-Fast-Path`. When it is `true`, a successful response returns the\nupstream response bytes verbatim. When it is `false` the request fell back to a browser\nrender, and the body is the rendered page rather than the bytes the target sent;\n`X-Fetch-Content-Length` is then the compressed size of that page. Non-2xx upstream\nresponses use the `upstream_error` JSON envelope with the upstream HTTP status.\n\n**GET** `/v1/fetch`\n\n## Parameters\n\n- `url` (query, string, required)\n- `country` (query, string) — Two-letter country code. Either case is accepted; the value is upper-cased.\n- `timeout_ms` (query, integer) — Time budget for the fetch, in milliseconds, from 1000 to 90000 (default 60000). The fetch is bounded by the lower of this value and the server's fast-path limit, a deployment setting that is not part of this contract, so a value above that limit has no effect while a lower value tightens the budget. The response does not report which limit applied.\n- `cache_ttl` (query) — How long a freshly fetched URL may be served from cache. `0` skips the cache read; cache-eligible fresh results are still written with the default 7-day TTL so later non-zero-TTL callers can HIT. Safety-classified WAF husks remain live-only and are not written. Accepts `Nh` (hours, up to 168h), `Nd` (days, up to 7d), or the integer `0`. Examples: `0`, `48h`, `2d`. Invalid values receive a 422 validation_error with an actionable message.\n- `custom` (query, string) — A JSON-encoded object, URL-encoded in the query string. It is echoed back base64-encoded in\nthe `X-Fetch-Custom` response header so callers can correlate the response to caller-side\nstate. Capped at 4096 UTF-8 bytes after JSON serialization, and not part of the cache key.\nA value that is not valid JSON answers `422 validation_error` (\"custom must be a\nJSON-encoded object\"); valid JSON that is not an object is also rejected with `422`.\n\n## Responses\n\n### 200 — Content from upstream.\n\n### 400 — Invalid URL (`invalid_url`) or oversized request.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — The target cannot be requested. Nothing is fetched and nothing is billed.\nThe unified `Error` envelope carries one of three codes:\n\n- `host_forbidden` — a blocked domain, any government host (`.gov`, or a `.gov.` country domain such as `.gov.uk`), or a blocked port.\n `details` is `{ host }`.\n- `path_forbidden` — an authentication-style path such as a login page.\n `details` is `{ path }`.\n- `proxy_refused` — our proxy provider does not allow requests to this host, so the request is refused without being attempted.\n `details` is `{ host }`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error (e.g. slow-path-only field), or a fetch that failed for a\ntarget-side reason.\n\nThree distinct conditions answer `422`. Read `error.code` to tell them apart.\n\n- **`validation_error`** — the request itself was rejected.\n- **`blocked`** or **`upstream_error`** — the fetch ran and the target could not\n be read. `blocked` means the target's bot protection refused every attempt;\n `upstream_error` (message `Failed to fetch URL.`) is any other exhausted-retries\n failure, such as a host that does not resolve. This is a result about the URL,\n not an outage of this API, so it is a `4xx` rather than `502` or `503`. No\n upstream HTTP status was received, so `error.http_status` reports `422`,\n mirroring what was served — unlike the relayed `upstream_error` under `503`\n below, whose `error.http_status` is the target's own. A target `502` or `504`\n ends here too whenever it does not meet the condition for `503` below. The\n request transfers no billable bytes and is charged nothing (#4669).\n- **`timeout`** — the fetch ran out of its time limit before the page could be\n fetched (message `The request hit its time limit before the page could be\n fetched.`). It takes precedence over `blocked` and `upstream_error`, and like\n them it is charged nothing and reports `error.http_status` `422`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — Two distinct conditions answer `503`, and they disagree about what the body's\n`error.http_status` reports. Read `error.code` to tell them apart.\n\n- **`upstream_error`** — the target returned HTTP `502` or `504`, relayed here as\n `503`. This happens only when the escalation ladder ended on that answer, or when a\n cached copy of it is served. A `502` or `504` is not terminal, so ByteKit first\n retries it through its proxy tiers and the browser fallback; if the ladder ends any\n other way, or a bot-protection vendor was seen on the way, the request answers\n `422` (`upstream_error` or `blocked`) instead.\n Cloudflare fronts this API and replaces a clean origin 502 or 504 with its\n own generic `text/plain` error page, discarding the envelope before it reaches\n you, while a 503 is passed through unchanged. The body's `error.http_status`\n still reports the **true upstream status**, `502` or `504` — not `503` — and is\n the only surviving record of what the target answered, so the body rather than\n the HTTP status is authoritative here (#3355, #4891). Every other non-2xx\n upstream response is relayed at its own HTTP status with the same\n `upstream_error` envelope, so any other 4xx/5xx the target returns surfaces as an\n Error envelope rather than a raw body (#1462).\n- **`internal_error`** (message `Fetch service unavailable.`) — no fetch service\n endpoint could be resolved on this deployment, a fault of this API and not of the\n target. There is no upstream status to preserve: the `503` is this API's own\n choice of wire status, so the body's `error.http_status` reports `503`, mirroring\n what was served (#3373). A fetch that ran and failed for a target-side reason\n answers `422` instead (#4669).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
|
|
76
76
|
},
|
|
77
77
|
"api/fetch/postfetch": {
|
|
78
78
|
"title": "Fetch a URL (POST)",
|
|
79
79
|
"section": "API Reference",
|
|
80
|
-
"body": "# Fetch a URL (POST)\n\nSame as GET /v1/fetch but with a JSON request body. The response is the same, including\nthe `X-Fetch-Fast-Path` rule for what the body holds: the upstream bytes verbatim when\nit is `true`, the rendered page when it is `false`.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/fetch`\n\n## Request Body\n\n- `url` (required)\n- `country`\n- `timeout_ms`\n- `cache_ttl`\n- `custom`\n\n## Responses\n\n### 200 — Content from upstream.\n\n### 400 — Invalid URL (`invalid_url`) or oversized request body.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error (e.g. malformed JSON, unsupported fetch format, or slow-path-only\nfield), or a fetch that failed for a target-side reason.\n\nThree distinct conditions answer `422`. Read `error.code` to tell them apart.\n\n- **`validation_error`** — the request itself was rejected.\n- **`blocked`** or **`upstream_error`** — the fetch ran and the target could not\n be read. `blocked` means the target's bot protection refused every attempt;\n `upstream_error` (message `Failed to fetch URL.`) is any other exhausted-retries\n failure, such as a host that does not resolve. This is a result about the URL,\n not an outage of this API, so it is a `4xx` rather than `502` or `503`. No\n upstream HTTP status was received, so `error.http_status` reports `422`,\n mirroring what was served — unlike the relayed `upstream_error` under `503`\n below, whose `error.http_status` is the target's own. A target `502` or `504`\n ends here too whenever it does not meet the condition for `503` below. The\n request transfers no billable bytes and is charged nothing (#4669).\n- **`timeout`** — the fetch ran out of its time limit before the page could be\n fetched (message `The request hit its time limit before the page could be\n fetched.`). It takes precedence over `blocked` and `upstream_error`, and like\n them it is charged nothing and reports `error.http_status` `422`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — Two distinct conditions answer `503`, and they disagree about what the body's\n`error.http_status` reports. Read `error.code` to tell them apart.\n\n- **`upstream_error`** — the target returned HTTP `502` or `504`, relayed here as\n `503`. This happens only when the escalation ladder ended on that answer, or when a\n cached copy of it is served. A `502` or `504` is not terminal, so ByteKit first\n retries it through its proxy tiers and the browser fallback; if the ladder ends any\n other way, or a bot-protection vendor was seen on the way, the request answers\n `422` (`upstream_error` or `blocked`) instead.\n Cloudflare fronts this API and replaces a clean origin 502 or 504 with its\n own generic `text/plain` error page, discarding the envelope before it reaches\n you, while a 503 is passed through unchanged. The body's `error.http_status`\n still reports the **true upstream status**, `502` or `504` — not `503` — and is\n the only surviving record of what the target answered, so the body rather than\n the HTTP status is authoritative here (#3355, #4891). Every other non-2xx\n upstream response is relayed at its own HTTP status with the same\n `upstream_error` envelope, so any other 4xx/5xx the target returns surfaces as an\n Error envelope rather than a raw body (#1462).\n- **`internal_error`** (message `Fetch service unavailable.`) — no fetch service\n endpoint could be resolved on this deployment, a fault of this API and not of the\n target. There is no upstream status to preserve: the `503` is this API's own\n choice of wire status, so the body's `error.http_status` reports `503`, mirroring\n what was served (#3373). A fetch that ran and failed for a target-side reason\n answers `422` instead (#4669).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
|
|
80
|
+
"body": "# Fetch a URL (POST)\n\nSame as GET /v1/fetch but with a JSON request body. The response is the same, including\nthe `X-Fetch-Fast-Path` rule for what the body holds: the upstream bytes verbatim when\nit is `true`, the rendered page when it is `false`.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/fetch`\n\n## Request Body\n\n- `url` (required)\n- `country`\n- `timeout_ms`\n- `cache_ttl`\n- `custom`\n\n## Responses\n\n### 200 — Content from upstream.\n\n### 400 — Invalid URL (`invalid_url`) or oversized request body.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — The target cannot be requested. Nothing is fetched and nothing is billed.\nThe unified `Error` envelope carries one of three codes:\n\n- `host_forbidden` — a blocked domain, any government host (`.gov`, or a `.gov.` country domain such as `.gov.uk`), or a blocked port.\n `details` is `{ host }`.\n- `path_forbidden` — an authentication-style path such as a login page.\n `details` is `{ path }`.\n- `proxy_refused` — our proxy provider does not allow requests to this host, so the request is refused without being attempted.\n `details` is `{ host }`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error (e.g. malformed JSON, unsupported fetch format, or slow-path-only\nfield), or a fetch that failed for a target-side reason.\n\nThree distinct conditions answer `422`. Read `error.code` to tell them apart.\n\n- **`validation_error`** — the request itself was rejected.\n- **`blocked`** or **`upstream_error`** — the fetch ran and the target could not\n be read. `blocked` means the target's bot protection refused every attempt;\n `upstream_error` (message `Failed to fetch URL.`) is any other exhausted-retries\n failure, such as a host that does not resolve. This is a result about the URL,\n not an outage of this API, so it is a `4xx` rather than `502` or `503`. No\n upstream HTTP status was received, so `error.http_status` reports `422`,\n mirroring what was served — unlike the relayed `upstream_error` under `503`\n below, whose `error.http_status` is the target's own. A target `502` or `504`\n ends here too whenever it does not meet the condition for `503` below. The\n request transfers no billable bytes and is charged nothing (#4669).\n- **`timeout`** — the fetch ran out of its time limit before the page could be\n fetched (message `The request hit its time limit before the page could be\n fetched.`). It takes precedence over `blocked` and `upstream_error`, and like\n them it is charged nothing and reports `error.http_status` `422`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — Two distinct conditions answer `503`, and they disagree about what the body's\n`error.http_status` reports. Read `error.code` to tell them apart.\n\n- **`upstream_error`** — the target returned HTTP `502` or `504`, relayed here as\n `503`. This happens only when the escalation ladder ended on that answer, or when a\n cached copy of it is served. A `502` or `504` is not terminal, so ByteKit first\n retries it through its proxy tiers and the browser fallback; if the ladder ends any\n other way, or a bot-protection vendor was seen on the way, the request answers\n `422` (`upstream_error` or `blocked`) instead.\n Cloudflare fronts this API and replaces a clean origin 502 or 504 with its\n own generic `text/plain` error page, discarding the envelope before it reaches\n you, while a 503 is passed through unchanged. The body's `error.http_status`\n still reports the **true upstream status**, `502` or `504` — not `503` — and is\n the only surviving record of what the target answered, so the body rather than\n the HTTP status is authoritative here (#3355, #4891). Every other non-2xx\n upstream response is relayed at its own HTTP status with the same\n `upstream_error` envelope, so any other 4xx/5xx the target returns surfaces as an\n Error envelope rather than a raw body (#1462).\n- **`internal_error`** (message `Fetch service unavailable.`) — no fetch service\n endpoint could be resolved on this deployment, a fault of this API and not of the\n target. There is no upstream status to preserve: the `503` is this API's own\n choice of wire status, so the body's `error.http_status` reports `503`, mirroring\n what was served (#3373). A fetch that ran and failed for a target-side reason\n answers `422` instead (#4669).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
|
|
81
81
|
},
|
|
82
82
|
"api/health": {
|
|
83
83
|
"title": "Health",
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
"api/schema/createschemaextraction": {
|
|
143
143
|
"title": "Schema-driven structured extraction",
|
|
144
144
|
"section": "API Reference",
|
|
145
|
-
"body": "# Schema-driven structured extraction\n\nFetches `url` and extracts structured JSON conforming to the supplied\nJSON Schema (draft 2020-12) using an LLM. Fast-path only — slow-path\nrendering options (`wait_until=networkidle`, `delay_ms`,\n`wait_for_selector`) cause a `400 unsupported_option`.\n\nDual-axis billing: a fixed per-request credit charge **plus** the\nunderlying page's bandwidth, billed at its upstream wire bytes with no\nendpoint factor (a 100 KiB estimate is pre-charged, then reconciled). The\nbandwidth is still billed when the scrape succeeds but extraction later\nfails; both axes are refunded only when the scrape itself never runs.\n\n**POST** `/v1/schema`\n\n## Request Body\n\n- `url` (required)\n- `schema` (required)\n- `prompt`\n- `model`\n- `wait_for_selector`\n- `wait_until`\n- `delay_ms`\n- `country`\n- `language`\n\n## Responses\n\n### 200 — Extraction completed (success or graceful extract failure).\n- `data`\n- `model`\n- `validated`\n- `metrics`\n- `metrics.scrape_ms`\n- `metrics.llm_total_ms`\n- `metrics.input_tokens`\n- `metrics.output_tokens`\n- `metrics.retries`\n- `metrics.total_ms`\n- `scrape`\n- `scrape.url`\n- `scrape.status_code`\n- `scrape.content_length`\n- `scrape.truncated`\n- `warnings`\n\n### 400 — Invalid URL (`invalid_url`), unsupported model (`unsupported_model`), or unsupported slow-path option (`unsupported_option`).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error (`validation_error`), non-normalizable schema (`schema_incompatible`),\nor the fetched page's HTML could not be converted for extraction — over the size cap or\npast the conversion deadline (`content_too_large`). On `content_too_large` the page's\nbandwidth is billed and the credits are refunded.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Per-account rate limit (`rate_limited`) or upstream provider rate limit (`provider_rate_limited`); a `Retry-After` header may be present.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 500 — Internal error (`internal_error`): the request could not be recorded, or its\nbandwidth charge could not be reserved. The credits held for it are refunded.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — Read `error.code` to tell the conditions apart: underlying scrape failed or the\nextraction service was unreachable (`scrape_failed`), upstream provider error\n(`provider_error`), extraction provider unconfigured (`provider_unavailable`), or\nupstream provider timed out (`provider_timeout`). None of these answers `502` or\n`504`: Cloudflare fronts this API and replaces an origin 502 or 504 with its own\n`text/plain` page, discarding the error envelope, while a 503 passes through\nunchanged (#4891).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
|
|
145
|
+
"body": "# Schema-driven structured extraction\n\nFetches `url` and extracts structured JSON conforming to the supplied\nJSON Schema (draft 2020-12) using an LLM. Fast-path only — slow-path\nrendering options (`wait_until=networkidle`, `delay_ms`,\n`wait_for_selector`) cause a `400 unsupported_option`.\n\nDual-axis billing: a fixed per-request credit charge **plus** the\nunderlying page's bandwidth, billed at its upstream wire bytes with no\nendpoint factor (a 100 KiB estimate is pre-charged, then reconciled). The\nbandwidth is still billed when the scrape succeeds but extraction later\nfails; both axes are refunded only when the scrape itself never runs.\n\n**POST** `/v1/schema`\n\n## Request Body\n\n- `url` (required)\n- `schema` (required)\n- `prompt`\n- `model`\n- `wait_for_selector`\n- `wait_until`\n- `delay_ms`\n- `country`\n- `language`\n\n## Responses\n\n### 200 — Extraction completed (success or graceful extract failure).\n- `id`\n- `data`\n- `model`\n- `validated`\n- `metrics`\n- `metrics.scrape_ms`\n- `metrics.llm_total_ms`\n- `metrics.input_tokens`\n- `metrics.output_tokens`\n- `metrics.retries`\n- `metrics.total_ms`\n- `scrape`\n- `scrape.url`\n- `scrape.status_code`\n- `scrape.content_length`\n- `scrape.truncated`\n- `warnings`\n- `credits_used`\n\n### 400 — Invalid URL (`invalid_url`), unsupported model (`unsupported_model`), or unsupported slow-path option (`unsupported_option`).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — The target cannot be requested. Nothing is fetched and nothing is billed.\nThe unified `Error` envelope carries one of three codes:\n\n- `host_forbidden` — a blocked domain, any government host (`.gov`, or a `.gov.` country domain such as `.gov.uk`), or a blocked port.\n `details` is `{ host }`.\n- `path_forbidden` — an authentication-style path such as a login page.\n `details` is `{ path }`.\n- `proxy_refused` — our proxy provider does not allow requests to this host, so the request is refused without being attempted.\n `details` is `{ host }`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error (`validation_error`), non-normalizable schema (`schema_incompatible`),\nor the fetched page's HTML could not be converted for extraction — over the size cap or\npast the conversion deadline (`content_too_large`). On `content_too_large` the page's\nbandwidth is billed and the credits are refunded.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Per-account rate limit (`rate_limited`) or upstream provider rate limit (`provider_rate_limited`); a `Retry-After` header may be present.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 500 — Internal error (`internal_error`): the request could not be recorded, or its\nbandwidth charge could not be reserved. The credits held for it are refunded.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — Read `error.code` to tell the conditions apart: underlying scrape failed or the\nextraction service was unreachable (`scrape_failed`), upstream provider error\n(`provider_error`), extraction provider unconfigured (`provider_unavailable`), or\nupstream provider timed out (`provider_timeout`). None of these answers `502` or\n`504`: Cloudflare fronts this API and replaces an origin 502 or 504 with its own\n`text/plain` page, discarding the error envelope, while a 503 passes through\nunchanged (#4891).\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
|
|
146
146
|
},
|
|
147
147
|
"api/scrape": {
|
|
148
148
|
"title": "Scrape",
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
"api/scrape/createscrape": {
|
|
168
168
|
"title": "Scrape a URL",
|
|
169
169
|
"section": "API Reference",
|
|
170
|
-
"body": "# Scrape a URL\n\nFetches and processes a URL, returning content in one or more formats wrapped in a ScrapeEnvelope.\n\n**The response shape is decided by your request, not by how we route it.** In precedence order:\n\n1. `async: true` in the body, or `?async=true` in the query string (either one is enough; `false` in one never cancels `true` in the other) → **202** with a `ScrapeQueuedEnvelope` receipt, returned immediately. Poll `GET /v1/scrape/{id}` for the result.\n2. Otherwise, a request that needs a full page render — today that is any of `delay_ms > 0`, `solve_challenge: true`, or `outline` in `formats` — is **held open** until the render reaches a terminal state, then returns **200** with the content envelope (`success` or `failed`). If the render is still running when the hold window expires (28 seconds by default), the request returns the **202** receipt instead and the job continues in the background. A `solve_challenge` render can outlast the hold window, so expect the 202 receipt from such a request.\n3. Otherwise the request is served by the fast HTTP path and returns **200** with the content envelope, typically in under a second.\n\n**A failed fetch is a result, not a transport error.** An unreachable host, a refused connection, or a target whose bot protection defeats every proxy tier all come back on the same **200** as a `failed` envelope — never a 5xx. Narrow on the envelope's `status` before reading the body. A failure the fast path decides inline is recorded as a failed job, so its envelope normally carries that job's `id` and `GET /v1/scrape/{id}` returns the same envelope; if recording the failed job itself fails, the envelope still arrives on the same 200 with `id` set to `null` and there is nothing to poll. A failure a held render reaches carries that render's real `id`. Either way the request transfers no billable bytes and is charged nothing.\n\n**A target that rate-limits us is not ByteKit rate-limiting you.** The `failed` envelope's `error.code` is `target_rate_limited` when the target rate-limits the request. On the fast path that means our proxy attempts end on an HTTP 429 and no bot protection is identified on any attempt, even if the browser fallback then fails or reaches only an unidentified block page; the inline failure carries `error.retry_after_seconds` when the target sent a usable `Retry-After`. On a held render the browser's own answer decides: it observes a 429 on the page itself, or it fails outright after the proxy attempts ended on an HTTP 429. A bot-protection verdict on an earlier fetch attempt does not keep a held render `blocked` when the browser then observes the 429. A held render never carries `error.retry_after_seconds`. Retrying a `target_rate_limited` failure later is likely to work. A held render whose browser reaches an unidentified 403 or 503 page after a proxy 429 is `blocked`. A 429 that bot protection sends as a block stays `blocked` when it is the answer that decides the code: the fast path's proxy attempts, or the browser render on a held render. Your own per-key limit is a separate case: it answers HTTP 429 `rate_limited` with a `Retry-After` header (see the `429` response).\n\nSo a 202 means one of exactly two things: you asked for one with `async: true` or `?async=true`, or the hold window expired. `wait_for_selector` and `wait_until` are `ScreenshotRequest` options, not `ScrapeRequest` options — sending either to this endpoint returns `422 validation_error`, so neither can produce a 202 here.\n\n**POST** `/v1/scrape`\n\n## Parameters\n\n- `async` (query, boolean) — Query-string spelling of the body `async` field. `true` returns the 202 receipt immediately; any other value is ignored. Either spelling turns async on, and `false` in one never cancels `true` in the other.\n\n## Request Body\n\n- `url` (required)\n- `formats`\n- `formats.type`\n- `formats.schema`\n- `formats.model`\n- `formats.prompt`\n- `country`\n- `delay_ms`\n- `timeout_ms`\n- `async`\n- `webhook_url`\n- `events`\n- `markdown_mode`\n- `markdown_query`\n- `markdown_links`\n- `markdown_images`\n- `with_links_summary`\n- `with_images_summary`\n- `markdown_compact`\n- `markdown_filter_images`\n- `markdown_include_media`\n- `markdown_include_warnings`\n- `markdown_include_stats`\n- `token_budget`\n- `token_encoding`\n- `mobile`\n- `solve_challenge`\n- `remove_base64_images`\n- `include_tags`\n- `exclude_tags`\n- `cache_ttl`\n- `custom`\n- `clean_markdown`\n\n## Responses\n\n### 200 — Scrape reached a terminal state and the body is that terminal envelope: `success` carrying content, or `failed` carrying the error envelope. Returned by the fast HTTP path in one round trip, and by a browser-path request without `async: true` or `?async=true` once its render reaches a terminal state inside the hold window. A held render that ends in failure answers 200 with the same `failed` envelope `GET /v1/scrape/{id}` returns — narrow on `status` before reading the body. A definitive upstream outcome is a result, not a transport error: an unreachable host, a refused connection, or a target whose bot protection defeats every proxy tier all answer 200 with the `failed` envelope, never a 5xx. An inline failure is recorded as a failed job, so its envelope normally carries that job's `id` and polling it returns the same envelope; `id` is `null` only when recording the failed job itself failed. `error.http_status` is present only when a real upstream HTTP status is known.\n- `schema_version`\n- `status`\n- `id`\n- `url`\n- `final_url`\n- `content_type`\n- `content_length`\n- `status_code`\n- `retrieved_at`\n- `formats`\n- `formats.raw`\n- `formats.markdown`\n- `formats.links`\n- `formats.links.url`\n- `formats.links.text`\n- `formats.links.isInternal`\n- `formats.links.rel`\n- `formats.images`\n- `formats.images.url`\n- `formats.images.alt`\n- `formats.images.width`\n- `formats.images.height`\n- `formats.images.format`\n- `formats.images.score`\n- `formats.json`\n- `formats.json.data`\n- `formats.json.validated`\n- `formats.json.model`\n- `formats.outline`\n- `metadata`\n- `metadata.title`\n- `metadata.description`\n- `metadata.language`\n- `metadata.canonicalUrl`\n- `metadata.ogTitle`\n- `metadata.ogDescription`\n- `metadata.ogImage`\n- `metadata.ogUrl`\n- `metadata.ogSiteName`\n- `metadata.robots`\n- `metadata.byline`\n- `metadata.publishedAt`\n- `tables`\n- `tables.kind`\n- `tables.gfm`\n- `tables.rows`\n- `tables.cols`\n- `warnings`\n- `warnings.code`\n- `warnings.message`\n- `warnings.element`\n- `stats`\n- `stats.chars`\n- `stats.tokens`\n- `stats.blocks`\n- `markdown_tokens`\n- `markdown_tokens.kept`\n- `markdown_tokens.total`\n- `markdown_tokens.truncated`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `custom`\n- `cache`\n- `cache_age_s`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.retry_after_seconds`\n- `error.failed_at`\n\n### 202 — Scrape accepted for background processing; the body is a receipt, not content. Returned when `async: true` or `?async=true` was requested, or when a browser-path request's hold window expired before the render finished. Poll `GET /v1/scrape/{id}` for the result.\n- `schema_version`\n- `status`\n- `id`\n- `url`\n- `status_url`\n- `queued_at`\n- `events`\n\n### 400 — Bad request. When the `url` field fails strict validation the error\ncode is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 415 — `unsupported_content_type`, in two cases:\n- The `url` path ends in `.pdf`: the path, lowercased, ends in `.pdf`; the query string and\n fragment are not looked at. It is refused before anything is drawn. A PDF served from\n another path, or reached through a redirect, is not caught by this check.\n- The page was fetched (or served from cache) and its content type cannot produce the\n requested formats. The charge is refunded.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error. A `json` format entry whose `schema` the extractor cannot take is\nrefused with `schema_incompatible`, before anything is drawn.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 500 — Internal server error.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — The request carried a `json` format entry and JSON extraction is unavailable on this\ndeployment (`provider_unavailable`). It is refused before anything is drawn. A\nterminal upstream failure is never a `503`: it is a `200` result, described above.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
|
|
170
|
+
"body": "# Scrape a URL\n\nFetches and processes a URL, returning content in one or more formats wrapped in a ScrapeEnvelope.\n\n**The response shape is decided by your request, not by how we route it.** In precedence order:\n\n1. `async: true` in the body, or `?async=true` in the query string (either one is enough; `false` in one never cancels `true` in the other) → **202** with a `ScrapeQueuedEnvelope` receipt, returned immediately. Poll `GET /v1/scrape/{id}` for the result.\n2. Otherwise, a request that needs a full page render — today that is any of `delay_ms > 0`, `solve_challenge: true`, or `outline` in `formats` — is **held open** until the render reaches a terminal state, then returns **200** with the content envelope (`success` or `failed`). If the render is still running when the hold window expires (28 seconds by default), the request returns the **202** receipt instead and the job continues in the background. A `solve_challenge` render can outlast the hold window, so expect the 202 receipt from such a request.\n3. Otherwise the request is served by the fast HTTP path and returns **200** with the content envelope, typically in under a second.\n\n**A failed fetch is a result, not a transport error.** An unreachable host, a refused connection, or a target whose bot protection defeats every proxy tier all come back on the same **200** as a `failed` envelope — never a 5xx. Narrow on the envelope's `status` before reading the body. A failure the fast path decides inline is recorded as a failed job, so its envelope normally carries that job's `id` and `GET /v1/scrape/{id}` returns the same envelope; if recording the failed job itself fails, the envelope still arrives on the same 200 with `id` set to `null` and there is nothing to poll. A failure a held render reaches carries that render's real `id`. Either way the request transfers no billable bytes and is charged nothing.\n\n**A target that rate-limits us is not ByteKit rate-limiting you.** The `failed` envelope's `error.code` is `target_rate_limited` when the target rate-limits the request. On the fast path that means our proxy attempts end on an HTTP 429 and no bot protection is identified on any attempt, even if the browser fallback then fails or reaches only an unidentified block page; the inline failure carries `error.retry_after_seconds` when the target sent a usable `Retry-After`. On a held render the browser's own answer decides: it observes a 429 on the page itself, or it fails outright after the proxy attempts ended on an HTTP 429. A bot-protection verdict on an earlier fetch attempt does not keep a held render `blocked` when the browser then observes the 429. A held render never carries `error.retry_after_seconds`. Retrying a `target_rate_limited` failure later is likely to work. A held render whose browser reaches an unidentified 403 or 503 page after a proxy 429 is `blocked`. A 429 that bot protection sends as a block stays `blocked` when it is the answer that decides the code: the fast path's proxy attempts, or the browser render on a held render. Your own per-key limit is a separate case: it answers HTTP 429 `rate_limited` with a `Retry-After` header (see the `429` response).\n\nSo a 202 means one of exactly two things: you asked for one with `async: true` or `?async=true`, or the hold window expired. `wait_for_selector` and `wait_until` are `ScreenshotRequest` options, not `ScrapeRequest` options — sending either to this endpoint returns `422 validation_error`, so neither can produce a 202 here.\n\n**POST** `/v1/scrape`\n\n## Parameters\n\n- `async` (query, boolean) — Query-string spelling of the body `async` field. `true` returns the 202 receipt immediately; any other value is ignored. Either spelling turns async on, and `false` in one never cancels `true` in the other.\n\n## Request Body\n\n- `url` (required)\n- `formats`\n- `formats.type`\n- `formats.schema`\n- `formats.model`\n- `formats.prompt`\n- `country`\n- `delay_ms`\n- `timeout_ms`\n- `async`\n- `webhook_url`\n- `events`\n- `markdown_mode`\n- `markdown_query`\n- `markdown_links`\n- `markdown_images`\n- `with_links_summary`\n- `with_images_summary`\n- `markdown_compact`\n- `markdown_filter_images`\n- `markdown_include_media`\n- `markdown_include_warnings`\n- `markdown_include_stats`\n- `token_budget`\n- `token_encoding`\n- `mobile`\n- `solve_challenge`\n- `remove_base64_images`\n- `include_tags`\n- `exclude_tags`\n- `cache_ttl`\n- `custom`\n- `clean_markdown`\n\n## Responses\n\n### 200 — Scrape reached a terminal state and the body is that terminal envelope: `success` carrying content, or `failed` carrying the error envelope. Returned by the fast HTTP path in one round trip, and by a browser-path request without `async: true` or `?async=true` once its render reaches a terminal state inside the hold window. A held render that ends in failure answers 200 with the same `failed` envelope `GET /v1/scrape/{id}` returns — narrow on `status` before reading the body. A definitive upstream outcome is a result, not a transport error: an unreachable host, a refused connection, or a target whose bot protection defeats every proxy tier all answer 200 with the `failed` envelope, never a 5xx. An inline failure is recorded as a failed job, so its envelope normally carries that job's `id` and polling it returns the same envelope; `id` is `null` only when recording the failed job itself failed. `error.http_status` is present only when a real upstream HTTP status is known.\n- `schema_version`\n- `status`\n- `id`\n- `url`\n- `final_url`\n- `content_type`\n- `content_length`\n- `status_code`\n- `retrieved_at`\n- `formats`\n- `formats.raw`\n- `formats.markdown`\n- `formats.links`\n- `formats.links.url`\n- `formats.links.text`\n- `formats.links.isInternal`\n- `formats.links.rel`\n- `formats.images`\n- `formats.images.url`\n- `formats.images.alt`\n- `formats.images.width`\n- `formats.images.height`\n- `formats.images.format`\n- `formats.images.score`\n- `formats.json`\n- `formats.json.data`\n- `formats.json.validated`\n- `formats.json.model`\n- `formats.outline`\n- `metadata`\n- `metadata.title`\n- `metadata.description`\n- `metadata.language`\n- `metadata.canonicalUrl`\n- `metadata.ogTitle`\n- `metadata.ogDescription`\n- `metadata.ogImage`\n- `metadata.ogUrl`\n- `metadata.ogSiteName`\n- `metadata.robots`\n- `metadata.byline`\n- `metadata.publishedAt`\n- `tables`\n- `tables.kind`\n- `tables.gfm`\n- `tables.rows`\n- `tables.cols`\n- `warnings`\n- `warnings.code`\n- `warnings.message`\n- `warnings.element`\n- `stats`\n- `stats.chars`\n- `stats.tokens`\n- `stats.blocks`\n- `markdown_tokens`\n- `markdown_tokens.kept`\n- `markdown_tokens.total`\n- `markdown_tokens.truncated`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `custom`\n- `cache`\n- `cache_age_s`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.retry_after_seconds`\n- `error.failed_at`\n\n### 202 — Scrape accepted for background processing; the body is a receipt, not content. Returned when `async: true` or `?async=true` was requested, or when a browser-path request's hold window expired before the render finished. Poll `GET /v1/scrape/{id}` for the result.\n- `schema_version`\n- `status`\n- `id`\n- `url`\n- `status_url`\n- `queued_at`\n- `events`\n\n### 400 — Bad request. When the `url` field fails strict validation the error\ncode is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — `proxy_refused`: our proxy provider does not allow requests to this host, so the request\nis refused without being attempted. Nothing is fetched and nothing is billed.\n`details` is `{ host }`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 415 — `unsupported_content_type`, in two cases:\n- The `url` path ends in `.pdf`: the path, lowercased, ends in `.pdf`; the query string and\n fragment are not looked at. It is refused before anything is drawn. A PDF served from\n another path, or reached through a redirect, is not caught by this check.\n- The page was fetched (or served from cache) and its content type cannot produce the\n requested formats. The charge is refunded.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — One of two codes:\n- `schema_incompatible`: a `json` format entry whose `schema` the extractor cannot take\n is refused before anything is drawn.\n- `content_too_large`: the request asks for `markdown` and the page is too large to\n convert (over the size cap or past the conversion deadline). The request is not\n charged, and the other requested formats are not returned. An `async` request fails\n with the same code on its error envelope.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 500 — Internal server error.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 503 — The request carried a `json` format entry and JSON extraction is unavailable on this\ndeployment (`provider_unavailable`). It is refused before anything is drawn. A\nterminal upstream failure is never a `503`: it is a `200` result, described above.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
|
|
171
171
|
},
|
|
172
172
|
"api/scrape/getscrape": {
|
|
173
173
|
"title": "Get scrape result",
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
"api/screenshots/createscreenshot": {
|
|
183
183
|
"title": "Capture a screenshot",
|
|
184
184
|
"section": "API Reference",
|
|
185
|
-
"body": "# Capture a screenshot\n\nSync by default (holds up to 28s). Pass `async: true` in the body or `?async=true` in the\nquery string to return 202 immediately; either one is enough, and `false` in one never\ncancels `true` in the other.\nPoll via GET /v1/screenshots/{id}.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/screenshots`\n\n## Parameters\n\n- `async` (query, boolean) — Query-string spelling of the body `async` field. `true` returns the 202 immediately; any other value is ignored.\n\n## Request Body\n\n- `url` (required)\n- `device`\n- `viewport`\n- `viewport.width`\n- `viewport.height`\n- `async`\n- `full_page`\n- `format`\n- `quality`\n- `block_ads`\n- `block_cookie_banners`\n- `wait_until`\n- `wait_for_selector`\n- `delay_ms`\n- `scroll`\n- `clip`\n- `clip.x`\n- `clip.y`\n- `clip.width`\n- `clip.height`\n- `dark_mode`\n- `device_scale_factor`\n- `include_html`\n- `country`\n- `language`\n- `metadata`\n\n## Responses\n\n### 200 — Screenshot completed (sync mode).\n- `id`\n- `status`\n- `url`\n- `image_url`\n- `page_title`\n- `image_width`\n- `image_height`\n- `file_size_bytes`\n- `credits_charged`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `error_code`\n- `error_message`\n- `created_at`\n- `completed_at`\n- `expires_at`\n- `poll_url`\n\n### 202 — Screenshot accepted (async mode or sync timeout).\n- `id`\n- `status`\n- `url`\n- `image_url`\n- `page_title`\n- `image_width`\n- `image_height`\n- `file_size_bytes`\n- `credits_charged`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `error_code`\n- `error_message`\n- `created_at`\n- `completed_at`\n- `expires_at`\n- `poll_url`\n\n### 400 — Bad request. When the `url` field fails strict validation the error\ncode is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — The target
|
|
185
|
+
"body": "# Capture a screenshot\n\nSync by default (holds up to 28s). Pass `async: true` in the body or `?async=true` in the\nquery string to return 202 immediately; either one is enough, and `false` in one never\ncancels `true` in the other.\nPoll via GET /v1/screenshots/{id}.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/screenshots`\n\n## Parameters\n\n- `async` (query, boolean) — Query-string spelling of the body `async` field. `true` returns the 202 immediately; any other value is ignored.\n\n## Request Body\n\n- `url` (required)\n- `device`\n- `viewport`\n- `viewport.width`\n- `viewport.height`\n- `async`\n- `full_page`\n- `format`\n- `quality`\n- `block_ads`\n- `block_cookie_banners`\n- `wait_until`\n- `wait_for_selector`\n- `delay_ms`\n- `scroll`\n- `clip`\n- `clip.x`\n- `clip.y`\n- `clip.width`\n- `clip.height`\n- `dark_mode`\n- `device_scale_factor`\n- `include_html`\n- `country`\n- `language`\n- `metadata`\n\n## Responses\n\n### 200 — Screenshot completed (sync mode).\n- `id`\n- `status`\n- `url`\n- `image_url`\n- `page_title`\n- `image_width`\n- `image_height`\n- `file_size_bytes`\n- `credits_charged`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `error_code`\n- `error_message`\n- `created_at`\n- `completed_at`\n- `expires_at`\n- `poll_url`\n\n### 202 — Screenshot accepted (async mode or sync timeout).\n- `id`\n- `status`\n- `url`\n- `image_url`\n- `page_title`\n- `image_width`\n- `image_height`\n- `file_size_bytes`\n- `credits_charged`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `error_code`\n- `error_message`\n- `created_at`\n- `completed_at`\n- `expires_at`\n- `poll_url`\n\n### 400 — Bad request. When the `url` field fails strict validation the error\ncode is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — The target cannot be requested. Nothing is captured and nothing is billed.\nThe unified `Error` envelope carries one of three codes:\n\n- `host_forbidden` — a blocked domain, any government host (`.gov`, or a `.gov.` country domain such as `.gov.uk`), or a blocked port.\n `details` is `{ host }`.\n- `path_forbidden` — an authentication-style path such as a login page.\n `details` is `{ path }`.\n- `proxy_refused` — our proxy provider does not allow requests to this host, so the request is refused without being attempted.\n `details` is `{ host }`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error, or a screenshot that failed inside the sync hold.\nThe two carry DIFFERENT bodies (issue #2679):\n\n- A request-validation failure returns the unified `Error` envelope\n with code `validation_error`. A `viewport` outside the `Viewport`\n bounds (width 360 to 2544, height 1 to 1297) is one.\n- A capture that reached a terminal `failed` state inside the sync\n hold returns the full `ScreenshotResponse` resource, whose\n `error_code`/`error_message` carry the real failure (`blocked`,\n `timeout`, …). This is the canonical shape for that case: the\n resource body is what carries the `ss_` handle, `poll_url` and\n `expires_at` a client needs to redeem the failed capture, none of\n which fit the `Error` envelope.\n\nDiscriminate on the shape of the top-level `error` key. The envelope\nform carries `error` as an OBJECT (`{ code, message, http_status,\nfailed_at }`); the resource form has no `error` key at all, and\ncarries the flat `error_code`/`error_message` pair plus `id` instead.\n\nDo NOT discriminate on `status`. Both forms carry\n`\"status\": \"failed\"` on this response — `Error.status` is a required\nproperty with `enum: [failed]` — so it separates nothing here.\n\n`X-Screenshot-ID` accompanies the resource form only: a\nrequest-validation failure is raised before a screenshot row exists,\nso no screenshot headers travel with it.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n- `id`\n- `url`\n- `image_url`\n- `page_title`\n- `image_width`\n- `image_height`\n- `file_size_bytes`\n- `credits_charged`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `error_code`\n- `error_message`\n- `created_at`\n- `completed_at`\n- `expires_at`\n- `poll_url`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
|
|
186
186
|
},
|
|
187
187
|
"api/screenshots/getscreenshot": {
|
|
188
188
|
"title": "Get screenshot status",
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
"api/sitemap/createsitemap": {
|
|
208
208
|
"title": "Discover URLs on a domain",
|
|
209
209
|
"section": "API Reference",
|
|
210
|
-
"body": "# Discover URLs on a domain\n\nCrawls a domain to build a sitemap. Returns cached results if available\nwithin cache_ttl. Results delivered via webhook and downloadable from results_url.\nWebhook deliveries include `X-ByteKit-Event: sitemap.completed` or\n`X-ByteKit-Event: sitemap.failed` so receivers can dispatch on the\nheader without parsing the body shape.\n\nThe webhook body is `{ event, data }`. For a job the worker ran, `data` is not a\n`SitemapResponse`:\n\n- `sitemap.completed` `data` carries `id`, `url`, `strategy`, `status`,\n `total_urls`, `sources`, `total_bytes`, `results_url`, `warnings`,\n `metadata`, `compact` and `billing`.\n- `sitemap.failed` `data` carries `id`, `url`, `strategy`, `status`,\n `error_code`, `error_message`, `warnings` and `metadata`.\n\nIn both, `url` is the host as `scheme://host`, and `warnings` is the\nworker's own warnings or `null`. When the request is answered from a cached job\n(`cache: hit`), the `sitemap.completed` `data` is instead the full job object, the\nsame fields as a `SitemapResponse`.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/sitemap`\n\n## Request Body\n\n- `url` (required)\n- `strategy`\n- `max_depth`\n- `max_urls`\n- `process`\n- `process.action`\n- `process.options`\n- `webhook_url`\n- `webhook_secret`\n- `cache_ttl`\n- `compact`\n- `metadata`\n\n## Responses\n\n### 202 — Sitemap job accepted (or cached result returned).\n- `id`\n- `url`\n- `strategy`\n- `max_depth`\n- `max_urls`\n- `status`\n- `total_urls`\n- `sources`\n- `total_bytes`\n- `results_url`\n- `cache`\n- `cache_age_s`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `warnings`\n- `error_code`\n- `error_message`\n- `compact`\n- `process`\n- `metadata`\n- `created_at`\n- `completed_at`\n- `expires_at`\n\n### 400 — Bad request. When the `url` field fails strict validation the error\ncode is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — The target
|
|
210
|
+
"body": "# Discover URLs on a domain\n\nCrawls a domain to build a sitemap. Returns cached results if available\nwithin cache_ttl. Results delivered via webhook and downloadable from results_url.\nWebhook deliveries include `X-ByteKit-Event: sitemap.completed` or\n`X-ByteKit-Event: sitemap.failed` so receivers can dispatch on the\nheader without parsing the body shape.\n\nThe webhook body is `{ event, data }`. For a job the worker ran, `data` is not a\n`SitemapResponse`:\n\n- `sitemap.completed` `data` carries `id`, `url`, `strategy`, `status`,\n `total_urls`, `sources`, `total_bytes`, `results_url`, `warnings`,\n `metadata`, `compact` and `billing`.\n- `sitemap.failed` `data` carries `id`, `url`, `strategy`, `status`,\n `error_code`, `error_message`, `warnings` and `metadata`.\n\nIn both, `url` is the host as `scheme://host`, and `warnings` is the\nworker's own warnings or `null`. When the request is answered from a cached job\n(`cache: hit`), the `sitemap.completed` `data` is instead the full job object, the\nsame fields as a `SitemapResponse`.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**POST** `/v1/sitemap`\n\n## Request Body\n\n- `url` (required)\n- `strategy`\n- `max_depth`\n- `max_urls`\n- `process`\n- `process.action`\n- `process.options`\n- `webhook_url`\n- `webhook_secret`\n- `cache_ttl`\n- `compact`\n- `metadata`\n\n## Responses\n\n### 202 — Sitemap job accepted (or cached result returned).\n- `id`\n- `url`\n- `strategy`\n- `max_depth`\n- `max_urls`\n- `status`\n- `total_urls`\n- `sources`\n- `total_bytes`\n- `results_url`\n- `cache`\n- `cache_age_s`\n- `billing`\n- `billing.raw_bytes`\n- `billing.factors`\n- `billing.factors.name`\n- `billing.factors.value`\n- `billing.factors.reason`\n- `billing.multiplier`\n- `billing.billed_bytes`\n- `warnings`\n- `error_code`\n- `error_message`\n- `compact`\n- `process`\n- `metadata`\n- `created_at`\n- `completed_at`\n- `expires_at`\n\n### 400 — Bad request. When the `url` field fails strict validation the error\ncode is `invalid_url` and the `details` object contains:\n- `field` — the request field that failed (e.g. `\"url\"`)\n- `url` — the rejected value\n- `reason` — one of: `scheme_missing`, `scheme_unsupported`,\n `scheme_separator_typo`, `host_empty`, `host_invalid`,\n `host_blocked_private`, `host_blocked_loopback`, `host_too_long`,\n `host_unicode_not_punycode`, `userinfo_present`, `url_too_long`,\n `control_chars`, `not_a_url`\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 401 — Unauthorized. The request carried no valid credential, and no work was\nperformed. The unified `Error` envelope carries one of the codes below\nin `error.code`; match on the code, never on the prose.\n\n- `invalid_api_key` — a bearer API key was presented and rejected:\n unknown, revoked, expired or malformed. The bearer-only operations\n (`/v1/webhook-deliveries*` among them) also return it when no\n `Authorization` header is sent. `GET /v1/account` is the exception\n to \"malformed\": it returns `invalid_api_key` only for a key that\n starts `sk_test_` or `sk_live_` and is unknown, revoked or expired.\n- `unauthorized` — the `Authorization` header is absent or malformed on\n an operation that also accepts a dashboard session (the dual-auth and\n billing operations). `GET /v1/account` also returns it, for no\n `Authorization` header and for any bearer value that does not start\n `sk_test_` or `sk_live_` (that value is checked as a dashboard\n session token).\n\nNot retryable as-is: supply a valid API key first.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 402 — Payment required. The account cannot fund this request, and no work was\nperformed. The unified `Error` envelope carries one of the billing codes\nbelow in `error.code`; match on the code, never on the prose.\n\n- `quota_exceeded` — the enforced balance for this request's meter\n cannot fund it. Capture endpoints (`/v1/scrape`, `/v1/fetch`,\n `/v1/screenshots`, `/v1/sitemap` and the bulk siblings) meter\n bandwidth: they reject when the balance cannot fund the request's\n byte reservation, and `error.details.required_bytes` and\n `error.details.available_bytes` report the bytes the request reserves\n and the bytes available. `/v1/search` meters credits.\n- `spending_cap_reached` — the request would push overage spend past the\n account's configured cap. Only reachable on a custom overage-enabled\n plan; standard plans stop at `quota_exceeded`.\n- `billing_entitlement_impaired` — the paid subscription is in a payment\n impairment (e.g. `past_due`). `error.message` names the reason.\n- `billing_entitlement_expired` — the paid subscription entitlement\n period has ended, or its dunning grace period has run out.\n\nNot retryable as-is: settle the balance, raise the cap, or restore the\nsubscription first. This response carries no `X-Quota-*` headers — they\ntravel with the 2xx responses of the operations that emit them.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 403 — The target cannot be requested. Nothing is queued and nothing is billed.\nThe unified `Error` envelope carries one of three codes:\n\n- `host_forbidden` — a blocked domain, any government host (`.gov`, or a `.gov.` country domain such as `.gov.uk`), or a blocked port.\n `details` is `{ host }`.\n- `path_forbidden` — an authentication-style path such as a login page.\n `details` is `{ path }`.\n- `proxy_refused` — our proxy provider does not allow requests to this host, so the request is refused without being attempted.\n `details` is `{ host }`.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 422 — Validation error.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`\n\n### 429 — Rate limit (`rate_limited`) or concurrency limit (`concurrency_limit`) exceeded. Carries a `Retry-After` header — seconds derived from the same clock as `X-RateLimit-Reset` for the rate-limit variant, a fixed small back-off for the concurrency variant.\n- `status`\n- `error`\n- `error.code`\n- `error.message`\n- `error.http_status`\n- `error.failed_at`\n- `error.details`"
|
|
211
211
|
},
|
|
212
212
|
"api/sitemap/getsitemap": {
|
|
213
213
|
"title": "Get sitemap job status",
|
|
@@ -357,12 +357,12 @@
|
|
|
357
357
|
"guides/errors": {
|
|
358
358
|
"title": "Errors",
|
|
359
359
|
"section": "Guides",
|
|
360
|
-
"body": "# Errors\n\nByteKit error response shape, common error codes, and retry guidance.\n\nAll errors from the ByteKit API follow a consistent envelope shape so you can handle them\nprogrammatically.\n\n## Error response shape\n\nEvery `4xx`/`5xx` response across the API uses one unified envelope. `status` is\nalways the literal string `\"failed\"`, so you can branch on the response body alone.\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"rate_limited\",\n \"message\": \"Rate limit exceeded. Allowed 5 requests per second.\",\n \"http_status\": 429,\n \"failed_at\": \"2026-08-27T12:17:46.234Z\"\n }\n}\n```\n\nThe number in a `rate_limited` message is your own plan's per-second limit — the same value the `X-RateLimit-Limit` response header carries.\n\n| Field | Description |\n| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |\n| `status` | Always `\"failed\"` on an error response — the top-level discriminator |\n| `error.code` | Machine-readable string identifier |\n| `error.message` | Human-readable explanation |\n| `error.http_status` | Mirrors the HTTP response status (useful for logged or replayed bodies) |\n| `error.failed_at` | ISO-8601 UTC timestamp of when the error was produced |\n| `error.details` | Optional object with additional context (e.g. which field failed validation). Absent — not `{}` — when the error carries no context |\n\n## Common error codes\n\n| HTTP status | Code | Meaning |\n| ----------- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `400` | `invalid_url` | A supplied URL (including `webhook_url`) is malformed or uses an unsupported scheme |\n| `400` | `validation_error` | Field errors on `/v1/search`, `POST /v1/billing/checkout` and `PUT`/`DELETE /v1/billing/payment-methods/{id}`, plus rejections that run before schema validation on any endpoint: a removed field such as `cookies` or `headers` on a capture endpoint, or a `/v1/fetch` or `/v1/fetch/bulk` request asking for an option only `/v1/scrape` or `/v1/bulk` serves |\n| `401` | `unauthorized` | Missing or malformed `Authorization` header |\n| `401` | `invalid_api_key` | API key is present but not valid |\n| `402` | `quota_exceeded` | The [balance](https://bytekit.com/docs/billing#terms) cannot fund this request. Capture endpoints reject when it cannot fund the request's byte reservation, and `error.details.required_bytes` and `error.details.available_bytes` give the bytes the request reserves and the bytes available; `/v1/search` meters credits and rejects when its credit balance is used up |\n| `402` | `spending_cap_reached` | A credit-metered request would push overage spend past the account's cap. Only reachable on a custom plan with an overage agreement — standard plans have no automatic overage and stop at `quota_exceeded` |\n| `402` | `billing_entitlement_impaired` | The paid subscription is in a payment impairment (e.g. `past_due`); `error.message` names the reason |\n| `402` | `billing_entitlement_expired` | The paid subscription's entitlement period has ended, or its dunning grace period has run out |\n| `403` | `forbidden` | Key is valid but lacks permission for this action |\n| `422` | `validation_error` | Malformed JSON, or a request field failed validation, everywhere the `400` row above does not name |\n| `422` | `blocked`, `upstream_error`, `timeout` | `/v1/fetch` only: the fetch ran and the target could not be read (bot protection refused every attempt, or another exhausted-retries failure such as an unresolvable host), or it ran out of its time limit before the page could be fetched (`timeout`). This is a result about the URL, not an outage of this API, and it is charged nothing. `upstream_error` can also come from a relay fault on our side, so the code alone does not prove the target is at fault. The `X-Fetch-ID` response header, when present, names the failed request's row in Logs |\n| `429` | `rate_limited` | Too many requests per second; back off and retry |\n| `429` | `concurrency_limit` | Too many simultaneous in-flight requests; back off and retry |\n| `500` | `internal_error` | A ByteKit-side failure (for example, failing to enqueue a job or to persist a result, or an unexpected server error), not a problem with the target site. A target-site failure is a result instead: a `200` response with a `failed` scrape envelope on `/v1/scrape` (its `error.code` can itself be `internal_error`), or the `422` `blocked` / `upstream_error` row above on `/v1/fetch` |\n\n## Webhook URLs Must Use HTTPS\n\nAll webhook URLs submitted to the ByteKit API must use HTTPS. Plain HTTP URLs (e.g. `http://example.com/webhook`) are rejected with a `400` `invalid_url` error.\n\n**Why HTTPS only?** Webhook payloads may contain sensitive data (API keys, session tokens, scrape results). HTTPS encryption protects this data in transit.\n\n**Request with an invalid webhook URL:**\n\n```json\n{\n \"webhook_url\": \"http://example.com/webhook\"\n}\n```\n\n**Response (HTTP 400)** — the same unified envelope as every other error; `error.details` names the offending field and reason:\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"invalid_url\",\n \"message\": \"url is not a valid HTTP(S) URL: scheme_unsupported\",\n \"http_status\": 400,\n \"failed_at\": \"2026-08-27T12:16:29.033Z\",\n \"details\": {\n \"url\": \"http://example.com/webhook\",\n \"field\": \"webhook_url\",\n \"reason\": \"scheme_unsupported\"\n }\n }\n}\n```\n\n**Working example:**\n\n```json\n{\n \"webhook_url\": \"https://example.com/webhook\"\n}\n```\n\nThis applies to all endpoints that accept a `webhook_url` parameter: `/v1/scrape` (async), `/v1/scrape/bulk`, `/v1/fetch/bulk`, `/v1/bulk`, `/v1/monitors`, and `/v1/sitemap`.\n\n## Retry guidance\n\nNot all errors are retryable. Use this table to decide:\n\n| Code | Retry? | Guidance |\n| ---------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `invalid_url` | No | Fix the URL before retrying |\n| `validation_error` | No | Fix the request body before retrying |\n| `unauthorized` / `invalid_api_key` | No | Check your API key |\n| `quota_exceeded` | No | Retrying the same request cannot succeed while the balance is short. Compare `error.details.required_bytes` with `error.details.available_bytes`: add balance (upgrade your plan or top up), or send a smaller request. On `/v1/search`, upgrade your plan or wait for the credit reset |\n| `spending_cap_reached` | No | The overage cap is account-level and has no self-service control — [contact support](https://bytekit.com/docs/billing/spending) to raise it, or upgrade the plan |\n| `billing_entitlement_impaired` | No | Settle the outstanding invoice — retrying cannot succeed while the subscription is impaired |\n| `billing_entitlement_expired` | No | Restore or renew the subscription; the entitlement period has ended |\n| `forbidden` | No | You do not have access to this resource \n\n---\n[Truncated to the 16384-byte per-page limit — this page is 18359 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/errors]"
|
|
360
|
+
"body": "# Errors\n\nByteKit error response shape, common error codes, and retry guidance.\n\nAll errors from the ByteKit API follow a consistent envelope shape so you can handle them\nprogrammatically.\n\n## Error response shape\n\nEvery `4xx`/`5xx` response across the API uses one unified envelope. `status` is\nalways the literal string `\"failed\"`, so you can branch on the response body alone.\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"rate_limited\",\n \"message\": \"Rate limit exceeded. Allowed 5 requests per second.\",\n \"http_status\": 429,\n \"failed_at\": \"2026-08-27T12:17:46.234Z\"\n }\n}\n```\n\nThe number in a `rate_limited` message is your own plan's per-second limit — the same value the `X-RateLimit-Limit` response header carries.\n\n| Field | Description |\n| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |\n| `status` | Always `\"failed\"` on an error response — the top-level discriminator |\n| `error.code` | Machine-readable string identifier |\n| `error.message` | Human-readable explanation |\n| `error.http_status` | Mirrors the HTTP response status (useful for logged or replayed bodies) |\n| `error.failed_at` | ISO-8601 UTC timestamp of when the error was produced |\n| `error.details` | Optional object with additional context (e.g. which field failed validation). Absent — not `{}` — when the error carries no context |\n\n## Common error codes\n\n| HTTP status | Code | Meaning |\n| ----------- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `400` | `invalid_url` | A supplied URL (including `webhook_url`) is malformed or uses an unsupported scheme |\n| `400` | `validation_error` | Field errors on `/v1/search`, `POST /v1/billing/checkout` and `PUT`/`DELETE /v1/billing/payment-methods/{id}`, plus rejections that run before schema validation on any endpoint: a removed field such as `cookies` or `headers` on a capture endpoint, or a `/v1/fetch` or `/v1/fetch/bulk` request asking for an option only `/v1/scrape` or `/v1/bulk` serves |\n| `401` | `unauthorized` | Missing or malformed `Authorization` header |\n| `401` | `invalid_api_key` | API key is present but not valid |\n| `402` | `quota_exceeded` | The [balance](https://bytekit.com/docs/billing#terms) cannot fund this request. Capture endpoints reject when it cannot fund the request's byte reservation, and `error.details.required_bytes` and `error.details.available_bytes` give the bytes the request reserves and the bytes available; `/v1/search` meters credits and rejects when its credit balance is used up |\n| `402` | `spending_cap_reached` | A credit-metered request would push overage spend past the account's cap. Only reachable on a custom plan with an overage agreement — standard plans have no automatic overage and stop at `quota_exceeded` |\n| `402` | `billing_entitlement_impaired` | The paid subscription is in a payment impairment (e.g. `past_due`); `error.message` names the reason |\n| `402` | `billing_entitlement_expired` | The paid subscription's entitlement period has ended, or its dunning grace period has run out |\n| `403` | `forbidden` | Key is valid but lacks permission for this action |\n| `422` | `validation_error` | Malformed JSON, or a request field failed validation, everywhere the `400` row above does not name |\n| `422` | `content_too_large` | The page is too large to convert to markdown: over the size cap, or past the conversion deadline. On `/v1/scrape` this answers a request that asks for `markdown` (an `async` request fails with the same code on its error envelope); `/v1/schema` answers it too. The request is charged nothing, and on `/v1/scrape` the other requested formats are not returned either |\n| `422` | `blocked`, `upstream_error`, `timeout` | `/v1/fetch` only: the fetch ran and the target could not be read (bot protection refused every attempt, or another exhausted-retries failure such as an unresolvable host), or it ran out of its time limit before the page could be fetched (`timeout`). This is a result about the URL, not an outage of this API, and it is charged nothing. `upstream_error` can also come from a relay fault on our side, so the code alone does not prove the target is at fault. The `X-Fetch-ID` response header, when present, names the failed request's row in Logs |\n| `429` | `rate_limited` | Too many requests per second; back off and retry |\n| `429` | `concurrency_limit` | Too many simultaneous in-flight requests; back off and retry |\n| `500` | `internal_error` | A ByteKit-side failure (for example, failing to enqueue a job or to persist a result, or an unexpected server error), not a problem with the target site. A target-site failure is a result instead: a `200` response with a `failed` scrape envelope on `/v1/scrape` (its `error.code` can itself be `internal_error`), or the `422` `blocked` / `upstream_error` row above on `/v1/fetch` |\n\n## Webhook URLs Must Use HTTPS\n\nAll webhook URLs submitted to the ByteKit API must use HTTPS. Plain HTTP URLs (e.g. `http://example.com/webhook`) are rejected with a `400` `invalid_url` error.\n\n**Why HTTPS only?** Webhook payloads may contain sensitive data (API keys, session tokens, scrape results). HTTPS encryption protects this data in transit.\n\n**Request with an invalid webhook URL:**\n\n```json\n{\n \"webhook_url\": \"http://example.com/webhook\"\n}\n```\n\n**Response (HTTP 400)** — the same unified envelope as every other error; `error.details` names the offending field and reason:\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"invalid_url\",\n \"message\": \"url is not a valid HTTP(S) URL: scheme_unsupported\",\n \"http_status\": 400,\n \"failed_at\": \"2026-08-27T12:16:29.033Z\",\n \"details\": {\n \"url\": \"http://example.com/webhook\",\n \"field\": \"webhook_url\",\n \"reason\": \"scheme_unsupported\"\n }\n }\n}\n```\n\n**Working example:**\n\n```json\n{\n \"webhook_url\": \"https://example.com/webhook\"\n}\n```\n\nThis applies to all endpoints that accept a `webhook_url` parameter: `/v1/scrape` (async), `/v1/scrape/bulk`, `/v1/fetch/bulk`, `/v1/bulk`, `/v1/monitors`, and `/v1/sitemap`.\n\n## Retry guidance\n\nNot all errors are retryable. Use this table to decide:\n\n| Code | Retry? | Guidance |\n| ---------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `invalid_url` | No | Fix the URL before retrying |\n| `validation_error` | No | Fix the request body before retrying |\n| `unauthorized` / `invalid_api_key` | No | Check your API key |\n| `quota_exceeded` | No | Retrying the same request cannot succeed while the balance is short. Compare `error.details.required_bytes` with `error.details.available_bytes`: add balance (upgrade your plan or top up), or send a smaller request. On `/v1/search`, upgrade your plan or wait for the credit reset |\n| `spending_cap_reached` | No | The overage cap is account-level and has no self-service control — [contact support](https://bytekit.com/docs/billing/spending) to raise it, or upgrade the plan |\n| `billing_entitlement_impaired` | No | Settle the outstanding invoice — retrying cannot succeed while the subscription is impaired \n\n---\n[Truncated to the 16384-byte per-page limit — this page is 19291 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/errors]"
|
|
361
361
|
},
|
|
362
362
|
"guides/fetch": {
|
|
363
363
|
"title": "Fetch",
|
|
364
364
|
"section": "Guides",
|
|
365
|
-
"body": "# Fetch\n\nFetch the raw response from a URL — a working request, the X-Fetch-* headers, the options that matter, what it costs, and the errors to handle.\n\n`GET /v1/fetch` and `POST /v1/fetch` request a URL and return the target's response as the body of a\nsuccessful reply. The metadata about the fetch travels in `X-Fetch-*` response headers rather than in\na JSON envelope. The endpoint takes no `format`: for Markdown, links, images, browser rendering or\nasynchronous delivery, use `/v1/scrape` (see\n[When to use /v1/scrape instead](#when-to-use-v1scrape-instead)).\n\n## Fetch a URL\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/fetch \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com/?page=guide-demo\"}'\n```\n\nThe response is the upstream page, with ByteKit's metadata in the headers:\n\n```http\nHTTP/2 200\ncontent-type: text/html\nx-billable-bytes: 334\nx-billing-multiplier: 1\nx-fetch-billing-multiplier: 1\nx-fetch-cache: miss\nx-fetch-completed-at: 2026-10-10T02:36:27.212Z\nx-fetch-content-length: 334\nx-fetch-content-type: text/html\nx-fetch-created-at: 2026-10-10T02:36:27.181Z\nx-fetch-credits-charged: 0\nx-fetch-duration-ms: 452\nx-fetch-expires-at: 2027-10-10T02:36:27.212Z\nx-fetch-fast-path: true\nx-fetch-id: ft_8cabc1f901d879c89f62e4bd5ef80083\nx-fetch-status: completed\nx-fetch-url: https://example.com/?page=guide-demo\nx-raw-bytes: 334\n\n<!doctype html><html lang=en><head><meta charset=utf-8>…<title>Example Domain</title>…\n```\n\n> This request was run for real and returned `200`. The `X-Quota-*` headers are left out and the\n> body is cut short.\n\nThe same request as `GET` puts the fields in the query string:\n\n```bash\ncurl -i \"https://api.bytekit.com/v1/fetch?url=https%3A%2F%2Fexample.com%2F%3Fpage%3Dguide-demo\" \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n> This request was run for real and returned `200`.\n\nA target that answers `201` comes back as `201`. Read the body as the page, and read the headers for\neverything else.\n\n## Response headers\n\nA `200` response carries these headers:\n\n| Header | Description |\n| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `X-Fetch-ID` | Fetch identifier, prefixed `ft_` |\n| `X-Fetch-Status` | `completed` on a successful response |\n| `X-Fetch-URL` | The URL that was fetched |\n| `X-Fetch-Content-Type` | The upstream `Content-Type` |\n| `X-Fetch-Content-Length` | Size of the upstream response in bytes, as the target sent it; see `X-Fetch-Fast-Path` below for the exception. When the target compresses its responses this is the compressed size |\n| `X-Fetch-Cache` | `hit`, `miss` or `bypass` — see [Caching](#caching) |\n| `X-Fetch-Cache-Age` | On a cache hit, the age of the cached copy in seconds |\n| `X-Fetch-Duration-Ms` | How long the fetch took, in milliseconds |\n| `X-Fetch-Created-At` | ISO 8601 timestamp of when the fetch started |\n| `X-Fetch-Completed-At` | ISO 8601 timestamp of when the fetch finished |\n| `X-Fetch-Expires-At` | ISO 8601 timestamp of when the stored fetch record expires |\n| `X-Fetch-Custom` | Your `custom` payload, base64-encoded JSON. Omitted when you sent no `custom` or an empty object |\n| `X-Fetch-Waf-Vendor` | The bot-protection vendor detected on the target site, or `suspected` when a low-confidence block marker was served. Omitted when none was detected |\n| `X-Fetch-Fast-Path` | `true` or `false`; see below |\n| `X-Fetch-Credits-Charged` | `0` on the responses shown here: `/v1/fetch` is billed on bandwidth, not credits (see [Cost](#cost)) |\n| `X-Raw-Bytes` | The byte count the charge starts from (see [Cost](#cost)) |\n| `X-Billing-Multiplier` | The factor applied to `X-Raw-Bytes`: `1`, or `0.5` on a cache hit |\n| `X-Fetch-Billing-Multiplier` | The same value as `X-Billing-Multiplier`, kept for clients that read the `X-Fetch-*` family. Prefer `X-Billing-Multiplier` |\n| `X-Billable-Bytes` | What the fetch is billed: `X-Raw-Bytes` times `X-Billing-Multiplier`, rounded |\n\nThe response also carries `X-Quota-Limit`, `X-Quota-Used`, `X-Quota-Remaining` and `X-Quota-Reset`,\nwhich report your quota.\n\nWhen the target compresses its responses, your HTTP client decodes the body, so the body you read can\nbe larger than `X-Fetch-Content-Length`.\n\n`X-Fetch-Fast-Path` is `false` when the page came from the fallback path that renders it, and `true`\notherwise. In the `false` case the body is the rendered page rather than the bytes the target sent, and\n`X-Fetch-Content-Length`, `X-Raw-Bytes` and the billing headers are based on the compressed size of\nthat rendered page, not on a response from the target. A cache hit reports `true` whatever produced\nthe cached copy.\n\n## Options\n\n`GET` takes `url`, `country`, `timeout_ms` and `cache_ttl` as query parameters, and `custom` as a\nJSON-encoded string. `POST` takes the same fields as a JSON body. Only `url` is required.\n\n| Option | Default | Description |\n| ------------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `url` | — | The page to fetch. Must be an HTTP or HTTPS URL |\n| `country` | `US` | Two-letter country code the request is made from |\n| `timeout_ms` | `60000` | How long to allow for the fetch, in milliseconds, from `1000` to `90000` |\n| `cache_ttl` | `48h` | How old a cached copy may be and still be served: `Nh` (hours) or `Nd` (days) up to `168h` / `7d`, or `0` to skip the cache read. See [Caching](#caching) |\n| `custom` | `{}` | A JSON object of your own, echoed back in `X-Fetch-Custom`. At most 4096 bytes once serialized as JSON |\n\nOn `GET`, `custom` goes in the query as JSON:\n\n```bash\ncurl -G \"https://api.bytekit.com/v1/fetch\" \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n --data-urlencode \"url=https://example.com\" \\\n --data-urlencode 'custom={\"job\":\"abc\"}'\n```\n\n> This request was run for real and returned `200` with `x-fetch-custom: eyJqb2IiOiJhYmMifQ==`,\n> which decodes to `{\"job\":\"abc\"}`.\n\n`custom` does not take part in caching: requests that differ only in `custom` share one cache entry.\n\n## Caching\n\nA fetch can be served from cache when a copy exists that is no older than `cache_ttl`, and\n`X-Fetch-Cache` says what happened:\n\n| `X-Fetch-Cache` | Meaning |\n| --------------- | ---------------------------------------------------------------------------------------- |\n| `miss` | No usable cached copy; the URL was fetched fresh |\n| `hit` | Served from a cached copy; `X-Fetch-Cache-Age` gives its age in seconds |\n| `bypass` | You sent `cache_ttl` of `0`, so the cache read was skipped and the URL was fetched fresh |\n\nRepeating the request above returned a cache hit, with the billing headers showing the cache-hit\nfactor (see [Cost](#cost)):\n\n```http\nHTTP/2 200\nx-billable-bytes: 167\nx-billing-multiplier: 0.5\nx-fetch-billing-multiplier: 0.5\nx-fetch-cache: hit\nx-fetch-cache-age: 0\nx-fetch-content-length: 334\nx-raw-bytes: 334\n```\n\n> This response was returned by a real request; only the cache and billing headers are shown.\n\nA `cache_ttl` above seven days is rejected with `422 validation_error`. A fresh fetch is normally\nwritten to the cache even when you send `cache_ttl` of `0`, so a later request with a non-zero\n`cache_ttl` can be served from it. A response flagged as a suspected bot-protection block is not\nwritten, and a non-2xx answer other than `404` or `410` is kept for 60 seconds only.\n\n## When to use /v1/scrape instead\n\n`/v1/fetch` takes no `format` and does not return Markdown: naming a `/v1/scrape` format returns\n`400 validation_error` and points you at `/v1/scrape`:\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/fetch \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\", \"format\": \"markdown\"}'\n```\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"validation_error\",\n \"message\": \"Use /v1/scrape for this format.\",\n \"http_status\": 400,\n \"failed_at\": \"2026-10-10T02:31:11.017Z\"\n }\n}\n```\n\n> This request was run for real and returned `400`.\n\nReach for `/v1/scrape` when you need:\n\n| You need | Where it lives |\n| ------------------------------------------------ | ------------------------------------------ |\n| Markdown, links or images from the page | the `formats` option on `/v1/scrape` |\n| The page rendered in a browser before it is read | options such as `delay_ms` on `/v1/scrape` |\n| A queued scrape you collect later | the `async` option on `/v1/scrape` |\n\nSee the [Scraping guide](https://bytekit.com/docs/guides/scraping) for those options.\n\nRequests that ask `/v1/fetch` for something it does not do are turned away, with these statuses:\n\n| Request | Result |\n| ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `format` set to `raw`, `markdown`, `links` or `images`, or to a spelling `/v1/scrape` has retired | `400 validation_error`, message `Use /v1/scrape for this format.` |\n| `formats`, or `format` sent as an array | `400 validation_error`, pointing at `/v1/scrape` |\n| `cookies` or `headers` in the `POST` body | `400 validation_error`, message `cookies is no longer accepted: caller-supplied cookies and headers were removed from the capture API. Every capture presents ByteKit's own identity to the target site.` (`headers` in place of `cookies` for that field) |\n| `wait_for_selector` or `wait_until` in the `POST` body | `400 validation_error`, message `wait_for_selector is not accepted by /v1/fetch.` (`wait_until` in place of `wait_for_selector` for that field) |\n| `delay_ms` in the `POST` body | `400 validation_error`, message `Use /v1/scrape for browser-backed options.` |\n| A `format` value that `/v1/fetch` has no name for, or a field it does not know | `422 validation_error`; `error.details` names the unrecognized key |\n\nThe retired spellings that get that `400` include `rawHtml`, `raw_html`\nand `html`.\n\nEach of those five fields gets its own message, because they have different destinations. Only\n`delay_ms` is a `/v1/scrape` option, so only its message points there (see the [Scraping guide](https://bytekit.com/docs/guides/scraping)).\n`wait_for_selector` and `wait_until` belong to `/v1/screenshots` and are not accepted by `/v1/scrape`, so\ntheir message names no other endpoint. No capture endpoint accepts `cookies` or `headers`, so theirs names none either.\n\nThe `400` checks run before field validation, so a body that carries both a rejected option and an\ninvalid field gets the `400`. On `GET`, `/v1/fetch` reads `url`, `country`, `timeout_ms`, `cache_ttl`,\n`custom` and `format`. A `delay_ms` in the query string is not rejected\nthere: `GET /v1/fetch?url=…&delay_ms=500` returned `200`, where the same field in a `POST` body gets the\n`400` above.\n\n## Cost\n\n`/v1/fetch` is billed on bandwidth: the bytes counted in `X-Raw-Bytes` (the bytes the target sent, or\nthe compressed size of the rendered page when `X-Fetch-Fast-Path` is `false`), at a factor of 1\n\n---\n[Truncated to the 16384-byte per-page limit — this page is 23398 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/fetch]"
|
|
365
|
+
"body": "# Fetch\n\nFetch the raw response from a URL — a working request, the X-Fetch-* headers, the options that matter, what it costs, and the errors to handle.\n\n`GET /v1/fetch` and `POST /v1/fetch` request a URL and return the target's response as the body of a\nsuccessful reply. The metadata about the fetch travels in `X-Fetch-*` response headers rather than in\na JSON envelope. The endpoint takes no `format`: for Markdown, links, images, browser rendering or\nasynchronous delivery, use `/v1/scrape` (see\n[When to use /v1/scrape instead](#when-to-use-v1scrape-instead)).\n\n## Fetch a URL\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/fetch \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com/?page=guide-demo\"}'\n```\n\nThe response is the upstream page, with ByteKit's metadata in the headers:\n\n```http\nHTTP/2 200\ncontent-type: text/html\nx-billable-bytes: 334\nx-billing-multiplier: 1\nx-fetch-billing-multiplier: 1\nx-fetch-cache: miss\nx-fetch-completed-at: 2026-10-10T02:36:27.212Z\nx-fetch-content-length: 334\nx-fetch-content-type: text/html\nx-fetch-created-at: 2026-10-10T02:36:27.181Z\nx-fetch-credits-charged: 0\nx-fetch-duration-ms: 452\nx-fetch-expires-at: 2027-10-10T02:36:27.212Z\nx-fetch-fast-path: true\nx-fetch-id: ft_8cabc1f901d879c89f62e4bd5ef80083\nx-fetch-status: completed\nx-fetch-url: https://example.com/?page=guide-demo\nx-raw-bytes: 334\n\n<!doctype html><html lang=en><head><meta charset=utf-8>…<title>Example Domain</title>…\n```\n\n> This request was run for real and returned `200`. The `X-Quota-*` headers are left out and the\n> body is cut short.\n\nThe same request as `GET` puts the fields in the query string:\n\n```bash\ncurl -i \"https://api.bytekit.com/v1/fetch?url=https%3A%2F%2Fexample.com%2F%3Fpage%3Dguide-demo\" \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n> This request was run for real and returned `200`.\n\nA target that answers `201` comes back as `201`. Read the body as the page, and read the headers for\neverything else.\n\n## Response headers\n\nA `200` response carries these headers:\n\n| Header | Description |\n| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `X-Fetch-ID` | Fetch identifier, prefixed `ft_` |\n| `X-Fetch-Status` | `completed` on a successful response |\n| `X-Fetch-URL` | The URL that was fetched |\n| `X-Fetch-Content-Type` | The upstream `Content-Type` |\n| `X-Fetch-Content-Length` | Size of the upstream response in bytes, as the target sent it; see `X-Fetch-Fast-Path` below for the exception. When the target compresses its responses this is the compressed size |\n| `X-Fetch-Cache` | `hit`, `miss` or `bypass` — see [Caching](#caching) |\n| `X-Fetch-Cache-Age` | On a cache hit, the age of the cached copy in seconds |\n| `X-Fetch-Duration-Ms` | How long the fetch took, in milliseconds |\n| `X-Fetch-Created-At` | ISO 8601 timestamp of when the fetch started |\n| `X-Fetch-Completed-At` | ISO 8601 timestamp of when the fetch finished |\n| `X-Fetch-Expires-At` | ISO 8601 timestamp of when the stored fetch record expires |\n| `X-Fetch-Custom` | Your `custom` payload, base64-encoded JSON. Omitted when you sent no `custom` or an empty object |\n| `X-Fetch-Waf-Vendor` | The bot-protection vendor detected on the target site, or `suspected` when a low-confidence block marker was served. Omitted when none was detected |\n| `X-Fetch-Fast-Path` | `true` or `false`; see below |\n| `X-Fetch-Credits-Charged` | `0` on the responses shown here: `/v1/fetch` is billed on bandwidth, not credits (see [Cost](#cost)) |\n| `X-Raw-Bytes` | The byte count the charge starts from (see [Cost](#cost)) |\n| `X-Billing-Multiplier` | The factor applied to `X-Raw-Bytes`: `1`, or `0.5` on a cache hit |\n| `X-Fetch-Billing-Multiplier` | The same value as `X-Billing-Multiplier`, kept for clients that read the `X-Fetch-*` family. Prefer `X-Billing-Multiplier` |\n| `X-Billable-Bytes` | What the fetch is billed: `X-Raw-Bytes` times `X-Billing-Multiplier`, rounded |\n\nThe response also carries `X-Quota-Limit`, `X-Quota-Used`, `X-Quota-Remaining` and `X-Quota-Reset`,\nwhich report your quota.\n\nWhen the target compresses its responses, your HTTP client decodes the body, so the body you read can\nbe larger than `X-Fetch-Content-Length`.\n\n`X-Fetch-Fast-Path` is `false` when the page came from the fallback path that renders it, and `true`\notherwise. In the `false` case the body is the rendered page rather than the bytes the target sent, and\n`X-Fetch-Content-Length`, `X-Raw-Bytes` and the billing headers are based on the compressed size of\nthat rendered page, not on a response from the target. A cache hit reports `true` whatever produced\nthe cached copy.\n\n## Options\n\n`GET` takes `url`, `country`, `timeout_ms` and `cache_ttl` as query parameters, and `custom` as a\nJSON-encoded string. `POST` takes the same fields as a JSON body. Only `url` is required.\n\n| Option | Default | Description |\n| ------------ | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `url` | — | The page to fetch. Must be an HTTP or HTTPS URL |\n| `country` | `US` | Two-letter country code the request is made from |\n| `timeout_ms` | `60000` | How long to allow for the fetch, in milliseconds, from `1000` to `90000` |\n| `cache_ttl` | `48h` | How old a cached copy may be and still be served: `Nh` (hours) or `Nd` (days) up to `168h` / `7d`, or `0` to skip the cache read. See [Caching](#caching) |\n| `custom` | `{}` | A JSON object of your own, echoed back in `X-Fetch-Custom`. At most 4096 bytes once serialized as JSON |\n\nOn `GET`, `custom` goes in the query as JSON:\n\n```bash\ncurl -G \"https://api.bytekit.com/v1/fetch\" \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n --data-urlencode \"url=https://example.com\" \\\n --data-urlencode 'custom={\"job\":\"abc\"}'\n```\n\n> This request was run for real and returned `200` with `x-fetch-custom: eyJqb2IiOiJhYmMifQ==`,\n> which decodes to `{\"job\":\"abc\"}`.\n\n`custom` does not take part in caching: requests that differ only in `custom` share one cache entry.\n\n## Caching\n\nA fetch can be served from cache when a copy exists that is no older than `cache_ttl`, and\n`X-Fetch-Cache` says what happened:\n\n| `X-Fetch-Cache` | Meaning |\n| --------------- | ---------------------------------------------------------------------------------------- |\n| `miss` | No usable cached copy; the URL was fetched fresh |\n| `hit` | Served from a cached copy; `X-Fetch-Cache-Age` gives its age in seconds |\n| `bypass` | You sent `cache_ttl` of `0`, so the cache read was skipped and the URL was fetched fresh |\n\nRepeating the request above returned a cache hit, with the billing headers showing the cache-hit\nfactor (see [Cost](#cost)):\n\n```http\nHTTP/2 200\nx-billable-bytes: 167\nx-billing-multiplier: 0.5\nx-fetch-billing-multiplier: 0.5\nx-fetch-cache: hit\nx-fetch-cache-age: 0\nx-fetch-content-length: 334\nx-raw-bytes: 334\n```\n\n> This response was returned by a real request; only the cache and billing headers are shown.\n\nA `cache_ttl` above seven days is rejected with `422 validation_error`. A fresh fetch is normally\nwritten to the cache even when you send `cache_ttl` of `0`, so a later request with a non-zero\n`cache_ttl` can be served from it. A response flagged as a suspected bot-protection block is not\nwritten, and a non-2xx answer other than `404` or `410` is kept for 60 seconds only.\n\n## When to use /v1/scrape instead\n\n`/v1/fetch` takes no `format` and does not return Markdown: naming a `/v1/scrape` format returns\n`400 validation_error` and points you at `/v1/scrape`:\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/fetch \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\", \"format\": \"markdown\"}'\n```\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"validation_error\",\n \"message\": \"Use /v1/scrape for this format.\",\n \"http_status\": 400,\n \"failed_at\": \"2026-10-10T02:31:11.017Z\"\n }\n}\n```\n\n> This request was run for real and returned `400`.\n\nReach for `/v1/scrape` when you need:\n\n| You need | Where it lives |\n| ------------------------------------------------ | ------------------------------------------ |\n| Markdown, links or images from the page | the `formats` option on `/v1/scrape` |\n| The page rendered in a browser before it is read | options such as `delay_ms` on `/v1/scrape` |\n| A queued scrape you collect later | the `async` option on `/v1/scrape` |\n\nSee the [Scraping guide](https://bytekit.com/docs/guides/scraping) for those options.\n\nRequests that ask `/v1/fetch` for something it does not do are turned away, with these statuses:\n\n| Request | Result |\n| ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `format` set to `raw`, `markdown`, `links` or `images`, or to a spelling `/v1/scrape` has retired | `400 validation_error`, message `Use /v1/scrape for this format.` |\n| `formats`, or `format` sent as an array | `400 validation_error`, pointing at `/v1/scrape` |\n| `cookies` or `headers` in the `POST` body | `400 validation_error`, message `cookies is no longer accepted: caller-supplied cookies and headers were removed from the capture API. Every capture presents ByteKit's own identity to the target site.` (`headers` in place of `cookies` for that field) |\n| `wait_for_selector` or `wait_until` in the `POST` body | `400 validation_error`, message `wait_for_selector is not accepted by /v1/fetch.` (`wait_until` in place of `wait_for_selector` for that field) |\n| `delay_ms` in the `POST` body | `400 validation_error`, message `Use /v1/scrape for browser-backed options.` |\n| A `format` value that `/v1/fetch` has no name for, or a field it does not know | `422 validation_error`; `error.details` names the unrecognized key |\n\nThe retired spellings that get that `400` include `rawHtml`, `raw_html`\nand `html`.\n\nEach of those five fields gets its own message, because they have different destinations. Only\n`delay_ms` is a `/v1/scrape` option, so only its message points there (see the [Scraping guide](https://bytekit.com/docs/guides/scraping)).\n`wait_for_selector` and `wait_until` belong to `/v1/screenshots` and are not accepted by `/v1/scrape`, so\ntheir message names no other endpoint. No capture endpoint accepts `cookies` or `headers`, so theirs names none either.\n\nThe `400` checks run before field validation, so a body that carries both a rejected option and an\ninvalid field gets the `400`. On `GET`, `/v1/fetch` reads `url`, `country`, `timeout_ms`, `cache_ttl`,\n`custom` and `format`. A `delay_ms` in the query string is not rejected\nthere: `GET /v1/fetch?url=…&delay_ms=500` returned `200`, where the same field in a `POST` body gets the\n`400` above.\n\n## Cost\n\n`/v1/fetch` is billed on bandwidth: the bytes counted in `X-Raw-Bytes` (the bytes the target sent, or\nthe compressed size of the rendered page when `X-Fetch-Fast-Path` is `false`), at a factor of 1\n\n---\n[Truncated to the 16384-byte per-page limit — this page is 24090 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/fetch]"
|
|
366
366
|
},
|
|
367
367
|
"guides/monitors": {
|
|
368
368
|
"title": "Monitors",
|
|
@@ -377,7 +377,7 @@
|
|
|
377
377
|
"guides/schema-extraction": {
|
|
378
378
|
"title": "Schema extraction",
|
|
379
379
|
"section": "Guides",
|
|
380
|
-
"body": "# Schema extraction\n\nTurn any page into structured JSON — a working request, the options that matter, the response, what it costs, and the errors to handle.\n\n`POST /v1/schema` fetches a URL and returns data from it as JSON that follows a\n[JSON Schema](https://json-schema.org/) you provide. Send a `url` and a `schema` describing the\nfields you want, such as a product name and price, and you get back an object with those fields\nfilled in from the page. An optional `prompt` tells the extraction what to look for.\n\nThe call is synchronous: it returns `200` with the result in the response body. There is no\nasync mode, and a field this endpoint does not know is rejected (see [Errors](#errors)).\n\n## Run an extraction\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/schema \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"title\": { \"type\": \"string\" },\n \"price\": { \"type\": \"number\" },\n \"in_stock\": { \"type\": \"boolean\" }\n }\n },\n \"prompt\": \"Extract the book title, its price as a number, and whether it is in stock.\"\n }'\n```\n\n```json\n{\n \"data\": {\n \"title\": \"A Light in the Attic\",\n \"price\": 51.77,\n \"in_stock\": true\n },\n \"model\": \"openai/gpt-oss-20b\",\n \"validated\": true,\n \"metrics\": {\n \"scrape_ms\": 1006,\n \"llm_total_ms\": 257,\n \"input_tokens\": 977,\n \"output_tokens\": 91,\n \"retries\": 0,\n \"total_ms\": 1502\n },\n \"scrape\": {\n \"url\": \"https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html\",\n \"status_code\": 200,\n \"content_length\": 2303,\n \"truncated\": false\n },\n \"warnings\": []\n}\n```\n\n> This request was run for real and returned `200`. The response is printed as it came back,\n> reformatted for reading. The page is a public practice shop for scraping; the timings and token\n> counts will differ on your calls.\n\n## Options\n\n`url` and `schema` are required. Send any of the others alongside them.\n\n| Option | Default | Description |\n| ------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------- |\n| `url` | — | The page to extract from. An `http` or `https` URL |\n| `schema` | — | A JSON Schema describing the output (see [Writing the schema](#writing-the-schema)) |\n| `prompt` | none | A hint in plain language about what to extract, up to 2000 characters |\n| `model` | `openai/gpt-oss-20b` | The extraction model: `openai/gpt-oss-20b` or `openai/gpt-oss-120b`. Any other value is rejected with `400 unsupported_model` |\n| `country` | `US` | Two-letter country code that sets where the page is fetched from, upper-cased for you. `null` is treated as `US` |\n| `language` | `null` | A string or `null`. The API accepts it, but the extraction does not use it today |\n| `wait_until` | `load` | `load` or `domcontentloaded`. `networkidle` is rejected (see [Rendering options](#rendering-options)) |\n| `wait_for_selector` | `null` | Must stay unset or `null` (see [Rendering options](#rendering-options)) |\n| `delay_ms` | `0` | Must stay `0` (see [Rendering options](#rendering-options)). A value outside `0`–`10000` is a `422 validation_error` |\n\n### Rendering options\n\n`/v1/schema` reads the page the quick way, without waiting on a browser to render it. Options\nthat ask for that waiting are therefore refused with `400 unsupported_option`:\n`wait_until` set to `networkidle`, a `wait_for_selector`, or a `delay_ms` above `0`. The error\nmessage lists the options this endpoint does not support; it does not say which of yours\ntriggered it.\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"unsupported_option\",\n \"message\": \"Schema extraction does not support slow-path options (wait_for_selector, wait_until=networkidle, cookies, delay_ms, custom headers).\",\n \"http_status\": 400,\n \"failed_at\": \"2026-10-09T23:17:40.806Z\"\n }\n}\n```\n\n> This response came from a real request with `\"wait_until\": \"networkidle\"`.\n\nCaller-supplied `cookies` and `headers` are no longer accepted: sending either returns\n`400 validation_error`.\n\n### Writing the schema\n\nThe `schema` is a JSON Schema (draft 2020-12) object. To keep the output reliable, ByteKit\naccepts a deliberately small part of the language:\n\n- The root must be an object schema: `\"type\": \"object\"` with its `properties`.\n- These keywords are accepted: `type`, `properties`, `required`,\n `additionalProperties`, `items`, `enum`, `$defs`, `$ref`, `description`, `title` and\n `default`. A `$ref` can only point into your own `#/$defs`.\n- Other keywords are rejected with `422 schema_incompatible`, and `error.details.construct`\n names the one found. They include `pattern`, `format`, `minimum`, `maxLength`, `oneOf`, `anyOf`,\n `allOf`, `not` and `if`/`then`/`else`.\n- The schema can be at most 50,000 characters once serialized, and nested `properties` can go\n at most 8 levels deep (the count restarts inside `items`, and `$defs` entries are not counted). A schema over either\n limit, or one that is not valid JSON Schema, returns `422 validation_error`.\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"schema_incompatible\",\n \"message\": \"schema_incompatible: unsupported construct \\\"pattern\\\" — unsupported keyword \\\"pattern\\\" found at #/properties/title\",\n \"http_status\": 422,\n \"failed_at\": \"2026-10-09T23:17:43.923Z\",\n \"details\": {\n \"construct\": \"pattern\"\n }\n }\n}\n```\n\n> This response came from a real request whose schema used `pattern`.\n\nEvery property you declare is asked for. What a missing value looks like depends on the\nproperty's type: a `string`, `number`, `integer`, `boolean` or `object` property the page does not\ncontain usually comes back as `null`, and a list (`array`) property usually comes back as an empty\narray, `[]`. Asking the book page above for an `isbn` it does not show returned `\"isbn\": null`.\nAsking it for a `title` and a list of literary awards, declared as an `array` of `string` items,\nreturned `\"awards\": []`. Both responses had `validated` set to `true`.\n\nA property limited by `enum`, such as `{\"type\": \"string\", \"enum\": [\"hardcover\", \"paperback\"]}`,\ncomes back as `null` when the page holds none of the listed values. The `type` is optional: an\n`enum` with no `type` behaves the same way. Your `enum` does not need to list `null`. Asking the\nbook page above for that `format` next to a `title` returned `\"format\": null` with `validated` set\nto `true`; asked for on its own, the same request returned `200` with `validated` set to `false`\nand an `empty_extraction` warning, which charges no credits. A model can also answer with one of the\nlisted values that the page does not support, so treat an `enum` result as a guess when the page is\nsilent. An `integer` property with `\"enum\": [1, 2]` returned `2` on a page that states no edition.\n\nOne kind of schema can instead fail with `503 provider_error` when the page has no value to give: a\nschema whose only properties are lists of strings, such as\n`{\"type\": \"object\", \"properties\": {\"awards\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}}}`,\nwhen the page has no entries. The same schema returned `\"awards\": []` on one call and\n`503 provider_error` on others, so it does not fail every time. The `title` and `awards` request\nabove, which asks for a `title` as well, returned `[]`.\n\nThis failure can repeat on retry, and it keeps the page's bandwidth charge (see\n[Cost](#cost)), so change the schema instead of retrying the same request.\n\nLists work through `items`. This schema collects every book on a category page:\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/schema \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://books.toscrape.com/catalogue/category/books/poetry_23/index.html\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"category\": { \"type\": \"string\" },\n \"books\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"title\": { \"type\": \"string\" },\n \"price\": { \"type\": \"number\" }\n }\n }\n }\n }\n },\n \"prompt\": \"List every book on the page with its price as a number.\"\n }'\n```\n\n> This request was run for real and returned `200` with `\"validated\": true` and 19 books in\n> `data.books`. Its `scrape.content_length` was `4521`. The first two books were:\n> `{\"title\": \"A Light in the Attic\", \"price\": 51.77}` and\n> `{\"title\": \"The Black Maria\", \"price\": 52.15}`.\n\n## Response\n\n| Field | Description |\n| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `data` | The extracted object, shaped by your schema. `null` when `validated` is `false` |\n| `model` | The model that produced the result |\n| `validated` | `true` when the output matched your schema, unless it holds values and all of them are `null`. See below for when this is `false` |\n| `metrics` | Timings in milliseconds (`scrape_ms`, `llm_total_ms`, `total_ms`), the token counts (`input_tokens`, `output_tokens`) and `retries`, the number of extra attempts (0 to 2) |\n| `scrape` | The page that was read: its `url`, the `status_code` it answered with (or `null`), `content_length` (its size in bytes, which the bandwidth charge uses) and `truncated` |\n| `warnings` | Codes for results that are less complete than a clean run. An empty array on a clean run |\n\nA `200` does not always mean you got data. `validated` is `false`, with `data: null`, when the\nmodel refused, when its retries ran out before it produced output that matched your schema, or\nwhen the output holds values and every one of them is `null`. That last case is still `true` if your\nschema allows it: each `null` value has to sit at a property whose `type` is a list that includes\n`\"null\"`, for example `[\"string\", \"null\"]`. Check `validated` before you use `data`.\n\n```json\n{\n \"data\": null,\n \"model\": \"openai/gpt-oss-20b\",\n \"validated\": false,\n \"metrics\": {\n \"scrape_ms\": 1455,\n \"llm_total_ms\": 220,\n \"input_tokens\": 303,\n \"output_tokens\": 102,\n \"retries\": 0,\n \"total_ms\": 1711\n },\n \"scrape\": {\n \"url\": \"https://example.com\",\n \"status_code\": 200,\n \"content_length\": 334,\n \"truncated\": false\n },\n \"warnings\": [\"empty_extraction\"]\n}\n```\n\n> This response came from a real request that asked `https://example.com`, which has no price,\n> for a `price` and a `sku`.\n\nThe warning codes are:\n\n| Code | Meaning |\n| --------------------------- | -------------------------------------------------------------------------------------- |\n| `content_truncated` | The page was too long for the model and was cut short, so the result may be incomplete |\n| `extract_validation_failed` | The model's output did not match your schema |\n| `exhausted_retries` | The retries ran out before the model produced output that matched your schema |\n| `model_refusal` | The model declined to extract |\n| `empty_extraction` | The output matched your schema, but it held values and all of them were `null` |\n\n## Cost\n\nA request is billed on two things:\n\n- **A fixed credit charge.** Today a request costs 10 credits, whatever the page or the schema, and they are charged only when the extraction validates.\n- **The page's bandwidth.** The page is billed at the bytes it took to download, which is the\n `scrape.content_length` in the response, with no multiplier. While the page loads the account is\n charged an estimate of 100 KiB; when the download finishes the estimate is replaced by the real\n size.\n\nWhen a request fails, what you keep paying depends on how far it got:\n\n| What happened | Credits | Bandwidth |\n| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | ----------------------------- |\n| Rejected or failed before the page was fetched | Not charged, or refunded | Not charged, or refunded |\n| The page was fetched, but the extraction failed (`provider_error`, `provider_timeout`, `provider_rate_limited`, `content_too_large`, or `schema_incompatible` raised after the fetch) | Refunded | Kept: the page was downloaded |\n| The page was fetched and the call returned `200` with `validated: false` | Not charged | Kept: the page was downloaded |\n| A successful extraction | Charged | Charged |\n\n[Credit billing](https://bytekit.com/docs/billing/credits) covers the two charges and a failure before the fetch, and\n[Rate Limits](https://bytekit.com/docs/guides/rate-limits) covers a failed extraction after it. On real requests,\n`credits_scrape` on `GET /v1/usage` rose by 10 after a successful extraction and did not move after\nthe `validated: false` call or a request for a host that does not exist.\n\n> The credits for this endpoint appear in `credits_scrape` on `GET /v1/usage`.\n\n## Not in the SDKs\n\n`/v1/schema` is not available in the TypeScript SDK, the Python SDK or the CLI: none of them has a\nmethod for it. Call the HTTP endpoint directly, as in the examples above. Any HTTP client works\nwith the same `Authorization: Bearer` header; see [Authentication](https://bytekit.com/docs/guides/authentication).\n\n## Errors\n\nErrors use the unified envelope described in the [Errors guide](https://bytekit.com/docs/guides/errors). These are the\nones you are most likely to meet on this endpoint. The Errors guide does not list\n`unsupported_option`, `unsupported_model`, `schema_incompatible`, `content_too_large`,\n`scrape_failed` or the `provider_*` codes, so handle those here.\n\n| Status | Code | When \n\n---\n[Truncated to the 16384-byte per-page limit — this page is 24026 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/schema-extraction]"
|
|
380
|
+
"body": "# Schema extraction\n\nTurn any page into structured JSON — a working request, the options that matter, the response, what it costs, and the errors to handle.\n\n`POST /v1/schema` fetches a URL and returns data from it as JSON that follows a\n[JSON Schema](https://json-schema.org/) you provide. Send a `url` and a `schema` describing the\nfields you want, such as a product name and price, and you get back an object with those fields\nfilled in from the page. An optional `prompt` tells the extraction what to look for.\n\nThe call is synchronous: it returns `200` with the result in the response body. There is no\nasync mode, and a field this endpoint does not know is rejected (see [Errors](#errors)).\n\n## Run an extraction\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/schema \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"title\": { \"type\": \"string\" },\n \"price\": { \"type\": \"number\" },\n \"in_stock\": { \"type\": \"boolean\" }\n }\n },\n \"prompt\": \"Extract the book title, its price as a number, and whether it is in stock.\"\n }'\n```\n\n```json\n{\n \"data\": {\n \"title\": \"A Light in the Attic\",\n \"price\": 51.77,\n \"in_stock\": true\n },\n \"model\": \"openai/gpt-oss-20b\",\n \"validated\": true,\n \"metrics\": {\n \"scrape_ms\": 1006,\n \"llm_total_ms\": 257,\n \"input_tokens\": 977,\n \"output_tokens\": 91,\n \"retries\": 0,\n \"total_ms\": 1502\n },\n \"scrape\": {\n \"url\": \"https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html\",\n \"status_code\": 200,\n \"content_length\": 2303,\n \"truncated\": false\n },\n \"warnings\": []\n}\n```\n\n> This request was run for real and returned `200`. The response is printed as it came back,\n> reformatted for reading. The page is a public practice shop for scraping; the timings and token\n> counts will differ on your calls. It was captured before `id` and `credits_used` were added to the\n> response, so neither appears here.\n\n## Options\n\n`url` and `schema` are required. Send any of the others alongside them.\n\n| Option | Default | Description |\n| ------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------- |\n| `url` | — | The page to extract from. An `http` or `https` URL |\n| `schema` | — | A JSON Schema describing the output (see [Writing the schema](#writing-the-schema)) |\n| `prompt` | none | A hint in plain language about what to extract, up to 2000 characters |\n| `model` | `openai/gpt-oss-20b` | The extraction model: `openai/gpt-oss-20b` or `openai/gpt-oss-120b`. Any other value is rejected with `400 unsupported_model` |\n| `country` | `US` | Two-letter country code that sets where the page is fetched from, upper-cased for you. `null` is treated as `US` |\n| `language` | `null` | A string or `null`. The API accepts it, but the extraction does not use it today |\n| `wait_until` | `load` | `load` or `domcontentloaded`. `networkidle` is rejected (see [Rendering options](#rendering-options)) |\n| `wait_for_selector` | `null` | Must stay unset or `null` (see [Rendering options](#rendering-options)) |\n| `delay_ms` | `0` | Must stay `0` (see [Rendering options](#rendering-options)). A value outside `0`–`10000` is a `422 validation_error` |\n\n### Rendering options\n\n`/v1/schema` reads the page the quick way, without waiting on a browser to render it. Options\nthat ask for that waiting are therefore refused with `400 unsupported_option`:\n`wait_until` set to `networkidle`, a `wait_for_selector`, or a `delay_ms` above `0`. The error\nmessage lists the options this endpoint does not support; it does not say which of yours\ntriggered it.\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"unsupported_option\",\n \"message\": \"Schema extraction does not support slow-path options (wait_for_selector, wait_until=networkidle, cookies, delay_ms, custom headers).\",\n \"http_status\": 400,\n \"failed_at\": \"2026-10-09T23:17:40.806Z\"\n }\n}\n```\n\n> This response came from a real request with `\"wait_until\": \"networkidle\"`.\n\nCaller-supplied `cookies` and `headers` are no longer accepted: sending either returns\n`400 validation_error`.\n\n### Writing the schema\n\nThe `schema` is a JSON Schema (draft 2020-12) object. To keep the output reliable, ByteKit\naccepts a deliberately small part of the language:\n\n- The root must be an object schema: `\"type\": \"object\"` with its `properties`.\n- These keywords are accepted: `type`, `properties`, `required`,\n `additionalProperties`, `items`, `enum`, `$defs`, `$ref`, `description`, `title` and\n `default`. A `$ref` can only point into your own `#/$defs`.\n- Other keywords are rejected with `422 schema_incompatible`, and `error.details.construct`\n names the one found. They include `pattern`, `format`, `minimum`, `maxLength`, `oneOf`, `anyOf`,\n `allOf`, `not` and `if`/`then`/`else`.\n- The schema can be at most 50,000 characters once serialized, and nested `properties` can go\n at most 8 levels deep (the count restarts inside `items`, and `$defs` entries are not counted). A schema over either\n limit, or one that is not valid JSON Schema, returns `422 validation_error`.\n\n```json\n{\n \"status\": \"failed\",\n \"error\": {\n \"code\": \"schema_incompatible\",\n \"message\": \"schema_incompatible: unsupported construct \\\"pattern\\\" — unsupported keyword \\\"pattern\\\" found at #/properties/title\",\n \"http_status\": 422,\n \"failed_at\": \"2026-10-09T23:17:43.923Z\",\n \"details\": {\n \"construct\": \"pattern\"\n }\n }\n}\n```\n\n> This response came from a real request whose schema used `pattern`.\n\nEvery property you declare is asked for. What a missing value looks like depends on the\nproperty's type: a `string`, `number`, `integer`, `boolean` or `object` property the page does not\ncontain usually comes back as `null`, and a list (`array`) property usually comes back as an empty\narray, `[]`. Asking the book page above for an `isbn` it does not show returned `\"isbn\": null`.\nAsking it for a `title` and a list of literary awards, declared as an `array` of `string` items,\nreturned `\"awards\": []`. Both responses had `validated` set to `true`.\n\nA property limited by `enum`, such as `{\"type\": \"string\", \"enum\": [\"hardcover\", \"paperback\"]}`,\ncomes back as `null` when the page holds none of the listed values. The `type` is optional: an\n`enum` with no `type` behaves the same way. Your `enum` does not need to list `null`. Asking the\nbook page above for that `format` next to a `title` returned `\"format\": null` with `validated` set\nto `true`; asked for on its own, the same request returned `200` with `validated` set to `false`\nand an `empty_extraction` warning, which charges no credits. A model can also answer with one of the\nlisted values that the page does not support, so treat an `enum` result as a guess when the page is\nsilent. An `integer` property with `\"enum\": [1, 2]` returned `2` on a page that states no edition.\n\nOne kind of schema can instead fail with `503 provider_error` when the page has no value to give: a\nschema whose only properties are lists of strings, such as\n`{\"type\": \"object\", \"properties\": {\"awards\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}}}`,\nwhen the page has no entries. The same schema returned `\"awards\": []` on one call and\n`503 provider_error` on others, so it does not fail every time. The `title` and `awards` request\nabove, which asks for a `title` as well, returned `[]`.\n\nThis failure can repeat on retry, and it keeps the page's bandwidth charge (see\n[Cost](#cost)), so change the schema instead of retrying the same request.\n\nLists work through `items`. This schema collects every book on a category page:\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/schema \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://books.toscrape.com/catalogue/category/books/poetry_23/index.html\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"category\": { \"type\": \"string\" },\n \"books\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"title\": { \"type\": \"string\" },\n \"price\": { \"type\": \"number\" }\n }\n }\n }\n }\n },\n \"prompt\": \"List every book on the page with its price as a number.\"\n }'\n```\n\n> This request was run for real and returned `200` with `\"validated\": true` and 19 books in\n> `data.books`. Its `scrape.content_length` was `4521`. The first two books were:\n> `{\"title\": \"A Light in the Attic\", \"price\": 51.77}` and\n> `{\"title\": \"The Black Maria\", \"price\": 52.15}`.\n\n## Response\n\n| Field | Description |\n| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `id` | The request's ID, starting `sch_`. It is the same ID the request carries in the Logs feed |\n| `data` | The extracted object, shaped by your schema. `null` when `validated` is `false` |\n| `model` | The model that produced the result |\n| `validated` | `true` when the output matched your schema, unless it holds values and all of them are `null`. See below for when this is `false` |\n| `metrics` | Timings in milliseconds (`scrape_ms`, `llm_total_ms`, `total_ms`), the token counts (`input_tokens`, `output_tokens`) and `retries`, the number of extra attempts (0 to 2) |\n| `scrape` | The page that was read: its `url`, the `status_code` it answered with (or `null`), `content_length` (its size in bytes, which the bandwidth charge uses) and `truncated` |\n| `warnings` | Codes for results that are less complete than a clean run. An empty array on a clean run |\n| `credits_used` | The credits charged for this request: 10 when `validated` is `true`, 0 otherwise. Bandwidth is billed separately, on `scrape.content_length` |\n\nA `200` does not always mean you got data. `validated` is `false`, with `data: null`, when the\nmodel refused, when its retries ran out before it produced output that matched your schema, or\nwhen the output holds values and every one of them is `null`. That last case is still `true` if your\nschema allows it: each `null` value has to sit at a property whose `type` is a list that includes\n`\"null\"`, for example `[\"string\", \"null\"]`. Check `validated` before you use `data`.\n\n```json\n{\n \"data\": null,\n \"model\": \"openai/gpt-oss-20b\",\n \"validated\": false,\n \"metrics\": {\n \"scrape_ms\": 1455,\n \"llm_total_ms\": 220,\n \"input_tokens\": 303,\n \"output_tokens\": 102,\n \"retries\": 0,\n \"total_ms\": 1711\n },\n \"scrape\": {\n \"url\": \"https://example.com\",\n \"status_code\": 200,\n \"content_length\": 334,\n \"truncated\": false\n },\n \"warnings\": [\"empty_extraction\"]\n}\n```\n\n> This response came from a real request that asked `https://example.com`, which has no price,\n> for a `price` and a `sku`. It was captured before `id` and `credits_used` were added to the\n> response, so neither appears here.\n\nThe warning codes are:\n\n| Code | Meaning |\n| --------------------------- | -------------------------------------------------------------------------------------- |\n| `content_truncated` | The page was too long for the model and was cut short, so the result may be incomplete |\n| `extract_validation_failed` | The model's output did not match your schema |\n| `exhausted_retries` | The retries ran out before the model produced output that matched your schema |\n| `model_refusal` | The model declined to extract |\n| `empty_extraction` | The output matched your schema, but it held values and all of them were `null` |\n\n## Cost\n\nA request is billed on two things:\n\n- **A fixed credit charge.** Today a request costs 10 credits, whatever the page or the schema, and they are charged only when the extraction validates. The `200` response reports what was charged in `credits_used`: 10 when `validated` is `true`, 0 otherwise.\n- **The page's bandwidth.** The page is billed at the bytes it took to download, which is the\n `scrape.content_length` in the response, with no multiplier. While the page loads the account is\n charged an estimate of 100 KiB; when the download finishes the estimate is replaced by the real\n size.\n\nWhen a request fails, what you keep paying depends on how far it got:\n\n| What happened | Credits | Bandwidth |\n| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | ----------------------------- |\n| Rejected or failed before the page was fetched | Not charged, or refunded | Not charged, or refunded |\n| The page was fetched, but the extraction failed (`provider_error`, `provider_timeout`, `provider_rate_limited`, `content_too_large`, or `schema_incompatible` raised after the fetch) | Refunded | Kept: the page was downloaded |\n| The page was fetched and the call returned `200` with `validated: false` | Not charged | Kept: the page was downloaded |\n| A successful extraction | Charged | Charged |\n\n[Credit billing](https://bytekit.com/docs/billing/credits) covers the two charges and a failure before the fetch, and\n[Rate Limits](https://bytekit.com/docs/guides/rate-limits) covers a failed extraction after it. On real requests,\n`credits_scrape` on `GET /v1/usage` rose by 10 after a successful extraction and did not move after\nthe `validated: false` call or a request for a host that does not exist.\n\n> The credits for this endpoint appear in `credits_scrape` on `GET /v1/usage`.\n\n## Not in the SDKs\n\n`/v1/schema` is not available in the TypeScript SDK, the Python SDK or the CLI: none of \n\n---\n[Truncated to the 16384-byte per-page limit — this page is 25473 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/schema-extraction]"
|
|
381
381
|
},
|
|
382
382
|
"guides/scraping": {
|
|
383
383
|
"title": "Scraping",
|
|
@@ -387,7 +387,7 @@
|
|
|
387
387
|
"guides/screenshots": {
|
|
388
388
|
"title": "Screenshots",
|
|
389
389
|
"section": "Guides",
|
|
390
|
-
"body": "# Screenshots\n\nCapture a screenshot of any URL — a working request, the options that matter, the response, what it costs, and the errors to handle.\n\n`POST /v1/screenshots` loads a URL in a real browser and returns an image of the page. Send a\nURL and you get back a `jpeg` (the default) or `png`, plus the page title and the image\ndimensions. Everything else — device, viewport, how long to wait, what to hide — is optional.\n\n## Capture a screenshot\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/screenshots \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n```\n\nBy default the call is **synchronous**: the request is held open for up to 28 seconds and\nreturns `200` with the finished screenshot. The response is JSON — `image_url` is a link to the\nimage, not the image bytes:\n\n```json\n{\n \"id\": \"ss_01a1210c210477f6838a6256629087e6\",\n \"status\": \"completed\",\n \"url\": \"https://example.com\",\n \"image_url\": \"https://<storage-host>/.../screenshot.jpeg?X-Amz-Signature=...\",\n \"page_title\": \"Example Domain\",\n \"image_width\": 1440,\n \"image_height\": 900,\n \"file_size_bytes\": 62635,\n \"credits_charged\": 1,\n \"billing\": {\n \"raw_bytes\": 334,\n \"factors\": [\n {\n \"name\": \"phase1_render\",\n \"value\": 1.5,\n \"reason\": \"phase 1 proxy fetch + render overhead\"\n }\n ],\n \"multiplier\": 1.5,\n \"billed_bytes\": 501\n },\n \"error_code\": null,\n \"error_message\": null,\n \"created_at\": \"2026-10-09T14:23:25.417Z\",\n \"completed_at\": \"2026-10-09T14:23:33.047Z\",\n \"expires_at\": \"2027-10-09T14:23:25.407Z\",\n \"poll_url\": \"https://api.bytekit.com/v1/screenshots/ss_01a1210c210477f6838a6256629087e6\"\n}\n```\n\n> This response was returned by a real request. Two values are edited for the page: the signed `image_url` is shortened, and `poll_url` shows the production\n> host.\n\n| Field | Description |\n| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `id` | Screenshot id, prefixed `ss_`. Use it with `GET /v1/screenshots/{id}` |\n| `status` | `pending`, `processing`, `completed`, or `failed` |\n| `image_url` | Signed link to the image. It stays valid for 10 minutes — fetch a fresh one by polling `GET /v1/screenshots/{id}` |\n| `page_title` | The page's `<title>` |\n| `image_width`, `image_height` | Image dimensions in pixels |\n| `file_size_bytes` | Size of the image file. Informational only — it is not what you are billed on (see [Cost](#cost)) |\n| `billing` | What the capture was billed: `raw_bytes`, the `factors` applied, the resulting `multiplier`, and `billed_bytes` |\n| `error_code`, `error_message` | Why a capture failed. `null` on success. On `pending` or `processing`, a set value is the last failed attempt's error while the capture is retried; on `failed`, it is the final cause |\n| `expires_at` | When the stored image expires |\n| `poll_url` | Where to poll this screenshot |\n\nThe `200` response also carries `X-Screenshot-*` headers (the same id, status and timestamps as\nthe JSON) and `X-Quota-*` headers reporting your quota.\n\nIf the capture is still running when the 28 seconds are up, the call returns `202` with\n`status: \"processing\"` and the same `id`. The capture keeps running in the background — poll it\nas described in [Async captures](#async-captures).\n\n## Options\n\nSend any of these alongside `url`. All are optional and the defaults suit most pages. Unknown\nfields are rejected with `422 validation_error`.\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/screenshots \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"format\": \"png\",\n \"viewport\": {\"width\": 1280, \"height\": 720},\n \"dark_mode\": true,\n \"wait_until\": \"networkidle\"\n }'\n```\n\n> This request was run for real and returned `200` with\n> `\"image_width\": 1280` and `\"image_height\": 720`.\n\n**Output**\n\n| Option | Default | Description |\n| --------------------- | ------- | -------------------------------------------------------------------------------------------------------------------- |\n| `format` | `jpeg` | Image format: `jpeg` or `png` |\n| `quality` | `80` | Image quality, an integer from `1` to `100` |\n| `full_page` | `false` | Capture the whole scrollable page instead of only the viewport |\n| `clip` | `null` | Capture only a region: `{\"x\": 0, \"y\": 0, \"width\": 800, \"height\": 600}` in pixels (`width` and `height` at least `1`) |\n| `device_scale_factor` | `null` | Pixel density: `1` or `null`; any other value is a 422 `validation_error` |\n\n**Device**\n\n| Option | Default | Description |\n| ----------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `device` | `desktop` | `desktop` or `mobile` |\n| `viewport` | `null` | Browser window size, `{\"width\": 1280, \"height\": 720}` in pixels. Overrides the device default. Width 360 to 2544, height 1 to 1297; any other size is a 422 `validation_error` |\n| `dark_mode` | `false` | Render the page with a dark colour scheme preference |\n\n**Page readiness**\n\n| Option | Default | Description |\n| ------------------- | ------- | ------------------------------------------------------------------------------ |\n| `wait_until` | `load` | Navigation event to wait for: `load`, `domcontentloaded`, or `networkidle` |\n| `wait_for_selector` | `null` | CSS selector that must be visible before the capture is taken |\n| `delay_ms` | `0` | Extra wait after the page is ready, in milliseconds (`0` to `10000`) |\n| `scroll` | `true` | Scroll the page to the bottom before capturing, so lazy-loaded content appears |\n\n`wait_until` and `wait_for_selector` are Screenshot options. They are not `POST /v1/scrape`\noptions — sending either there returns `422`. See the [Scraping guide](https://bytekit.com/docs/guides/scraping).\n\n**Clean-up**\n\n| Option | Default | Description |\n| ---------------------- | ------- | --------------------------- |\n| `block_ads` | `true` | Block ads on the page |\n| `block_cookie_banners` | `true` | Hide cookie-consent banners |\n\n**Geo and language**\n\n| Option | Default | Description |\n| ---------- | ------- | ---------------------------------------------------------------------------------- |\n| `country` | `US` | Two-letter, upper-case country code the page is requested from |\n| `language` | `null` | Browser language, for example `de-DE`. When `null`, the language follows `country` |\n\n**Other**\n\n| Option | Default | Description |\n| -------------- | ------- | ----------------------------------------------------------------------------------------------------------- |\n| `include_html` | `false` | Also capture the page's rendered HTML alongside the image. The HTML is not returned in the response |\n| `metadata` | `{}` | Your own key-value pairs to attach to the capture. At most 4096 bytes as JSON; keys must not start with `_` |\n\n`cookies` and `headers` are not request options on any capture endpoint. Sending either returns\n`400 validation_error`.\n\n## Async captures\n\nFor pages that take a while, add `?async=true` to the URL, or send `\"async\": true` in the request\nbody. Either one is enough, and `false` in one never cancels `true` in the other. The call returns\n`202` immediately with an `ss_` id and `status: \"pending\"`, and the capture runs in the background.\n`POST /v1/scrape` accepts the same two spellings.\n\n```bash\n# Start an async capture\ncurl -X POST \"https://api.bytekit.com/v1/screenshots?async=true\" \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n\n# Poll for the result\ncurl https://api.bytekit.com/v1/screenshots/ss_... \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\nThe first call returns:\n\n```json\n{\n \"id\": \"ss_01a1210d0e3a719589e9c3d70c4791d2\",\n \"status\": \"pending\",\n \"url\": \"https://example.com\",\n \"image_url\": null,\n \"page_title\": null,\n \"image_width\": null,\n \"image_height\": null,\n \"file_size_bytes\": null,\n \"credits_charged\": 1,\n \"error_code\": null,\n \"error_message\": null,\n \"created_at\": \"2026-10-09T14:24:26.172Z\",\n \"completed_at\": null,\n \"expires_at\": \"2027-10-09T14:24:26.149Z\",\n \"poll_url\": \"https://api.bytekit.com/v1/screenshots/ss_01a1210d0e3a719589e9c3d70c4791d2\"\n}\n```\n\n> This response was returned by a real request; `poll_url` shows the production host.\n\n`GET /v1/screenshots/{id}` answers by state:\n\n| State | Status | Body |\n| ------------------------------- | ------ | ---------------------------------------------------------------------- |\n| Still `pending` or `processing` | `202` | The screenshot resource; poll again |\n| `completed` | `200` | The full screenshot resource, with a fresh signed `image_url` |\n| `failed` | `200` | The [error envelope](https://bytekit.com/docs/guides/errors), with the failure in `error.code` |\n\nA failed capture is a successfully retrieved terminal state, so check `status` before reading\n`image_url`.\n\n## Pages that are not HTML\n\nA URL that serves text-like content — plain text, JSON, XML — is captured as the browser displays\nit and billed as usual. A URL that serves anything else, such as an image, a PDF or binary data,\nfails with `unsupported_content_type` on its first attempt, is not retried, and bills nothing.\n\n## Cost\n\nScreenshots are billed on bandwidth, not credits. A capture is billed on the bytes of the\ninitial page fetch, multiplied by 1.5 — the extra 0.5 covers rendering the page. The size of the\nimage file is not the basis. If that initial fetch is skipped or fails, the capture bills nothing.\n\nIn the example above, the page fetch transferred 334 bytes (`raw_bytes`), so the capture was\nbilled 501 bytes (`billed_bytes`). The `billing` object is the authoritative breakdown; its\n`factors[].reason` text is descriptive and may change, so read `value` and `multiplier` rather\nthan parsing it. The same figures arrive in the `X-Raw-Bytes`, `X-Billing-Multiplier`, and\n`X-Billable-Bytes` response headers.\n\nThe `credits_charged` field and the `X-Screenshot-Credits-Charged` header carry a legacy weight\n(`1`, `2` or `4`, doubling for `full_page` and again for mobile). It is recorded for\nreporting only and is not what you are billed. For how capture bandwidth is billed,\nsee [Bandwidth billing](https://bytekit.com/docs/billing/bandwidth).\n\n## Errors\n\nErrors use the unified envelope described in the [Errors guide](https://bytekit.com/docs/guides/errors). These are the\nones you are most likely to meet on this endpoint:\n\n| Status | Code | When | Retry? |\n| ------ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------ |\n| `400` | `invalid_url` | `url` is not a valid HTTP(S) URL. `error.details.reason` says why, for example `scheme_unsupported` | No — fix the URL |\n| `400` | `request_too_large` | The request body is over 512 KB | No — send a smaller body |\n| `401` | `unauthorized`, `invalid_api_key` | The API key is missing, malformed, or not valid | No — check your key |\n| `400` | `validation_error` | The request carries a removed field such as `cookies` or `headers` | No — remove the field |\n| `402` | `quota_exceeded` | The balance cannot fund the capture. `error.details.required_bytes` and `available_bytes` give the numbers | No — add balance or upgrade |\n| `402` | `spending_cap_reached`, `billing_entitlement_impaired`, `billing_entitlement_expired` | The spending cap or the subscription state blocks the request — see the [Errors guide](https://bytekit.com/docs/guides/errors) | No — resolve the billing state first |\n| `403` | `host_forbidden`, `path_forbidden` | The URL's host \n\n---\n[Truncated to the 16384-byte per-page limit — this page is 19126 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/screenshots]"
|
|
390
|
+
"body": "# Screenshots\n\nCapture a screenshot of any URL — a working request, the options that matter, the response, what it costs, and the errors to handle.\n\n`POST /v1/screenshots` loads a URL in a real browser and returns an image of the page. Send a\nURL and you get back a `jpeg` (the default) or `png`, plus the page title and the image\ndimensions. Everything else — device, viewport, how long to wait, what to hide — is optional.\n\n## Capture a screenshot\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/screenshots \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n```\n\nBy default the call is **synchronous**: the request is held open for up to 28 seconds and\nreturns `200` with the finished screenshot. The response is JSON — `image_url` is a link to the\nimage, not the image bytes:\n\n```json\n{\n \"id\": \"ss_01a1210c210477f6838a6256629087e6\",\n \"status\": \"completed\",\n \"url\": \"https://example.com\",\n \"image_url\": \"https://<storage-host>/.../screenshot.jpeg?X-Amz-Signature=...\",\n \"page_title\": \"Example Domain\",\n \"image_width\": 1440,\n \"image_height\": 900,\n \"file_size_bytes\": 62635,\n \"credits_charged\": 1,\n \"billing\": {\n \"raw_bytes\": 334,\n \"factors\": [\n {\n \"name\": \"phase1_render\",\n \"value\": 1.5,\n \"reason\": \"phase 1 proxy fetch + render overhead\"\n }\n ],\n \"multiplier\": 1.5,\n \"billed_bytes\": 501\n },\n \"error_code\": null,\n \"error_message\": null,\n \"created_at\": \"2026-10-09T14:23:25.417Z\",\n \"completed_at\": \"2026-10-09T14:23:33.047Z\",\n \"expires_at\": \"2027-10-09T14:23:25.407Z\",\n \"poll_url\": \"https://api.bytekit.com/v1/screenshots/ss_01a1210c210477f6838a6256629087e6\"\n}\n```\n\n> This response was returned by a real request. Two values are edited for the page: the signed `image_url` is shortened, and `poll_url` shows the production\n> host.\n\n| Field | Description |\n| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `id` | Screenshot id, prefixed `ss_`. Use it with `GET /v1/screenshots/{id}` |\n| `status` | `pending`, `processing`, `completed`, or `failed` |\n| `image_url` | Signed link to the image. It stays valid for 10 minutes — fetch a fresh one by polling `GET /v1/screenshots/{id}` |\n| `page_title` | The page's `<title>` |\n| `image_width`, `image_height` | Image dimensions in pixels |\n| `file_size_bytes` | Size of the image file. Informational only — it is not what you are billed on (see [Cost](#cost)) |\n| `billing` | What the capture was billed: `raw_bytes`, the `factors` applied, the resulting `multiplier`, and `billed_bytes` |\n| `error_code`, `error_message` | Why a capture failed. `null` on success. On `pending` or `processing`, a set value is the last failed attempt's error while the capture is retried; on `failed`, it is the final cause |\n| `expires_at` | When the stored image expires |\n| `poll_url` | Where to poll this screenshot |\n\nThe `200` response also carries `X-Screenshot-*` headers (the same id, status and timestamps as\nthe JSON) and `X-Quota-*` headers reporting your quota.\n\nIf the capture is still running when the 28 seconds are up, the call returns `202` with\n`status: \"processing\"` and the same `id`. The capture keeps running in the background — poll it\nas described in [Async captures](#async-captures).\n\n## Options\n\nSend any of these alongside `url`. All are optional and the defaults suit most pages. Unknown\nfields are rejected with `422 validation_error`.\n\n```bash\ncurl -X POST https://api.bytekit.com/v1/screenshots \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"format\": \"png\",\n \"viewport\": {\"width\": 1280, \"height\": 720},\n \"dark_mode\": true,\n \"wait_until\": \"networkidle\"\n }'\n```\n\n> This request was run for real and returned `200` with\n> `\"image_width\": 1280` and `\"image_height\": 720`.\n\n**Output**\n\n| Option | Default | Description |\n| --------------------- | ------- | -------------------------------------------------------------------------------------------------------------------- |\n| `format` | `jpeg` | Image format: `jpeg` or `png` |\n| `quality` | `80` | Image quality, an integer from `1` to `100` |\n| `full_page` | `false` | Capture the whole scrollable page instead of only the viewport |\n| `clip` | `null` | Capture only a region: `{\"x\": 0, \"y\": 0, \"width\": 800, \"height\": 600}` in pixels (`width` and `height` at least `1`) |\n| `device_scale_factor` | `null` | Pixel density: `1` or `null`; any other value is a 422 `validation_error` |\n\n**Device**\n\n| Option | Default | Description |\n| ----------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `device` | `desktop` | `desktop` or `mobile` |\n| `viewport` | `null` | Browser window size, `{\"width\": 1280, \"height\": 720}` in pixels. Overrides the device default. Width 360 to 2544, height 1 to 1297; any other size is a 422 `validation_error` |\n| `dark_mode` | `false` | Render the page with a dark colour scheme preference |\n\n**Page readiness**\n\n| Option | Default | Description |\n| ------------------- | ------- | ------------------------------------------------------------------------------ |\n| `wait_until` | `load` | Navigation event to wait for: `load`, `domcontentloaded`, or `networkidle` |\n| `wait_for_selector` | `null` | CSS selector that must be visible before the capture is taken |\n| `delay_ms` | `0` | Extra wait after the page is ready, in milliseconds (`0` to `10000`) |\n| `scroll` | `true` | Scroll the page to the bottom before capturing, so lazy-loaded content appears |\n\n`wait_until` and `wait_for_selector` are Screenshot options. They are not `POST /v1/scrape`\noptions — sending either there returns `422`. See the [Scraping guide](https://bytekit.com/docs/guides/scraping).\n\n**Clean-up**\n\n| Option | Default | Description |\n| ---------------------- | ------- | --------------------------- |\n| `block_ads` | `true` | Block ads on the page |\n| `block_cookie_banners` | `true` | Hide cookie-consent banners |\n\n**Geo and language**\n\n| Option | Default | Description |\n| ---------- | ------- | ---------------------------------------------------------------------------------- |\n| `country` | `US` | Two-letter, upper-case country code the page is requested from |\n| `language` | `null` | Browser language, for example `de-DE`. When `null`, the language follows `country` |\n\n**Other**\n\n| Option | Default | Description |\n| -------------- | ------- | ----------------------------------------------------------------------------------------------------------- |\n| `include_html` | `false` | Also capture the page's rendered HTML alongside the image. The HTML is not returned in the response |\n| `metadata` | `{}` | Your own key-value pairs to attach to the capture. At most 4096 bytes as JSON; keys must not start with `_` |\n\n`cookies` and `headers` are not request options on any capture endpoint. Sending either returns\n`400 validation_error`.\n\n## Async captures\n\nFor pages that take a while, add `?async=true` to the URL, or send `\"async\": true` in the request\nbody. Either one is enough, and `false` in one never cancels `true` in the other. The call returns\n`202` immediately with an `ss_` id and `status: \"pending\"`, and the capture runs in the background.\n`POST /v1/scrape` accepts the same two spellings.\n\n```bash\n# Start an async capture\ncurl -X POST \"https://api.bytekit.com/v1/screenshots?async=true\" \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n\n# Poll for the result\ncurl https://api.bytekit.com/v1/screenshots/ss_... \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\nThe first call returns:\n\n```json\n{\n \"id\": \"ss_01a1210d0e3a719589e9c3d70c4791d2\",\n \"status\": \"pending\",\n \"url\": \"https://example.com\",\n \"image_url\": null,\n \"page_title\": null,\n \"image_width\": null,\n \"image_height\": null,\n \"file_size_bytes\": null,\n \"credits_charged\": 1,\n \"error_code\": null,\n \"error_message\": null,\n \"created_at\": \"2026-10-09T14:24:26.172Z\",\n \"completed_at\": null,\n \"expires_at\": \"2027-10-09T14:24:26.149Z\",\n \"poll_url\": \"https://api.bytekit.com/v1/screenshots/ss_01a1210d0e3a719589e9c3d70c4791d2\"\n}\n```\n\n> This response was returned by a real request; `poll_url` shows the production host.\n\n`GET /v1/screenshots/{id}` answers by state:\n\n| State | Status | Body |\n| ------------------------------- | ------ | ---------------------------------------------------------------------- |\n| Still `pending` or `processing` | `202` | The screenshot resource; poll again |\n| `completed` | `200` | The full screenshot resource, with a fresh signed `image_url` |\n| `failed` | `200` | The [error envelope](https://bytekit.com/docs/guides/errors), with the failure in `error.code` |\n\nA failed capture is a successfully retrieved terminal state, so check `status` before reading\n`image_url`.\n\n## Pages that are not HTML\n\nA URL that serves text-like content — plain text, JSON, XML — is captured as the browser displays\nit and billed as usual. A URL that serves anything else, such as an image, a PDF or binary data,\nfails with `unsupported_content_type` on its first attempt, is not retried, and bills nothing.\n\n## Cost\n\nScreenshots are billed on bandwidth, not credits. A capture is billed on the bytes of the\ninitial page fetch, multiplied by 1.5 — the extra 0.5 covers rendering the page. The size of the\nimage file is not the basis. If that initial fetch is skipped or fails, the capture bills nothing.\n\nIn the example above, the page fetch transferred 334 bytes (`raw_bytes`), so the capture was\nbilled 501 bytes (`billed_bytes`). The `billing` object is the authoritative breakdown; its\n`factors[].reason` text is descriptive and may change, so read `value` and `multiplier` rather\nthan parsing it. The same figures arrive in the `X-Raw-Bytes`, `X-Billing-Multiplier`, and\n`X-Billable-Bytes` response headers.\n\nThe `credits_charged` field and the `X-Screenshot-Credits-Charged` header carry a legacy weight\n(`1`, `2` or `4`, doubling for `full_page` and again for mobile). It is recorded for\nreporting only and is not what you are billed. For how capture bandwidth is billed,\nsee [Bandwidth billing](https://bytekit.com/docs/billing/bandwidth).\n\n## Errors\n\nErrors use the unified envelope described in the [Errors guide](https://bytekit.com/docs/guides/errors). These are the\nones you are most likely to meet on this endpoint:\n\n| Status | Code | When | Retry? |\n| ------ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------ |\n| `400` | `invalid_url` | `url` is not a valid HTTP(S) URL. `error.details.reason` says why, for example `scheme_unsupported` | No — fix the URL |\n| `400` | `request_too_large` | The request body is over 512 KB | No — send a smaller body |\n| `401` | `unauthorized`, `invalid_api_key` | The API key is missing, malformed, or not valid | No — check your key |\n| `400` | `validation_error` | The request carries a removed field such as `cookies` or `headers` | No — remove the field |\n| `402` | `quota_exceeded` | The balance cannot fund the capture. `error.details.required_bytes` and `available_bytes` give the numbers | No — add balance or upgrade |\n| `402` | `spending_cap_reached`, `billing_entitlement_impaired`, `billing_entitlement_expired` | The spending cap or the subscription state blocks the request — see the [Errors guide](https://bytekit.com/docs/guides/errors) | No — resolve the billing state first |\n| `403` | `host_forbidden`, `path_forbidden` | The URL's host \n\n---\n[Truncated to the 16384-byte per-page limit — this page is 19419 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/screenshots]"
|
|
391
391
|
},
|
|
392
392
|
"guides/search": {
|
|
393
393
|
"title": "Search",
|
|
@@ -397,7 +397,7 @@
|
|
|
397
397
|
"guides/sitemap": {
|
|
398
398
|
"title": "Sitemap",
|
|
399
399
|
"section": "Guides",
|
|
400
|
-
"body": "# Sitemap\n\nDiscover the URLs on a domain — start a job, read its status, download the results file, get a webhook, and what it costs.\n\n`POST /v1/sitemap` finds the URLs of a website, and `GET /v1/sitemap/{id}` reports on the job.\nA valid request answers `202` with a job id. ByteKit discovers the URLs in the background and saves them as a results file that you download from `results_url`.\n\n## Start a job\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/sitemap \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://bytekit.com\", \"strategy\": \"quick\", \"max_urls\": 20}'\n```\n\n```json\n{\n \"id\": \"sm_c013b3fa71f94ff292f5c2fa74f8d77b\",\n \"url\": \"https://bytekit.com\",\n \"strategy\": \"quick\",\n \"max_depth\": 2,\n \"max_urls\": 20,\n \"status\": \"pending\",\n \"total_urls\": null,\n \"sources\": null,\n \"total_bytes\": null,\n \"results_url\": null,\n \"warnings\": null,\n \"error_code\": null,\n \"error_message\": null,\n \"compact\": false,\n \"process\": null,\n \"metadata\": null,\n \"created_at\": \"2026-10-10T14:59:44.602Z\",\n \"completed_at\": null,\n \"expires_at\": null,\n \"cache\": \"miss\",\n \"cache_age_s\": null\n}\n```\n\n> This request was run for real and returned `202`. `cache` is `miss` because no earlier job could answer it; see [Cache](#cache).\n\nOnly `url` is required. Keep the `id`: it is how you read the job.\n\n| Field | Default | What it does |\n| ---------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `url` | (required) | The site to discover. Only the scheme and host are used: a path, query string or fragment is accepted but ignored, and the `202` response carries a `warnings` entry saying so |\n| `strategy` | `standard` | `quick`, `standard` or `deep`: where ByteKit looks for URLs. See [Strategies](#strategies) |\n| `max_depth` | `2` | From 1 to 5. How many levels of page links a `deep` job follows |\n| `max_urls` | `5000` | From 1 to 100000. A new job stops collecting at this many URLs |\n| `process` | `null` | An object with an `action` and `options`. ByteKit accepts it and returns it on the job, and it has no other effect |\n| `compact` | `false` | `true` makes the results file a plain list of URLs, one per line, with no header |\n| `metadata` | none | An object of your own, up to 4096 bytes when serialized. It is returned on the job and in webhook deliveries. A key that starts with `_` is rejected with `422 validation_error` |\n| `webhook_url` | none | An `https://` URL to notify about the job. An `http://` URL is rejected with `400 invalid_url` and the reason `scheme_unsupported`. See [Webhooks](#webhooks) |\n| `webhook_secret` | `null` | Signs the webhook deliveries. It is ignored when there is no `webhook_url` |\n| `cache_ttl` | `30d` | How old a cached job may be and still answer the request. It is a string: `0`, hours such as `48h`, or days such as `30d`, up to 90 days. A number is rejected with `422 validation_error` |\n\nThe `202` response reports `url` after ByteKit has normalised it: the scheme and host are lowercased, an international host is in punycode, non-ASCII characters are percent-encoded, and surrounding spaces are trimmed. If the result is only a scheme and host, with or without a trailing `/`, it is returned as `scheme://host`. If it carries a path, query string or fragment, it is returned whole, together with the `warnings` entry. `GET` returns the host as `scheme://host`.\n\n## Strategies\n\n| Strategy | Where it looks |\n| ---------- | ---------------------------------------------------------------------------------------------------------------------------- |\n| `quick` | The sitemap files the site publishes. Every URL has the source `sitemap` |\n| `standard` | The same, plus URLs from your account's completed scrapes of the host in the last 90 days. These have the source `known` |\n| `deep` | The same as `standard`, plus URLs found by following links on pages, up to `max_depth` levels. These have the source `links` |\n\nThe sources run in that order, and each one fills only the room that `max_urls` leaves. A URL found by more than one source is counted once, under the first.\nA `deep` job follows links only from URLs the earlier sources found, so on a site with no sitemap files and no `known` URLs it finds no `links`.\nThe job's `sources` field counts the URLs per source. For a `deep` job run for real it read `{\"known\": 1, \"links\": 4, \"sitemap\": 119}`.\n\n## Check the job\n\n`GET /v1/sitemap/{id}` answers `200` with the job whatever its `status`: `pending`, `processing`, `completed` or `failed`. Poll it every few seconds until the status is `completed` or `failed`. The jobs on this page finished within a few seconds.\n\n```bash\ncurl -i https://api.bytekit.com/v1/sitemap/sm_c013b3fa71f94ff292f5c2fa74f8d77b \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n```json\n{\n \"id\": \"sm_c013b3fa71f94ff292f5c2fa74f8d77b\",\n \"url\": \"https://bytekit.com\",\n \"strategy\": \"quick\",\n \"max_depth\": 2,\n \"max_urls\": 20,\n \"status\": \"completed\",\n \"total_urls\": 20,\n \"sources\": { \"sitemap\": 20 },\n \"total_bytes\": 196,\n \"results_url\": \"https://…\",\n \"warnings\": [],\n \"error_code\": null,\n \"error_message\": null,\n \"compact\": false,\n \"process\": null,\n \"metadata\": null,\n \"created_at\": \"2026-10-10T14:59:44.602Z\",\n \"completed_at\": \"2026-10-10T14:59:47.405Z\",\n \"expires_at\": \"2027-01-08T14:59:47.405Z\",\n \"billing\": {\n \"factors\": [{ \"name\": \"endpoint\", \"value\": 1, \"reason\": \"sitemap\" }],\n \"raw_bytes\": 196,\n \"multiplier\": 1,\n \"billed_bytes\": 196\n }\n}\n```\n\n> This request was run for real and returned `200`. The signed `results_url` is shortened.\n\n| Field | Meaning |\n| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `status` | `pending`, `processing`, `completed` or `failed` |\n| `total_urls` | How many URLs the results hold. `null` until the job completes |\n| `sources` | The URLs per source: `sitemap`, `known` or `links` |\n| `total_bytes` | The size in bytes of the gzip-compressed results file. This is what the job is billed on; see [Cost](#cost) |\n| `results_url` | A signed link to the results file, present once the job is `completed`. Each `GET` of a completed job returns a new link, valid for 7 days |\n| `warnings` | Notes about the run, such as a source that could not be read |\n| `error_code`, `error_message` | Why a job failed. `null` otherwise |\n| `billing` | What the job was billed: `raw_bytes`, the `factors` applied, the `multiplier` and `billed_bytes` |\n| `expires_at` | When the job expires: 90 days after it completes, except that a cache hit keeps the expiry of the job that answered it. `null` until the job completes |\n\nA completed `200` also carries the headers `X-Raw-Bytes`, `X-Billing-Multiplier` and `X-Billable-Bytes`, which show the same figures as `billing`.\n\n### When a job fails\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/sitemap \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\", \"strategy\": \"quick\", \"max_urls\": 20}'\n```\n\n> This request was run for real and returned `202`, with the same fields as above and `cache` `miss`. The job then failed, and polling it returned `200`:\n\n```json\n{\n \"id\": \"sm_a380b0ea64dd4b19a854699c58933499\",\n \"url\": \"https://example.com\",\n \"strategy\": \"quick\",\n \"max_depth\": 2,\n \"max_urls\": 20,\n \"status\": \"failed\",\n \"total_urls\": null,\n \"sources\": null,\n \"total_bytes\": null,\n \"results_url\": null,\n \"warnings\": [\"robots.txt unavailable (non-success fetch)\"],\n \"error_code\": \"no_urls_found\",\n \"error_message\": \"No URLs discovered for this domain\",\n \"compact\": false,\n \"process\": null,\n \"metadata\": null,\n \"created_at\": \"2026-10-10T14:59:54.408Z\",\n \"completed_at\": \"2026-10-10T14:59:55.941Z\",\n \"expires_at\": null\n}\n```\n\nA `robots.txt` or sitemap file that ByteKit cannot read does not fail a job by itself. It adds an entry to `warnings`, and discovery goes on with the other sources. A sitemap file that is not there (`404` or `410`) or is empty adds no warning, and neither does a page that cannot be fetched while a `deep` job follows links.\nThese are the `error_code` values you may meet:\n\n| `error_code` | When |\n| ---------------- | ------------------------------------------------------------------------ |\n| `no_urls_found` | Discovery ended without finding a URL |\n| `blocked` | The site blocks ByteKit's requests, so discovery did not start |\n| `job_timeout` | The job did not finish in time |\n| `internal_error` | A failure on ByteKit's side |\n| `worker_crash` | The job stopped making progress, and ByteKit failed it after a long wait |\n\nA job that fails with `worker_crash` sends no `sitemap.failed` webhook, so poll the job as well as listening for the webhook.\n\n## Download the results\n\n```bash\ncurl --compressed \"$RESULTS_URL\"\n```\n\n```csv\nurl,source\nhttps://bytekit.com/docs/changelog,sitemap\nhttps://bytekit.com/docs,sitemap\nhttps://bytekit.com/docs/introduction,sitemap\n```\n\n> This request was run for real and returned `200`. The file holds a header and 20 rows, and the first rows are shown.\n\nThe results file is a gzip-compressed CSV, served with `Content-Encoding: gzip`, so `--compressed` makes curl decode it. A client that does not decode gzip receives the compressed bytes, and their count is `total_bytes`.\nIt has the header `url,source` and one row per discovered URL, and `source` is `sitemap`, `known` or `links`. In that format a URL that contains a comma is wrapped in double quotes.\nWith `compact: true` the file is a plain list of URLs, one per line, with no header. The `lastmod` and `depth` columns are not emitted.\n\n## Cache\n\nBefore it queues discovery, ByteKit looks for a completed job of your account that has the same scheme and host and the same `strategy`, that finished within `cache_ttl`, and whose `max_depth` and `max_urls` are at least the ones you sent.\nA job that was itself a cache hit is never matched, only the job that ran discovery is, so `cache_ttl` counts from when that job finished.\nThe `cache` field of the `202` response says what it found. `GET` leaves out `cache` and `cache_age_s`.\n\n| `cache` | Meaning |\n| -------- | ------------------------------------------------------------------------------------------------------------------------------- |\n| `miss` | No such job. A new job is queued |\n| `hit` | A job matched. The response is already `completed` and has a `results_url`, and `cache_age_s` is the age of that job in seconds |\n| `bypass` | `cache_ttl` is `0`, so the cache was not read and a new job is queued |\n\nSending the request above again a few seconds later returned a hit:\n\n```json\n{\n \"id\": \"sm_6aa7e5ea6a854f19976754b0fdc8f438\",\n \"url\": \"https://bytekit.com\",\n \"strategy\": \"quick\",\n \"max_depth\": 2,\n \"max_urls\": 20,\n \"status\": \"completed\",\n \"total_urls\": 20,\n \"sources\": { \"sitemap\": 20 },\n \"total_bytes\": 196,\n \"results_url\": \"https://…\",\n \"warnings\": null,\n \"error_code\": null,\n \"error_message\": null,\n \"compact\": false,\n \"process\": null,\n \"metadata\": null,\n \"created_at\": \"2026-10-10T14:59:53.441Z\",\n \"completed_at\": \"2026-10-10T14:59:53.440Z\",\n \"expires_at\": \"2027-01-08T14:59:47.405Z\",\n \"billing\": {\n \"factors\": [\n { \"name\": \"endpoint\", \"value\": 1, \"reason\": \"sitemap\" },\n { \"name\": \"cache_hit\", \"value\": 0.5, \"reason\": \"hit\" }\n ],\n \"raw_bytes\": 196,\n \"multiplier\": 0.5,\n \"billed_bytes\": 98\n },\n \"cache\": \"hit\",\n \"cache_age_s\": 6\n}\n```\n\n> This request was run for real and returned `202`. The signed `results_url` is shortened.\n\nA hit has an `id` of its own and points at the same results file as the job that answered it.\nThe file is returned as that job stored it. It can hold more URLs than the `max_urls` you sent, and it keeps the format that job was created with, whatever `compact` you send, because `compact` is not part of the match.\nThe `compact` field of a hit's response repeats your request, not the format of the file, so tell the format from the file: only a non-compact file starts with the header line `url,source`.\nTo get a new job that follows your request, send `cache_ttl` `0`.\n\n## Webhooks\n\nSend a `webhook_url` and ByteKit POSTs the outcome to it. The header `X-ByteKit-Event` is `sitemap.completed` when the job completes and `sitemap.failed` when it fails, so you can dispatch on the header without reading the body. A cache hit sends `sitemap.completed` as well. A failure that sends no `sitemap.failed` is described under [When a job fails](#when-a-job-fails).\nWithout a `webhook_url` the job is poll-only. Set `webhook_secret` to have the deliveries signed; see the [Webhooks guide](https://bytekit.com/docs/guides/webhooks) for verification. The [Scraping guide](https://bytekit.com/docs/guides/scraping#webhook-event-header) lists the other event types.\n\nThe body has two keys, `event`, which repeats the header, and `data`. This page shows no captured delivery, only the fields:\n\n| Event | `data` holds |\n| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |\n| `sitemap.completed` | `id`, `url`, `strategy`, `status`, `total_urls`, `sources`, `total_bytes`, `res\n\n---\n[Truncated to the 16384-byte per-page limit — this page is 20821 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/sitemap]"
|
|
400
|
+
"body": "# Sitemap\n\nDiscover the URLs on a domain — start a job, read its status, download the results file, get a webhook, and what it costs.\n\n`POST /v1/sitemap` finds the URLs of a website, and `GET /v1/sitemap/{id}` reports on the job.\nA valid request answers `202` with a job id. ByteKit discovers the URLs in the background and saves them as a results file that you download from `results_url`.\n\n## Start a job\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/sitemap \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://bytekit.com\", \"strategy\": \"quick\", \"max_urls\": 20}'\n```\n\n```json\n{\n \"id\": \"sm_c013b3fa71f94ff292f5c2fa74f8d77b\",\n \"url\": \"https://bytekit.com\",\n \"strategy\": \"quick\",\n \"max_depth\": 2,\n \"max_urls\": 20,\n \"status\": \"pending\",\n \"total_urls\": null,\n \"sources\": null,\n \"total_bytes\": null,\n \"results_url\": null,\n \"warnings\": null,\n \"error_code\": null,\n \"error_message\": null,\n \"compact\": false,\n \"process\": null,\n \"metadata\": null,\n \"created_at\": \"2026-10-10T14:59:44.602Z\",\n \"completed_at\": null,\n \"expires_at\": null,\n \"cache\": \"miss\",\n \"cache_age_s\": null\n}\n```\n\n> This request was run for real and returned `202`. `cache` is `miss` because no earlier job could answer it; see [Cache](#cache).\n\nOnly `url` is required. Keep the `id`: it is how you read the job.\n\n| Field | Default | What it does |\n| ---------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `url` | (required) | The site to discover. Only the scheme and host are used: a path, query string or fragment is accepted but ignored, and the `202` response carries a `warnings` entry saying so |\n| `strategy` | `standard` | `quick`, `standard` or `deep`: where ByteKit looks for URLs. See [Strategies](#strategies) |\n| `max_depth` | `2` | From 1 to 5. How many levels of page links a `deep` job follows |\n| `max_urls` | `5000` | From 1 to 100000. A new job stops collecting at this many URLs |\n| `process` | `null` | An object with an `action` and `options`. ByteKit accepts it and returns it on the job, and it has no other effect |\n| `compact` | `false` | `true` makes the results file a plain list of URLs, one per line, with no header |\n| `metadata` | none | An object of your own, up to 4096 bytes when serialized. It is returned on the job and in webhook deliveries. A key that starts with `_` is rejected with `422 validation_error` |\n| `webhook_url` | none | An `https://` URL to notify about the job. An `http://` URL is rejected with `400 invalid_url` and the reason `scheme_unsupported`. See [Webhooks](#webhooks) |\n| `webhook_secret` | `null` | Signs the webhook deliveries. It is ignored when there is no `webhook_url` |\n| `cache_ttl` | `30d` | How old a cached job may be and still answer the request. It is a string: `0`, hours such as `48h`, or days such as `30d`, up to 90 days. A number is rejected with `422 validation_error` |\n\nThe `202` response reports `url` after ByteKit has normalised it: the scheme and host are lowercased, an international host is in punycode, non-ASCII characters are percent-encoded, and surrounding spaces are trimmed. If the result is only a scheme and host, with or without a trailing `/`, it is returned as `scheme://host`. If it carries a path, query string or fragment, it is returned whole, together with the `warnings` entry. `GET` returns the host as `scheme://host`.\n\n## Strategies\n\n| Strategy | Where it looks |\n| ---------- | ---------------------------------------------------------------------------------------------------------------------------- |\n| `quick` | The sitemap files the site publishes. Every URL has the source `sitemap` |\n| `standard` | The same, plus URLs from your account's completed scrapes of the host in the last 90 days. These have the source `known` |\n| `deep` | The same as `standard`, plus URLs found by following links on pages, up to `max_depth` levels. These have the source `links` |\n\nThe sources run in that order, and each one fills only the room that `max_urls` leaves. A URL found by more than one source is counted once, under the first.\nA `deep` job follows links only from URLs the earlier sources found, so on a site with no sitemap files and no `known` URLs it finds no `links`.\nThe job's `sources` field counts the URLs per source. For a `deep` job run for real it read `{\"known\": 1, \"links\": 4, \"sitemap\": 119}`.\n\n## Check the job\n\n`GET /v1/sitemap/{id}` answers `200` with the job whatever its `status`: `pending`, `processing`, `completed` or `failed`. Poll it every few seconds until the status is `completed` or `failed`. The jobs on this page finished within a few seconds.\n\n```bash\ncurl -i https://api.bytekit.com/v1/sitemap/sm_c013b3fa71f94ff292f5c2fa74f8d77b \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n```json\n{\n \"id\": \"sm_c013b3fa71f94ff292f5c2fa74f8d77b\",\n \"url\": \"https://bytekit.com\",\n \"strategy\": \"quick\",\n \"max_depth\": 2,\n \"max_urls\": 20,\n \"status\": \"completed\",\n \"total_urls\": 20,\n \"sources\": { \"sitemap\": 20 },\n \"total_bytes\": 196,\n \"results_url\": \"https://…\",\n \"warnings\": [],\n \"error_code\": null,\n \"error_message\": null,\n \"compact\": false,\n \"process\": null,\n \"metadata\": null,\n \"created_at\": \"2026-10-10T14:59:44.602Z\",\n \"completed_at\": \"2026-10-10T14:59:47.405Z\",\n \"expires_at\": \"2027-01-08T14:59:47.405Z\",\n \"billing\": {\n \"factors\": [{ \"name\": \"endpoint\", \"value\": 1, \"reason\": \"sitemap\" }],\n \"raw_bytes\": 196,\n \"multiplier\": 1,\n \"billed_bytes\": 196\n }\n}\n```\n\n> This request was run for real and returned `200`. The signed `results_url` is shortened.\n\n| Field | Meaning |\n| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| `status` | `pending`, `processing`, `completed` or `failed` |\n| `total_urls` | How many URLs the results hold. `null` until the job completes |\n| `sources` | The URLs per source: `sitemap`, `known` or `links` |\n| `total_bytes` | The size in bytes of the gzip-compressed results file. This is what the job is billed on; see [Cost](#cost) |\n| `results_url` | A signed link to the results file, present once the job is `completed`. Each `GET` of a completed job returns a new link, valid for 7 days |\n| `warnings` | Notes about the run, such as a source that could not be read |\n| `error_code`, `error_message` | Why a job failed. `null` otherwise |\n| `billing` | What the job was billed: `raw_bytes`, the `factors` applied, the `multiplier` and `billed_bytes` |\n| `expires_at` | When the job expires: 90 days after it completes, except that a cache hit keeps the expiry of the job that answered it. `null` until the job completes |\n\nA completed `200` also carries the headers `X-Raw-Bytes`, `X-Billing-Multiplier` and `X-Billable-Bytes`, which show the same figures as `billing`.\n\n### When a job fails\n\n```bash\ncurl -i -X POST https://api.bytekit.com/v1/sitemap \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\", \"strategy\": \"quick\", \"max_urls\": 20}'\n```\n\n> This request was run for real and returned `202`, with the same fields as above and `cache` `miss`. The job then failed, and polling it returned `200`:\n\n```json\n{\n \"id\": \"sm_a380b0ea64dd4b19a854699c58933499\",\n \"url\": \"https://example.com\",\n \"strategy\": \"quick\",\n \"max_depth\": 2,\n \"max_urls\": 20,\n \"status\": \"failed\",\n \"total_urls\": null,\n \"sources\": null,\n \"total_bytes\": null,\n \"results_url\": null,\n \"warnings\": [\"robots.txt unavailable (non-success fetch)\"],\n \"error_code\": \"no_urls_found\",\n \"error_message\": \"No URLs discovered for this domain\",\n \"compact\": false,\n \"process\": null,\n \"metadata\": null,\n \"created_at\": \"2026-10-10T14:59:54.408Z\",\n \"completed_at\": \"2026-10-10T14:59:55.941Z\",\n \"expires_at\": null\n}\n```\n\nA `robots.txt` or sitemap file that ByteKit cannot read does not fail a job by itself. It adds an entry to `warnings`, and discovery goes on with the other sources. A sitemap file that is not there (`404` or `410`) or is empty adds no warning, and neither does a page that cannot be fetched while a `deep` job follows links.\nThese are the `error_code` values you may meet:\n\n| `error_code` | When |\n| ---------------- | ------------------------------------------------------------------------ |\n| `no_urls_found` | Discovery ended without finding a URL |\n| `blocked` | The site blocks ByteKit's requests, so discovery did not start |\n| `job_timeout` | The job did not finish in time |\n| `internal_error` | A failure on ByteKit's side |\n| `worker_crash` | The job stopped making progress, and ByteKit failed it after a long wait |\n\nA job that fails with `worker_crash` sends no `sitemap.failed` webhook, so poll the job as well as listening for the webhook.\n\n## Download the results\n\n```bash\ncurl --compressed \"$RESULTS_URL\"\n```\n\n```csv\nurl,source\nhttps://bytekit.com/docs/changelog,sitemap\nhttps://bytekit.com/docs,sitemap\nhttps://bytekit.com/docs/introduction,sitemap\n```\n\n> This request was run for real and returned `200`. The file holds a header and 20 rows, and the first rows are shown.\n\nThe results file is a gzip-compressed CSV, served with `Content-Encoding: gzip`, so `--compressed` makes curl decode it. A client that does not decode gzip receives the compressed bytes, and their count is `total_bytes`.\nIt has the header `url,source` and one row per discovered URL, and `source` is `sitemap`, `known` or `links`. In that format a URL that contains a comma is wrapped in double quotes.\nWith `compact: true` the file is a plain list of URLs, one per line, with no header. The `lastmod` and `depth` columns are not emitted.\n\n## Cache\n\nBefore it queues discovery, ByteKit looks for a completed job of your account that has the same scheme and host and the same `strategy`, that finished within `cache_ttl`, and whose `max_depth` and `max_urls` are at least the ones you sent.\nA job that was itself a cache hit is never matched, only the job that ran discovery is, so `cache_ttl` counts from when that job finished.\nThe `cache` field of the `202` response says what it found. `GET` leaves out `cache` and `cache_age_s`.\n\n| `cache` | Meaning |\n| -------- | ------------------------------------------------------------------------------------------------------------------------------- |\n| `miss` | No such job. A new job is queued |\n| `hit` | A job matched. The response is already `completed` and has a `results_url`, and `cache_age_s` is the age of that job in seconds |\n| `bypass` | `cache_ttl` is `0`, so the cache was not read and a new job is queued |\n\nSending the request above again a few seconds later returned a hit:\n\n```json\n{\n \"id\": \"sm_6aa7e5ea6a854f19976754b0fdc8f438\",\n \"url\": \"https://bytekit.com\",\n \"strategy\": \"quick\",\n \"max_depth\": 2,\n \"max_urls\": 20,\n \"status\": \"completed\",\n \"total_urls\": 20,\n \"sources\": { \"sitemap\": 20 },\n \"total_bytes\": 196,\n \"results_url\": \"https://…\",\n \"warnings\": null,\n \"error_code\": null,\n \"error_message\": null,\n \"compact\": false,\n \"process\": null,\n \"metadata\": null,\n \"created_at\": \"2026-10-10T14:59:53.441Z\",\n \"completed_at\": \"2026-10-10T14:59:53.440Z\",\n \"expires_at\": \"2027-01-08T14:59:47.405Z\",\n \"billing\": {\n \"factors\": [\n { \"name\": \"endpoint\", \"value\": 1, \"reason\": \"sitemap\" },\n { \"name\": \"cache_hit\", \"value\": 0.5, \"reason\": \"hit\" }\n ],\n \"raw_bytes\": 196,\n \"multiplier\": 0.5,\n \"billed_bytes\": 98\n },\n \"cache\": \"hit\",\n \"cache_age_s\": 6\n}\n```\n\n> This request was run for real and returned `202`. The signed `results_url` is shortened.\n\nA hit has an `id` of its own and points at the same results file as the job that answered it.\nThe file is returned as that job stored it. It can hold more URLs than the `max_urls` you sent, and it keeps the format that job was created with, whatever `compact` you send, because `compact` is not part of the match.\nThe `compact` field of a hit's response repeats your request, not the format of the file, so tell the format from the file: only a non-compact file starts with the header line `url,source`.\nTo get a new job that follows your request, send `cache_ttl` `0`.\n\n## Webhooks\n\nSend a `webhook_url` and ByteKit POSTs the outcome to it. The header `X-ByteKit-Event` is `sitemap.completed` when the job completes and `sitemap.failed` when it fails, so you can dispatch on the header without reading the body. A cache hit sends `sitemap.completed` as well. A failure that sends no `sitemap.failed` is described under [When a job fails](#when-a-job-fails).\nWithout a `webhook_url` the job is poll-only. Set `webhook_secret` to have the deliveries signed; see the [Webhooks guide](https://bytekit.com/docs/guides/webhooks) for verification. The [Scraping guide](https://bytekit.com/docs/guides/scraping#webhook-event-header) lists the other event types.\n\nThe body has two keys, `event`, which repeats the header, and `data`. This page shows no captured delivery, only the fields:\n\n| Event | `data` holds |\n| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |\n| `sitemap.completed` | `id`, `url`, `strategy`, `status`, `total_urls`, `sources`, `total_bytes`, `res\n\n---\n[Truncated to the 16384-byte per-page limit — this page is 21078 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/guides/sitemap]"
|
|
401
401
|
},
|
|
402
402
|
"guides/structured-extraction": {
|
|
403
403
|
"title": "Structured extraction",
|
|
@@ -39,7 +39,7 @@ export interface ScrapeStats {
|
|
|
39
39
|
tokens: number;
|
|
40
40
|
blocks: number;
|
|
41
41
|
}
|
|
42
|
-
export type ScrapeEnvelopeErrorCode = 'validation_error' | 'invalid_url' | 'request_too_large' | 'payload_too_large' | 'unsupported_content_type' | 'rate_limited' | 'upstream_error' | 'timeout' | 'blocked' | 'target_rate_limited' | 'internal_error';
|
|
42
|
+
export type ScrapeEnvelopeErrorCode = 'validation_error' | 'invalid_url' | 'request_too_large' | 'payload_too_large' | 'unsupported_content_type' | 'content_too_large' | 'rate_limited' | 'upstream_error' | 'timeout' | 'blocked' | 'target_rate_limited' | 'internal_error';
|
|
43
43
|
export interface ScrapeFormats {
|
|
44
44
|
/**
|
|
45
45
|
* The untouched upstream source of whatever the URL served — HTML, JSON, XML or
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hunt-labs/bytekit-mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.28",
|
|
4
4
|
"description": "ByteKit MCP server — exposes ByteKit web-data tools (scrape, screenshot, search, docs) to AI agents over the Model Context Protocol, hosted or as a local stdio server.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|