@hunt-labs/bytekit-mcp 0.2.5 → 0.2.7
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 +75 -0
- package/dist/cli.d.ts +22 -0
- package/dist/cli.js +68 -11
- package/dist/client.d.ts +8 -1
- package/dist/client.js +43 -11
- package/dist/docs-bundle/docs-bundle.json +52 -27
- package/dist/docs-bundle/helpers.d.ts +12 -2
- package/dist/docs-bundle/helpers.js +12 -2
- package/dist/lib/render-screenshot.js +11 -5
- package/dist/lib/scrape-formats.d.ts +36 -0
- package/dist/lib/scrape-formats.js +42 -0
- package/dist/scrape-contract.generated.d.ts +61 -6
- package/dist/tools/scrape-url.js +7 -20
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,81 @@ today, see [README.md](./README.md), which remains the authoritative usage guide
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [0.2.7] - 2026-08-18
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- **The generated scrape contract now carries the `billing` node** (#3139). `ScrapeSuccessEnvelope`
|
|
18
|
+
gained an optional `billing` object with `raw_bytes`, an ordered `factors` list of
|
|
19
|
+
`name`/`value`/`reason` entries, `multiplier` and `billed_bytes`. The factor list explains
|
|
20
|
+
exactly how a scrape's charge was composed — endpoint factor, cache-hit discount, clean-markdown
|
|
21
|
+
surcharge — and multiplies out to the `X-Billing-Multiplier` on the same response. The existing
|
|
22
|
+
flat `billing_multiplier` / `billed_bytes` pair is unchanged and still emitted beside it; this
|
|
23
|
+
release is a regeneration of the checked-in contract only, with no behavior change in the server
|
|
24
|
+
itself.
|
|
25
|
+
|
|
26
|
+
## [0.2.6] - 2026-08-12
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- **`scrape_url` now sends the public `raw_html` format spelling on the wire** (#2959). It
|
|
31
|
+
previously translated the `raw_html` an agent asks for into the gateway's internal `rawHtml`
|
|
32
|
+
before calling the API. That request only succeeded because the gateway happens to accept both
|
|
33
|
+
spellings — nothing in the published API contract promised it, so this server depended on an
|
|
34
|
+
undocumented leniency it could not see. It now sends what the spec documents.
|
|
35
|
+
|
|
36
|
+
**No change to what the tool accepts:** `raw_html` and the legacy `rawHtml` are both still
|
|
37
|
+
valid `formats` values, and results are rendered identically. The bundled `libraries/typescript`
|
|
38
|
+
doc page also gained the `search`, `usage` and `webhooks` resources it had been omitting.
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- The published docs bundle now includes the five billing guides linked from the pricing page:
|
|
43
|
+
balance, bandwidth, credits, spending, and top-ups. The guides describe the source-backed
|
|
44
|
+
charging, expiry, rollover, and quota behavior. (#2960)
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- A validation failure from the API now reaches the agent as `validation_error: <message>` from
|
|
49
|
+
every tool, instead of a bare `Invalid request body. ({"formErrors":[],"fieldErrors":{…}})`
|
|
50
|
+
with the error code stripped off. `scrape_url` and `screenshot_url` are the two tools
|
|
51
|
+
affected: the client's 422 handling rendered a screenshot's failed-capture body as
|
|
52
|
+
`code: message` but passed a validation envelope's message through verbatim, so which
|
|
53
|
+
spelling an agent saw depended on the HTTP status the endpoint happened to pick — the same
|
|
54
|
+
vocabulary already rendered `validation_error: …` on a 400. The field details are unchanged,
|
|
55
|
+
and so are `web_search`'s render, the concurrency-limit advice, and the 401/402 guidance
|
|
56
|
+
messages. (#2955)
|
|
57
|
+
- The hosted `/mcp` endpoint now rejects a missing or invalid API key with a JSON-RPC error body
|
|
58
|
+
(`{"jsonrpc":"2.0","error":{"code":-32000,…},"id":null}`, HTTP 401) rather than the REST
|
|
59
|
+
capture envelope, so an MCP host that parses `/mcp` responses as JSON-RPC can read the failure
|
|
60
|
+
it is most likely to hit. Every other transport-level failure on that endpoint already spoke
|
|
61
|
+
JSON-RPC (405 on GET/DELETE, `-32700` on a malformed body, 406 on `Accept`). The ByteKit code
|
|
62
|
+
(`invalid_api_key`) is preserved on JSON-RPC's `data` member, and the capture endpoints' 401
|
|
63
|
+
envelope is untouched. (#2955)
|
|
64
|
+
- The 26 SDK reference pages in the docs bundle (`sdk/python/*`, `sdk/typescript/*`) no longer
|
|
65
|
+
open with their title and description twice, so `get_doc` and `search_docs` stop spending
|
|
66
|
+
tokens on a duplicated preamble and search snippets stop reading doubled. The docs site's
|
|
67
|
+
LLM markdown composer prepended a synthesized `# <title>` + description block
|
|
68
|
+
unconditionally, on top of the generator-authored SDK bodies that already carry their own
|
|
69
|
+
H1 and intro paragraph; it now yields the title block to a body that leads with an H1. The
|
|
70
|
+
other 77 bundled pages are byte-identical. `sdk/python/client`'s body heading was also
|
|
71
|
+
aligned to its page title (`# Client Reference` → `# Client`), the one SDK page where the
|
|
72
|
+
two disagreed. (#2953)
|
|
73
|
+
- The screenshot render's signed-URL note no longer presents the plan's artifact-retention
|
|
74
|
+
date (`expires_at`, ~30 days out) as the signed image URL's expiry. The URL is a B2-signed
|
|
75
|
+
link that dies ~10 minutes after issue (`X-Amz-Expires=600`) regardless of retention; the
|
|
76
|
+
note now always states that ~600s signature expiry, so an agent following it no longer
|
|
77
|
+
stashes a link that reads as good for weeks and is already dead. `expires_at` itself is
|
|
78
|
+
untouched — it remains correct for plan retention everywhere else. (#2947)
|
|
79
|
+
- An unknown flag (e.g. `--bogus-flag`) or the space-form `--timeout-ms -5` (which
|
|
80
|
+
`node:util`'s `parseArgs` itself rejects as an ambiguous option value, before it ever
|
|
81
|
+
reaches the existing `--timeout-ms` validation) no longer crashes with a raw
|
|
82
|
+
`node:internal/util/parse_args` stack trace. Both now render the same one-line
|
|
83
|
+
`Error: ...` message the binary already used for `--help`, a missing API key, and the
|
|
84
|
+
equals-form/non-numeric `--timeout-ms` cases — parse-layer failures and value-validation
|
|
85
|
+
failures render through one error path. `--help`, the missing-key message, and the
|
|
86
|
+
existing `--timeout-ms abc` / `--timeout-ms=-5` errors are unchanged. (#2952)
|
|
87
|
+
|
|
13
88
|
## [0.2.5] - 2026-08-11
|
|
14
89
|
|
|
15
90
|
### Added
|
package/dist/cli.d.ts
CHANGED
|
@@ -61,7 +61,29 @@ export declare const TIMEOUT_MS_INVALID_MESSAGE = "Error: --timeout-ms must be a
|
|
|
61
61
|
* @throws {RangeError} when the flag is present but not a finite, non-negative number.
|
|
62
62
|
*/
|
|
63
63
|
export declare function resolveTimeoutMs(flag: string | undefined): number | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* True when `err` is the shape node:util's `parseArgs` throws for a parse-layer failure —
|
|
66
|
+
* unknown option, ambiguous/invalid option value, unexpected positional, etc. Every error
|
|
67
|
+
* parseArgs itself throws is a {@link TypeError} carrying a `code` in the `ERR_PARSE_ARGS_*`
|
|
68
|
+
* namespace (verified against Node's own `internal/util/parse_args` implementation).
|
|
69
|
+
*
|
|
70
|
+
* Exported so the classifier — not just its effect inside {@link main}'s catch — is directly
|
|
71
|
+
* testable (issue #2952 failure mode E1): `main`'s catch must handle only what this returns
|
|
72
|
+
* `true` for and rethrow everything else, never swallow an unrelated error into a graceful
|
|
73
|
+
* `exit(1)`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isParseArgsFailure(err: unknown): err is TypeError & {
|
|
76
|
+
code: string;
|
|
77
|
+
};
|
|
78
|
+
/** Appended to a parse-layer error's own message so the operator knows where to look next. */
|
|
79
|
+
export declare const PARSE_ARGS_USAGE_HINT = "Run 'bytekit-mcp --help' for usage.\n";
|
|
64
80
|
export declare const HELP_TEXT = "ByteKit MCP Server\n\nUsage:\n bytekit-mcp --api-key <key> [--base-url <url>] [--timeout-ms <ms>] [--verbose]\n\nOptions:\n --api-key ByteKit API key. Resolution order: --api-key flag, then\n BYTEKIT_API_KEY.\n --base-url API base URL. Resolution order: --base-url flag, then\n BYTEKIT_BASE_URL (default: https://api.bytekit.com)\n --timeout-ms Per-request timeout budget in milliseconds (default: 120000;\n 0 disables it)\n --verbose Log requests to stderr\n --help Show this help message\n";
|
|
81
|
+
/**
|
|
82
|
+
* Optional `argv` (defaulting to `process.argv.slice(2)`, parseArgs's own default) so tests
|
|
83
|
+
* can drive `main` with synthetic arg vectors without touching the real process argv (issue
|
|
84
|
+
* #2952).
|
|
85
|
+
*/
|
|
86
|
+
export declare function main(argv?: string[]): Promise<void>;
|
|
65
87
|
/**
|
|
66
88
|
* True when this module is the process entrypoint (run directly or via its bin),
|
|
67
89
|
* false when it is merely imported (e.g. the test suite exercising resolveApiKey).
|
package/dist/cli.js
CHANGED
|
@@ -74,6 +74,24 @@ export function resolveTimeoutMs(flag) {
|
|
|
74
74
|
}
|
|
75
75
|
return parsed;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* True when `err` is the shape node:util's `parseArgs` throws for a parse-layer failure —
|
|
79
|
+
* unknown option, ambiguous/invalid option value, unexpected positional, etc. Every error
|
|
80
|
+
* parseArgs itself throws is a {@link TypeError} carrying a `code` in the `ERR_PARSE_ARGS_*`
|
|
81
|
+
* namespace (verified against Node's own `internal/util/parse_args` implementation).
|
|
82
|
+
*
|
|
83
|
+
* Exported so the classifier — not just its effect inside {@link main}'s catch — is directly
|
|
84
|
+
* testable (issue #2952 failure mode E1): `main`'s catch must handle only what this returns
|
|
85
|
+
* `true` for and rethrow everything else, never swallow an unrelated error into a graceful
|
|
86
|
+
* `exit(1)`.
|
|
87
|
+
*/
|
|
88
|
+
export function isParseArgsFailure(err) {
|
|
89
|
+
return (err instanceof TypeError &&
|
|
90
|
+
typeof err.code === 'string' &&
|
|
91
|
+
err.code.startsWith('ERR_PARSE_ARGS_'));
|
|
92
|
+
}
|
|
93
|
+
/** Appended to a parse-layer error's own message so the operator knows where to look next. */
|
|
94
|
+
export const PARSE_ARGS_USAGE_HINT = "Run 'bytekit-mcp --help' for usage.\n";
|
|
77
95
|
export const HELP_TEXT = `ByteKit MCP Server
|
|
78
96
|
|
|
79
97
|
Usage:
|
|
@@ -89,17 +107,56 @@ Options:
|
|
|
89
107
|
--verbose Log requests to stderr
|
|
90
108
|
--help Show this help message
|
|
91
109
|
`;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Parses `argv` into the CLI's flags (`{ args: argv }` on top of the same option schema
|
|
112
|
+
* `main` has always used) — factored out purely so its return type can drive `values`'s
|
|
113
|
+
* declaration below without hand-duplicating the inferred shape.
|
|
114
|
+
*/
|
|
115
|
+
const parseCliArgs = (argv) => parseArgs({
|
|
116
|
+
args: argv,
|
|
117
|
+
options: {
|
|
118
|
+
'api-key': { type: 'string' },
|
|
119
|
+
'base-url': { type: 'string' },
|
|
120
|
+
'timeout-ms': { type: 'string' },
|
|
121
|
+
verbose: { type: 'boolean', default: false },
|
|
122
|
+
help: { type: 'boolean', default: false },
|
|
123
|
+
},
|
|
124
|
+
strict: true,
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* Optional `argv` (defaulting to `process.argv.slice(2)`, parseArgs's own default) so tests
|
|
128
|
+
* can drive `main` with synthetic arg vectors without touching the real process argv (issue
|
|
129
|
+
* #2952).
|
|
130
|
+
*/
|
|
131
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
132
|
+
let values;
|
|
133
|
+
try {
|
|
134
|
+
({ values } = parseCliArgs(argv));
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
// Issue #2952: an unknown flag or a value parseArgs itself rejects (e.g. the space-form
|
|
138
|
+
// `--timeout-ms -5`, which LOOKS like another flag to parseArgs and is consumed before
|
|
139
|
+
// resolveTimeoutMs below ever sees it) used to escape as a raw node:internal stack trace.
|
|
140
|
+
// Guard lives HERE, around the parseArgs call — not inside resolveTimeoutMs/resolveApiKey,
|
|
141
|
+
// whose contracts stay pure (Failure Mode E2).
|
|
142
|
+
if (!isParseArgsFailure(err)) {
|
|
143
|
+
// Not something parseArgs itself throws — never swallow an unrelated error into a
|
|
144
|
+
// graceful CLI exit (Failure Mode E1).
|
|
145
|
+
throw err;
|
|
146
|
+
}
|
|
147
|
+
if (err.code === 'ERR_PARSE_ARGS_INVALID_OPTION_VALUE' &&
|
|
148
|
+
err.message.includes("'--timeout-ms'")) {
|
|
149
|
+
// parseArgs rejected `--timeout-ms -5` (space form) as an ambiguous option value before
|
|
150
|
+
// resolveTimeoutMs ever ran. Render the IDENTICAL message resolveTimeoutMs uses for the
|
|
151
|
+
// equals-form/non-numeric cases (Precedence rule: parse-layer and value-validation
|
|
152
|
+
// failures for the same flag render through one message), rather than a generic one.
|
|
153
|
+
process.stderr.write(TIMEOUT_MS_INVALID_MESSAGE);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
process.stderr.write(`Error: ${err.message}\n${PARSE_ARGS_USAGE_HINT}`);
|
|
157
|
+
}
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}
|
|
103
160
|
if (values.help) {
|
|
104
161
|
process.stderr.write(HELP_TEXT);
|
|
105
162
|
process.exit(0);
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { Format, ScrapeEnvelope } from './scrape-contract.generated.js';
|
|
2
|
-
|
|
2
|
+
import type { PublicScrapeFormat } from './lib/scrape-formats.js';
|
|
3
|
+
/**
|
|
4
|
+
* The `formats` values this client puts ON THE WIRE — the PUBLIC spelling the API spec
|
|
5
|
+
* documents, not the gateway's internal `Format` (issue #2959). Derived from `Format`
|
|
6
|
+
* rather than written out, so a format added to the contract flows through here; only the
|
|
7
|
+
* raw-HTML member's spelling diverges between the two vocabularies.
|
|
8
|
+
*/
|
|
9
|
+
export type ScrapeFormat = Exclude<Format, 'rawHtml'> | PublicScrapeFormat;
|
|
3
10
|
export interface ScrapeParams {
|
|
4
11
|
url: string;
|
|
5
12
|
formats?: ScrapeFormat[] | undefined;
|
package/dist/client.js
CHANGED
|
@@ -460,21 +460,34 @@ export class BytekitClient {
|
|
|
460
460
|
// body is what carries the `ss_` handle and the rest of the resource, and reshaping
|
|
461
461
|
// it would move a wire contract the SDK, CLI and dashboard already read.
|
|
462
462
|
//
|
|
463
|
-
// Rendered as `code: message
|
|
464
|
-
// uses, so one 422 does not read differently from
|
|
465
|
-
// The code alone when `error_message` is null: the
|
|
466
|
-
// on, and a bare `null` would be worse than terse.
|
|
463
|
+
// Rendered as `code: message` by {@link renderCoded}, the same spelling the
|
|
464
|
+
// generic-envelope branch below uses, so one 422 does not read differently from
|
|
465
|
+
// every other server-coded error. The code alone when `error_message` is null: the
|
|
466
|
+
// code is the half the agent acts on, and a bare `null` would be worse than terse.
|
|
467
467
|
//
|
|
468
468
|
// Precedence: this wins over `envelope.message` because a resource body cannot
|
|
469
469
|
// populate it (its `message` key does not exist), so the two are never both present
|
|
470
|
-
// — a genuine validation 422 still carries the unified envelope and renders
|
|
471
|
-
//
|
|
470
|
+
// — a genuine validation 422 still carries the unified envelope and renders through
|
|
471
|
+
// the envelope arm below.
|
|
472
|
+
//
|
|
473
|
+
// ── The ENVELOPE 422 (issue #2955) ──
|
|
474
|
+
// Until #2955 that arm passed `envelope.message` through verbatim, so the comment
|
|
475
|
+
// above was false for the shape it named: a validation 422 reached the agent as a
|
|
476
|
+
// bare `Invalid request body. ({…})` with no code, while the SAME server vocabulary
|
|
477
|
+
// on a 400 (e.g. `/v1/search`, which documents no 422 at all) already rendered
|
|
478
|
+
// `validation_error: …` through the generic branch. Which spelling an agent saw was
|
|
479
|
+
// decided by the status the endpoint happened to choose. It now applies exactly the
|
|
480
|
+
// condition the generic branch uses — code AND message both present — so a 422 that
|
|
481
|
+
// carries no code cannot acquire one, and a flat `{ error: '<code>' }` 422 keeps the
|
|
482
|
+
// generic sentence it has had since #2541 E6.
|
|
472
483
|
const resource = envelope.resource;
|
|
473
484
|
const base = resource
|
|
474
|
-
? resource.message
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
485
|
+
? renderCoded(resource.code, resource.message)
|
|
486
|
+
: envelope.message === undefined
|
|
487
|
+
? 'Validation error.'
|
|
488
|
+
: envelope.code === undefined
|
|
489
|
+
? envelope.message
|
|
490
|
+
: renderCoded(envelope.code, envelope.message);
|
|
478
491
|
const detail = envelope.details !== undefined ? `${base} (${formatErrorDetails(envelope.details)})` : base;
|
|
479
492
|
// A sync-failed screenshot (POST /v1/screenshots -> 422) carries no `ss_` handle in
|
|
480
493
|
// the generic error body this branch parses (only message/details/code) -- the
|
|
@@ -503,7 +516,7 @@ export class BytekitClient {
|
|
|
503
516
|
// API envelope surfaces the server's own code + message so the agent can act
|
|
504
517
|
// on it (e.g. 503 `blocked`, 400 `invalid_url`, 404 `not_found`). ──
|
|
505
518
|
if (envelope.code !== undefined && envelope.message !== undefined) {
|
|
506
|
-
throw new BytekitApiError(
|
|
519
|
+
throw new BytekitApiError(renderCoded(envelope.code, envelope.message), status, envelope.code);
|
|
507
520
|
}
|
|
508
521
|
// ── Fallbacks: no parseable envelope. Report the status line, never a
|
|
509
522
|
// misleading retry hint (retrying a non-retryable failure won't help). ──
|
|
@@ -574,6 +587,25 @@ async function parseErrorEnvelope(response, signal) {
|
|
|
574
587
|
}
|
|
575
588
|
return parsed;
|
|
576
589
|
}
|
|
590
|
+
/**
|
|
591
|
+
* THE code-aware render (issue #2955): `code: message`, or the bare code when the server
|
|
592
|
+
* sent no message.
|
|
593
|
+
*
|
|
594
|
+
* Every branch of {@link BytekitClient.handleErrorResponse} that has BOTH a server code
|
|
595
|
+
* and a server message renders through here, so an agent reads one spelling for a coded
|
|
596
|
+
* API failure whatever status carried it. Tools render `error.message` verbatim and must
|
|
597
|
+
* not re-derive this shape in their own catch blocks (issue #2955, failure mode E2) —
|
|
598
|
+
* `web_search` is the one deliberate exception, and it appends rather than prepends only
|
|
599
|
+
* when the message does not already name the code (issue #2687 item 2).
|
|
600
|
+
*
|
|
601
|
+
* Not applied where the client REPLACES the server's prose with its own actionable advice
|
|
602
|
+
* — the 401/402 mappings (#2478) and the 429 species advice (#2681). Those messages are
|
|
603
|
+
* ByteKit's own sentences, not a server message to be labelled, and prefixing them would
|
|
604
|
+
* change copy that two earlier tickets wrote deliberately.
|
|
605
|
+
*/
|
|
606
|
+
function renderCoded(code, message) {
|
|
607
|
+
return message !== undefined ? `${code}: ${message}` : code;
|
|
608
|
+
}
|
|
577
609
|
/** Render an error `details` value as a compact human-readable string. */
|
|
578
610
|
function formatErrorDetails(details) {
|
|
579
611
|
if (typeof details === 'string')
|
|
@@ -244,6 +244,31 @@
|
|
|
244
244
|
"section": "API Reference",
|
|
245
245
|
"body": "# Retry a webhook delivery\n\nRequeues a failed or exhausted webhook delivery for another attempt.\n\n**Limits:** this endpoint takes no request body; any body sent is\ncapped at 64 KB. An oversized body returns a `400` with error code\n`request_too_large`.\n"
|
|
246
246
|
},
|
|
247
|
+
"billing/balance": {
|
|
248
|
+
"title": "Balance and exhausted quota",
|
|
249
|
+
"section": "General",
|
|
250
|
+
"body": "# Balance and exhausted quota\n\nWhat happens when a ByteKit bandwidth or credit balance reaches zero.\n\nByteKit checks the relevant balance before admitting billable work. Capture endpoints use the bandwidth balance; search uses the credit balance; schema extraction requires both.\n\nWhen a request would exceed an enforced balance, ByteKit returns **HTTP 402** with the error code `quota_exceeded`. The request does not continue as unpriced usage.\n\nThere is no automatic overage: availability is an explicit plan setting. The plan schema defaults `has_overage` to false, while some seeded subscription plans explicitly enable it. For credit-metered requests on an overage-enabled plan, a configured spending cap can permit or reject additional usage. Capture endpoints still enforce their bandwidth budget.\n\nTo continue after a hard balance stop, purchase a top-up or move to a plan with more included usage. Auto-top-up can purchase bandwidth before the configured threshold is crossed, but it must be enabled and configured in advance; reaching zero does not silently enable it.\n\nSee **Dashboard → Settings → Billing** for included usage, purchased and rollover balances, and auto-top-up status."
|
|
251
|
+
},
|
|
252
|
+
"billing/bandwidth": {
|
|
253
|
+
"title": "Bandwidth billing",
|
|
254
|
+
"section": "General",
|
|
255
|
+
"body": "# Bandwidth billing\n\nHow ByteKit measures billed bandwidth for capture and sitemap endpoints.\n\nByteKit bills most capture endpoints from bytes transferred over the upstream wire, not from the size of the final JSON, Markdown, image, or recording artifact. Sitemap jobs use the generated results artifact instead, as described below.\n\n## Upstream wire-byte endpoints\n\nFor scrape, fetch, crawl, and monitor requests, ByteKit applies one calculation and rounds once:\n\n```\nbilled bytes = round(upstream wire bytes × endpoint factor × cache factor × clean-Markdown factor)\n```\n\nThe endpoint factor depends on the work performed:\n\n| Endpoint | Factor |\n| --- | ---: |\n| Scrape | 1× |\n| Scrape with Markdown output | 1.5× |\n| Fetch | 1× |\n| Fetch with Markdown output | 1.5× |\n| Crawl | 1.5× |\n| Crawl links | 1× |\n| Monitor run | 1× |\n\nA cache hit contributes a **0.5×** factor. Successful clean-Markdown processing contributes a separate **3×** factor. These factors compose with the endpoint factor; they are not alternative rates.\n\n## Sitemap\n\nSitemap billing uses the byte length of the **gzip-compressed generated results CSV**. The worker builds the results CSV, compresses it, and uses that compressed length for the job's billed bytes and sitemap usage record.\n\nDiscovery fetch bytes are not accumulated into the sitemap charge. The charged byte count is the compressed results artifact, not the upstream bytes transferred while discovering URLs.\n\n## Other capture artifacts\n\nScreenshots and recordings use a separate capture basis: `phase1WireBytes × 1.5`, rounded to whole bytes. The 1.5× combines the upstream Phase 1 fetch with rendering overhead. If Phase 1 has no positive wire-byte measurement, that capture contributes zero billable bytes.\n\nYour current allowance, purchased bandwidth, rollover bandwidth, and remaining balance are shown under **Dashboard → Settings → Billing**."
|
|
256
|
+
},
|
|
257
|
+
"billing/credits": {
|
|
258
|
+
"title": "Credit billing",
|
|
259
|
+
"section": "General",
|
|
260
|
+
"body": "# Credit billing\n\nHow search and schema extraction consume credits.\n\nCredits pay for operations with a per-request or per-upstream-page cost. They are tracked separately from bandwidth.\n\n## Search\n\nSearch costs one credit for every upstream results page requested:\n\n```\npages = min(ceil(limit / 10), 10)\ncredits = pages\n```\n\nFor example, a limit of 10 costs one credit, a limit of 11 costs two credits, and limits up to 100 are capped at ten upstream pages and ten credits. The charge follows the requested limit even if an upstream page returns fewer results.\n\n## Schema extraction\n\nSchema extraction is dual-axis billing. Each request has a fixed **10-credit** extraction charge and also consumes bandwidth for its source-page fetch. ByteKit pre-charges an estimated 100 KiB for that fetch, then reconciles the bandwidth charge to the actual upstream wire bytes.\n\nIf the request fails before the source page is fetched, ByteKit compensates the credit and bandwidth pre-charges. Failures after the fetch may retain the source-page bandwidth charge because that upstream work was completed.\n\nYour effective credit budget includes plan credits, purchased credits, and any live rollover credits."
|
|
261
|
+
},
|
|
262
|
+
"billing/spending": {
|
|
263
|
+
"title": "Spending controls",
|
|
264
|
+
"section": "General",
|
|
265
|
+
"body": "# Spending controls\n\nHow spending caps and automatic bandwidth top-ups behave.\n\nByteKit has two distinct spending controls: a credit-overage cap and automatic bandwidth top-ups.\n\n## Credit-overage spending cap\n\nFor a credit-metered request on an overage-enabled plan, ByteKit compares the calculated overage cost with the account's `max_overage_spend_cents`. When the request would cross that limit, the API returns **HTTP 402** with `spending_cap_reached`.\n\nThe current billing page does not expose a self-service control for this account-level overage cap. Contact support if it must be changed.\n\n## Automatic bandwidth top-ups\n\nThe billing page lets an account administrator enable or disable auto-top-up and configure:\n\n- the remaining-bandwidth threshold that triggers a purchase;\n- the amount of bandwidth to purchase; and\n- an optional monthly top-up spending cap.\n\nThe trigger requires auto-top-up to be enabled and the account to have a Stripe customer. When remaining included bandwidth falls below the configured threshold, ByteKit queues a top-up. A stored monthly cap of zero means no cap; the API and dashboard present that state as no configured cap.\n\nThese controls do not configure purchased-balance expiration. See [Top-ups](https://bytekit.com/docs/billing/top-ups) for the expiry and rollover rules enforced by the billing ledger."
|
|
266
|
+
},
|
|
267
|
+
"billing/top-ups": {
|
|
268
|
+
"title": "Top-ups and rollover",
|
|
269
|
+
"section": "General",
|
|
270
|
+
"body": "# Top-ups and rollover\n\nHow purchased bandwidth and credits expire, carry across periods, and are consumed.\n\nTop-ups add bandwidth or credits without changing your plan's included allowance. The billing ledger records each purchase as its own lot and consumes eligible lots as billable work exceeds included and rollover allowances.\n\n## Expiration\n\nPurchased top-up lots expire **180 days after the payment provider object was created**. This expiry is fixed by the billing service; it is not configurable in the dashboard. Expired lots are removed from the active purchased balance and cannot fund new usage.\n\nThat source-backed rule supersedes older wording that described top-ups as never expiring or said their expiration could be configured.\n\n## Billing-period rollover\n\nMonthly plan allowances reset with the billing period. Purchased value is maintained in the billing ledger rather than being limited to the `account_usage_periods` row where the purchase first appeared; the current period's `topup_bytes` and `topup_credits` fields are projections of eligible, unexpired lot balances.\n\nCredit rollover is also live: credits present in the current period's `rollover_credits` field are included in the enforced credit budget together with included and purchased credits. Rollover is consumed before a top-up lot is charged. The presence of this budget field does not make top-up expiry configurable and does not extend a purchased lot beyond its 180-day expiry.\n\nYour current purchased and rollover balances appear under **Dashboard → Settings → Billing**."
|
|
271
|
+
},
|
|
247
272
|
"changelog": {
|
|
248
273
|
"title": "Changelog",
|
|
249
274
|
"section": "General",
|
|
@@ -347,7 +372,7 @@
|
|
|
347
372
|
"libraries/typescript": {
|
|
348
373
|
"title": "TypeScript SDK",
|
|
349
374
|
"section": "Libraries",
|
|
350
|
-
"body": "# TypeScript SDK\n\nType-safe ByteKit client for Node.js and modern JavaScript runtimes.\n\nThe official TypeScript SDK is a thin, type-safe wrapper over the ByteKit REST API. It works\nin Node.js and any runtime with a global `fetch` (Bun, Deno, Cloudflare Workers, modern\nbrowsers).\n\n## Install\n\n```bash\nnpm install @hunt-labs/bytekit-sdk\n```\n\n## Initialize\n\n```ts\nimport { ByteKit } from '@hunt-labs/bytekit-sdk';\n\nconst client = new ByteKit({\n apiKey: process.env.BYTEKIT_API_KEY!, // your sk_live_… key\n});\n```\n\n## Your first scrape\n\n```ts\nconst result = await client.scrape.create({\n url: 'https://example.com',\n formats: ['markdown'],\n});\n\nconsole.log(result);\n```\n\n## Capture a screenshot\n\n```ts\nconst shot = await client.screenshots.create({\n url: 'https://example.com',\n full_page: true,\n});\n\nconsole.log(shot);\n```\n\n## Handle errors\n\nAny 4xx/5xx response throws a `ByteKitError` carrying the HTTP `status` and the API\n`error.code`:\n\n```ts\nimport { ByteKit, ByteKitError } from '@hunt-labs/bytekit-sdk';\n\ntry {\n await client.scrape.create({ url: 'https://example.com' });\n} catch (err) {\n if (err instanceof ByteKitError) {\n console.error(`${err.status} ${err.code}: ${err.message}`);\n } else {\n throw err;\n }\n}\n```\n\n## Async scrapes\n\nPass `async: true` to enqueue the job and poll by ID:\n\n```ts\nconst queued = await client.scrape.create({ url: 'https://example.com', async: true });\n// later — poll with the returned sc_… id\nconst final = await client.scrape.get('sc_...');\n```\n\n## What's available\n\nThe client exposes one resource per capability: `scrape`, `screenshots`, `bulk`,\n`fetch`, `monitors`, `sitemap`,
|
|
375
|
+
"body": "# TypeScript SDK\n\nType-safe ByteKit client for Node.js and modern JavaScript runtimes.\n\nThe official TypeScript SDK is a thin, type-safe wrapper over the ByteKit REST API. It works\nin Node.js and any runtime with a global `fetch` (Bun, Deno, Cloudflare Workers, modern\nbrowsers).\n\n## Install\n\n```bash\nnpm install @hunt-labs/bytekit-sdk\n```\n\n## Initialize\n\n```ts\nimport { ByteKit } from '@hunt-labs/bytekit-sdk';\n\nconst client = new ByteKit({\n apiKey: process.env.BYTEKIT_API_KEY!, // your sk_live_… key\n});\n```\n\n## Your first scrape\n\n```ts\nconst result = await client.scrape.create({\n url: 'https://example.com',\n formats: ['markdown'],\n});\n\nconsole.log(result);\n```\n\n## Capture a screenshot\n\n```ts\nconst shot = await client.screenshots.create({\n url: 'https://example.com',\n full_page: true,\n});\n\nconsole.log(shot);\n```\n\n## Handle errors\n\nAny 4xx/5xx response throws a `ByteKitError` carrying the HTTP `status` and the API\n`error.code`:\n\n```ts\nimport { ByteKit, ByteKitError } from '@hunt-labs/bytekit-sdk';\n\ntry {\n await client.scrape.create({ url: 'https://example.com' });\n} catch (err) {\n if (err instanceof ByteKitError) {\n console.error(`${err.status} ${err.code}: ${err.message}`);\n } else {\n throw err;\n }\n}\n```\n\n## Async scrapes\n\nPass `async: true` to enqueue the job and poll by ID:\n\n```ts\nconst queued = await client.scrape.create({ url: 'https://example.com', async: true });\n// later — poll with the returned sc_… id\nconst final = await client.scrape.get('sc_...');\n```\n\n## What's available\n\nThe client exposes one resource per capability: `scrape`, `screenshots`, `bulk`,\n`fetch`, `monitors`, `sitemap`, `search`, `account`, `usage`, and `webhooks` (each with\n`create` / `get` / `list` methods as applicable, plus nested resources like `scrape.bulk`\nand `monitors.captures`).\n\nSee the [TypeScript SDK Reference](https://bytekit.com/docs/sdk/typescript/client) for every method and option.\n\n## Next steps\n\n- [Python SDK](https://bytekit.com/docs/libraries/python) — the same API surface in Python.\n- [API Reference](https://bytekit.com/docs/api) — the underlying REST endpoints.\n- [Errors](https://bytekit.com/docs/guides/errors) — error codes and retry guidance."
|
|
351
376
|
},
|
|
352
377
|
"mcp": {
|
|
353
378
|
"title": "MCP Server",
|
|
@@ -362,131 +387,131 @@
|
|
|
362
387
|
"sdk/python/account": {
|
|
363
388
|
"title": "Account",
|
|
364
389
|
"section": "SDK Reference",
|
|
365
|
-
"body": "# Account\n\
|
|
390
|
+
"body": "# Account\n\nFunctions for interacting with the `account` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Get Account\n\nGet account details\n\nReturns account, plan, and current API key details, including the\n`api_key` and `subscription` fields.\n\n**Call styles**\n\n```python\nsync_detailed(client=client) -> Response[Union[Error, Union['AccountBearerResponse', 'AccountSessionResponse']]]\nsync(client=client) -> Optional[Union[Error, Union['AccountBearerResponse', 'AccountSessionResponse']]]\nawait asyncio_detailed(client=client) -> Response[Union[Error, Union['AccountBearerResponse', 'AccountSessionResponse']]]\nawait asyncio(client=client) -> Optional[Union[Error, Union['AccountBearerResponse', 'AccountSessionResponse']]]\n```"
|
|
366
391
|
},
|
|
367
392
|
"sdk/python/bulk": {
|
|
368
393
|
"title": "Bulk",
|
|
369
394
|
"section": "SDK Reference",
|
|
370
|
-
"body": "# Bulk\n\
|
|
395
|
+
"body": "# Bulk\n\nFunctions for interacting with the `bulk` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Bulk\n\nCreate mixed bulk job\n\nEnqueues screenshots or scrapes in a single batch.\nProvide `urls` (simple list) or `items` (per-item config), not both.\nWebhook deliveries include `X-ByteKit-Event: bulk.completed` so\nreceivers can dispatch on the header without parsing the body shape.\n\n**Limits:** request bodies are guarded in a two-tier shape. A streamed body\nwith no `Content-Length` header is capped at 4 MB before your API key\nis checked; a body that declares `Content-Length` is instead bounded\nthere by a 32 MB fail-safe (not the real limit — see below), since\nthat branch reads nothing until your key is verified. Once your key\nis verified, a second check re-gates the body against your account's\nown `max_bulk_size` (at this endpoint's richer per-item override\nbudget), which reaches 28.7 MB for the largest documented account. A\nstandard-plan account's effective ceiling is 4 MB; either tier's\noverrun returns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `body (CreateBulkBody): Provide `urls` (simple list) OR `items` (per-item config), not`\n- `both. `type` selects the capture kind per entry — only`\n- ``screenshot` and `scrape` are accepted (`recording` is`\n- `deactivated). Behaviour fields may be set per item or via`\n- ``defaults`; a per-item value overrides the matching default.`\n- `This includes `type`: an entry with no `type` of its own`\n- `inherits `defaults.type`, falling back to `screenshot` only`\n- `when neither is set.`\n- `The top-level object, each `items[]` entry, and `defaults``\n- `each reject unrecognized keys with a 422 `validation_error``\n- `(the offending key name appears in the error's `details``\n- `message text) rather than silently discarding them.`\n- ``items[]` and `defaults` do not share one field set`\n- ``device_scale_factor` is accepted only under `defaults` (a`\n- `per-item value 422s), and `duration`/`scenario` are accepted`\n- `only per item (a `defaults` value 422s). `metadata` is`\n- `different from those three: it is valid both at the top`\n- `level of the body and per item, but rejected with a 422 if`\n- `placed under `defaults`. See the `422` response below.`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[CreateBulkResponse202, Error]]\nsync(client=client, body=body) -> Optional[Union[CreateBulkResponse202, Error]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[CreateBulkResponse202, Error]]\nawait asyncio(client=client, body=body) -> Optional[Union[CreateBulkResponse202, Error]]\n```\n\n## Delete Bulk\n\nCancel a bulk job\n\nCancels an in-flight bulk job: drains its still-queued (pending) child jobs and refunds the quota\nheld for exactly those drained children. Children already completed, failed, or in progress are\nuntouched and keep their charge. Idempotent — cancelling an already-terminal job (completed, failed,\nor cancelled) is a no-op that returns 200 with the job's real, unchanged status and refunds nothing.\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[DeleteBulkResponse200, Error]]\nsync(id=id, client=client) -> Optional[Union[DeleteBulkResponse200, Error]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[DeleteBulkResponse200, Error]]\nawait asyncio(id=id, client=client) -> Optional[Union[DeleteBulkResponse200, Error]]\n```\n\n## Get Bulk\n\nGet bulk job status\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[Error, GetBulkResponse200]]\nsync(id=id, client=client) -> Optional[Union[Error, GetBulkResponse200]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[Error, GetBulkResponse200]]\nawait asyncio(id=id, client=client) -> Optional[Union[Error, GetBulkResponse200]]\n```\n\n## List Bulk Screenshots\n\nList bulk job items\n\nReturns the bulk job's items, discriminated by `type`.\n\n**Downloading item artifacts.** `image_url` (`type: screenshot`) and both\n`content_url` and `markdown_url` (`type: scrape`) are **pre-signed** URLs,\nminted fresh on every read of this endpoint and valid for **600 seconds\n(10 minutes)** —\nthe same signing lifetime as `content_url` on `GET /v1/fetch/bulk/\\{id\\}`.\nThe underlying objects are private, so an unsigned URL returns `401`:\ndownload inside that window, or re-poll this endpoint for a fresh\nsignature. Items that are not `completed`, and completed items with no\nstored object, carry `null` or the unsigned stored URL instead.\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[ListBulkScreenshotsResponse200]\nsync(id=id, client=client) -> Optional[ListBulkScreenshotsResponse200]\nawait asyncio_detailed(id=id, client=client) -> Response[ListBulkScreenshotsResponse200]\nawait asyncio(id=id, client=client) -> Optional[ListBulkScreenshotsResponse200]\n```"
|
|
371
396
|
},
|
|
372
397
|
"sdk/python/client": {
|
|
373
398
|
"title": "Client",
|
|
374
399
|
"section": "SDK Reference",
|
|
375
|
-
"body": "# Client\n\
|
|
400
|
+
"body": "# Client\n\nThe ByteKit Python SDK provides two client classes for making API requests.\n\n## Client\n\nA class for keeping track of data related to the API\n\nThe following are accepted as keyword arguments and will be used to construct httpx Clients internally:\n\n``base_url``: The base URL for the API, all requests are made to a relative path to this URL\n\n``cookies``: A dictionary of cookies to be sent with every request\n\n``headers``: A dictionary of headers to be sent with every request\n\n``timeout``: The maximum amount of a time a request can take. API functions will raise\nhttpx.TimeoutException if this is exceeded. A connection that never gets established at\nall — DNS failure, refused connection, TLS handshake failure — raises its transport\nsibling httpx.ConnectError instead. Neither is caught by this SDK: both propagate to the\ncaller, on the generated operations and on ``AuthenticatedClient.search`` alike.\n\n``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,\nbut can be set to False for testing purposes.\n\n``follow_redirects``: Whether or not to follow redirects. Default value is False.\n\n``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.\n\nAttributes:\nraise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a\nstatus code that was not documented in the source OpenAPI document. Can also be provided as a keyword\nargument to the constructor.\nExplicit constructor arguments always win over these defaults (explicit arg > default).\n\n### with_headers\n\n```python\nwith_headers(headers: dict[str, str]) -> 'Client'\n```\n\nGet a new client matching this one with additional headers\n\n### with_cookies\n\n```python\nwith_cookies(cookies: dict[str, str]) -> 'Client'\n```\n\nGet a new client matching this one with additional cookies\n\n### with_timeout\n\n```python\nwith_timeout(timeout: httpx.Timeout) -> 'Client'\n```\n\nGet a new client matching this one with a new timeout (in seconds)\n\n### set_httpx_client\n\n```python\nset_httpx_client(client: httpx.Client) -> 'Client'\n```\n\nManually set the underlying httpx.Client\n\n**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.\n\n### get_httpx_client\n\n```python\nget_httpx_client() -> httpx.Client\n```\n\nGet the underlying httpx.Client, constructing a new one if not previously set\n\n### set_async_httpx_client\n\n```python\nset_async_httpx_client(async_client: httpx.AsyncClient) -> 'Client'\n```\n\nManually the underlying httpx.AsyncClient\n\n**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.\n\nA client set here is YOURS to manage: the SDK never rebuilds or closes it, even if\nit is later used from a different event loop. Clients the SDK constructs itself are\nrebuilt automatically when the running event loop changes.\n\n### get_async_httpx_client\n\n```python\nget_async_httpx_client() -> httpx.AsyncClient\n```\n\nGet the underlying httpx.AsyncClient, constructing a new one if not previously set\n\n## AuthenticatedClient\n\nA Client which has been authenticated for use on secured endpoints\n\nThe following are accepted as keyword arguments and will be used to construct httpx Clients internally:\n\n``base_url``: The base URL for the API, all requests are made to a relative path to this URL\n\n``cookies``: A dictionary of cookies to be sent with every request\n\n``headers``: A dictionary of headers to be sent with every request\n\n``timeout``: The maximum amount of a time a request can take. API functions will raise\nhttpx.TimeoutException if this is exceeded. A connection that never gets established at\nall — DNS failure, refused connection, TLS handshake failure — raises its transport\nsibling httpx.ConnectError instead. Neither is caught by this SDK: both propagate to the\ncaller, on the generated operations and on ``AuthenticatedClient.search`` alike.\n\n``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,\nbut can be set to False for testing purposes.\n\n``follow_redirects``: Whether or not to follow redirects. Default value is False.\n\n``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.\n\nAttributes:\nraise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a\nstatus code that was not documented in the source OpenAPI document. Can also be provided as a keyword\nargument to the constructor.\nExplicit constructor arguments always win over these defaults (explicit arg > default).\ntoken: The token to use for authentication. KEYWORD-ONLY.\nprefix: The prefix to use for the Authorization header. KEYWORD-ONLY.\nauth_header_name: The name of the Authorization header. KEYWORD-ONLY.\nAll three are keyword-only so that the pre-0.3.0 positional call\n``AuthenticatedClient(base_url, token)`` raises TypeError instead of\nsilently binding the base URL to ``token`` and the API key to ``prefix``.\n\n### search\n\n```python\nsearch(query: str, type: Optional[Union['CreateSearchBodyType', Literal['web', 'news', 'images']]] = None, limit: Optional[int] = None, country: Optional[str] = None, language: Optional[str] = None, date_range: Optional[Union['CreateSearchBodyDateRange', Literal['any', 'hour', 'day', 'week', 'month', 'year']]] = None) -> 'CreateSearchResponse200'\n```\n\nRun a web search and return ranked organic results.\n\nThin, statically-declared delegate to the hand-written ``_search`` appended at the\nbottom of this module; the full contract (argument semantics, the\n``errors.UnexpectedStatus`` guarantee) is documented there.\n\n### with_headers\n\n```python\nwith_headers(headers: dict[str, str]) -> 'AuthenticatedClient'\n```\n\nGet a new client matching this one with additional headers\n\n### with_cookies\n\n```python\nwith_cookies(cookies: dict[str, str]) -> 'AuthenticatedClient'\n```\n\nGet a new client matching this one with additional cookies\n\n### with_timeout\n\n```python\nwith_timeout(timeout: httpx.Timeout) -> 'AuthenticatedClient'\n```\n\nGet a new client matching this one with a new timeout (in seconds)\n\n### set_httpx_client\n\n```python\nset_httpx_client(client: httpx.Client) -> 'AuthenticatedClient'\n```\n\nManually set the underlying httpx.Client\n\n**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.\n\n### get_httpx_client\n\n```python\nget_httpx_client() -> httpx.Client\n```\n\nGet the underlying httpx.Client, constructing a new one if not previously set\n\n### set_async_httpx_client\n\n```python\nset_async_httpx_client(async_client: httpx.AsyncClient) -> 'AuthenticatedClient'\n```\n\nManually the underlying httpx.AsyncClient\n\n**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.\n\nA client set here is YOURS to manage: the SDK never rebuilds or closes it, even if\nit is later used from a different event loop. Clients the SDK constructs itself are\nrebuilt automatically when the running event loop changes.\n\n### get_async_httpx_client\n\n```python\nget_async_httpx_client() -> httpx.AsyncClient\n```\n\nGet the underlying httpx.AsyncClient, constructing a new one if not previously set"
|
|
376
401
|
},
|
|
377
402
|
"sdk/python/fetch": {
|
|
378
403
|
"title": "Fetch",
|
|
379
404
|
"section": "SDK Reference",
|
|
380
|
-
"body": "# Fetch\n\
|
|
405
|
+
"body": "# Fetch\n\nFunctions for interacting with the `fetch` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Get Fetch\n\nFetch a URL (GET)\n\nDirect HTTP fetch. The response body IS the content; metadata is returned in X-Fetch-* headers.\nOmit `format` for raw passthrough. Use `format=markdown` or `format=html` for conversion.\n\n**Parameters**\n\n- `url_query (str)`\n- `format_ (Union[Unset, GetFetchFormat])`\n- `country (Union[Unset, str])`\n- `timeout_ms (Union[Unset, int])`\n- `cache_ttl (Union[GetFetchCacheTtlType1, Unset, str])`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, url_query=url_query, format_=format_, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Response[Union[Error, str]]\nsync(client=client, url_query=url_query, format_=format_, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Optional[Union[Error, str]]\nawait asyncio_detailed(client=client, url_query=url_query, format_=format_, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Response[Union[Error, str]]\nawait asyncio(client=client, url_query=url_query, format_=format_, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Optional[Union[Error, str]]\n```\n\n## Post Fetch\n\nFetch a URL (POST)\n\nSame as GET /v1/fetch but with a JSON request body.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `body (FetchRequest)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[Error, str]]\nsync(client=client, body=body) -> Optional[Union[Error, str]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[Error, str]]\nawait asyncio(client=client, body=body) -> Optional[Union[Error, str]]\n```"
|
|
381
406
|
},
|
|
382
407
|
"sdk/python/fetch-bulk": {
|
|
383
408
|
"title": "Fetch Bulk",
|
|
384
409
|
"section": "SDK Reference",
|
|
385
|
-
"body": "# Fetch Bulk\n\
|
|
410
|
+
"body": "# Fetch Bulk\n\nFunctions for interacting with the `fetch_bulk` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Fetch Bulk\n\nBulk fetch URLs\n\nEnqueues multiple URLs for HTTP fetching. Results delivered via webhook.\nDoes not support options that require page rendering (cookies, wait_for_selector, etc.).\n\n**Limits:** request bodies are guarded in a two-tier shape. A streamed body\nwith no `Content-Length` header is capped at 2 MB before your API key\nis checked; a body that declares `Content-Length` is instead bounded\nthere by a 20 MB fail-safe (not the real limit — see below), since\nthat branch reads nothing until your key is verified. Once your key\nis verified, a second check re-gates the body against your account's\nown `max_bulk_size` (at this endpoint's per-item override budget),\nwhich reaches 16.8 MB for the largest documented account. A\nstandard-plan account's effective ceiling is 2 MB; either tier's\noverrun returns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `body (CreateFetchBulkBody)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[CreateFetchBulkResponse202, Error]]\nsync(client=client, body=body) -> Optional[Union[CreateFetchBulkResponse202, Error]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[CreateFetchBulkResponse202, Error]]\nawait asyncio(client=client, body=body) -> Optional[Union[CreateFetchBulkResponse202, Error]]\n```\n\n## Get Fetch Bulk\n\nGet fetch bulk job status\n\nReturns the job envelope plus its per-URL items.\n\n**Downloading item content.** Each completed item's `content_url` is a\n**pre-signed** URL, minted fresh on every read of this endpoint and valid\nfor **600 seconds (10 minutes)** — the same signing lifetime as the\n`image_url` returned by `GET /v1/bulk/\\{id\\}/screenshots`. The underlying\nobjects are private, so an unsigned URL returns `401`: download the\ncontent inside that window, or re-poll this endpoint for a fresh\nsignature. Items that are not `completed`, and completed items with no\nstored object, carry `null` or the unsigned stored URL instead.\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[Error, GetFetchBulkResponse200]]\nsync(id=id, client=client) -> Optional[Union[Error, GetFetchBulkResponse200]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[Error, GetFetchBulkResponse200]]\nawait asyncio(id=id, client=client) -> Optional[Union[Error, GetFetchBulkResponse200]]\n```"
|
|
386
411
|
},
|
|
387
412
|
"sdk/python/monitors": {
|
|
388
413
|
"title": "Monitors",
|
|
389
414
|
"section": "SDK Reference",
|
|
390
|
-
"body": "# Monitors\n\
|
|
415
|
+
"body": "# Monitors\n\nFunctions for interacting with the `monitors` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\nFirst-capture behavior is the same for both monitor types: the first capture is a silent baseline (`has_change=False`, `change_pct=None`) with no `change_detected` webhook, whether the monitor is `scrape` or `screenshot`. From the second capture onward both types diff against the previous capture.\n\n## Create Monitor\n\nCreate a change-detection monitor\n\nCreates a recurring change-detection monitor for a URL, delivering results via webhook.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `body (MonitorCreateRequest)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[Error, MonitorCreateResponse]]\nsync(client=client, body=body) -> Optional[Union[Error, MonitorCreateResponse]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[Error, MonitorCreateResponse]]\nawait asyncio(client=client, body=body) -> Optional[Union[Error, MonitorCreateResponse]]\n```\n\n## Delete Monitor\n\nCancel monitor\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[Any, Error]]\nsync(id=id, client=client) -> Optional[Union[Any, Error]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[Any, Error]]\nawait asyncio(id=id, client=client) -> Optional[Union[Any, Error]]\n```\n\n## Get Monitor\n\nGet monitor\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[Error, MonitorResponse]]\nsync(id=id, client=client) -> Optional[Union[Error, MonitorResponse]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[Error, MonitorResponse]]\nawait asyncio(id=id, client=client) -> Optional[Union[Error, MonitorResponse]]\n```\n\n## List Monitor Captures\n\nList monitor captures\n\n**Parameters**\n\n- `id (str)`\n- `limit (Union[Unset, int])`\n- `cursor (Union[Unset, str])`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client, limit=limit, cursor=cursor) -> Response[ListMonitorCapturesResponse200]\nsync(id=id, client=client, limit=limit, cursor=cursor) -> Optional[ListMonitorCapturesResponse200]\nawait asyncio_detailed(id=id, client=client, limit=limit, cursor=cursor) -> Response[ListMonitorCapturesResponse200]\nawait asyncio(id=id, client=client, limit=limit, cursor=cursor) -> Optional[ListMonitorCapturesResponse200]\n```\n\n## List Monitors\n\nList monitors\n\n**Parameters**\n\n- `limit (Union[Unset, int])`\n- `cursor (Union[Unset, str])`\n- `status (Union[Unset, ListMonitorsStatus])`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, limit=limit, cursor=cursor, status=status) -> Response[ListMonitorsResponse200]\nsync(client=client, limit=limit, cursor=cursor, status=status) -> Optional[ListMonitorsResponse200]\nawait asyncio_detailed(client=client, limit=limit, cursor=cursor, status=status) -> Response[ListMonitorsResponse200]\nawait asyncio(client=client, limit=limit, cursor=cursor, status=status) -> Optional[ListMonitorsResponse200]\n```\n\n## Update Monitor\n\nUpdate monitor\n\n**Parameters**\n\n- `id (str)`\n- `body (MonitorUpdateRequest)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client, body=body) -> Response[Union[Error, MonitorResponse]]\nsync(id=id, client=client, body=body) -> Optional[Union[Error, MonitorResponse]]\nawait asyncio_detailed(id=id, client=client, body=body) -> Response[Union[Error, MonitorResponse]]\nawait asyncio(id=id, client=client, body=body) -> Optional[Union[Error, MonitorResponse]]\n```"
|
|
391
416
|
},
|
|
392
417
|
"sdk/python/scrape": {
|
|
393
418
|
"title": "Scrape",
|
|
394
419
|
"section": "SDK Reference",
|
|
395
|
-
"body": "# Scrape\n\
|
|
420
|
+
"body": "# Scrape\n\nFunctions for interacting with the `scrape` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Scrape\n\nScrape a URL\n\nFetches and processes a URL, returning content in one or more formats wrapped in a ScrapeEnvelope.\nMost requests return synchronously in under a second; requests needing a full page render return\nHTTP 202 and complete asynchronously.\n\n**Parameters**\n\n- `body (ScrapeRequest)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[Error, ScrapeQueuedEnvelope, ScrapeSuccessEnvelope]]\nsync(client=client, body=body) -> Optional[Union[Error, ScrapeQueuedEnvelope, ScrapeSuccessEnvelope]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[Error, ScrapeQueuedEnvelope, ScrapeSuccessEnvelope]]\nawait asyncio(client=client, body=body) -> Optional[Union[Error, ScrapeQueuedEnvelope, ScrapeSuccessEnvelope]]\n```\n\n## Get Scrape\n\nGet scrape result\n\nAlways returns 200. Check the `status` discriminator for the scrape state.\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[Error, Union['ScrapeErrorEnvelope', 'ScrapeQueuedEnvelope', 'ScrapeSuccessEnvelope']]]\nsync(id=id, client=client) -> Optional[Union[Error, Union['ScrapeErrorEnvelope', 'ScrapeQueuedEnvelope', 'ScrapeSuccessEnvelope']]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[Error, Union['ScrapeErrorEnvelope', 'ScrapeQueuedEnvelope', 'ScrapeSuccessEnvelope']]]\nawait asyncio(id=id, client=client) -> Optional[Union[Error, Union['ScrapeErrorEnvelope', 'ScrapeQueuedEnvelope', 'ScrapeSuccessEnvelope']]]\n```"
|
|
396
421
|
},
|
|
397
422
|
"sdk/python/scrape-bulk": {
|
|
398
423
|
"title": "Scrape Bulk",
|
|
399
424
|
"section": "SDK Reference",
|
|
400
|
-
"body": "# Scrape Bulk\n\
|
|
425
|
+
"body": "# Scrape Bulk\n\nFunctions for interacting with the `scrape_bulk` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Scrape Bulk\n\nBulk scrape URLs\n\nEnqueues multiple URLs for scraping. Results delivered via webhook.\nWebhook deliveries include `X-ByteKit-Event: scrape.completed` or\n`X-ByteKit-Event: scrape.failed` so receivers can dispatch on the\nheader without parsing the body shape.\n\n**Parameters**\n\n- `body (CreateScrapeBulkBody)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[CreateScrapeBulkResponse202, Error]]\nsync(client=client, body=body) -> Optional[Union[CreateScrapeBulkResponse202, Error]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[CreateScrapeBulkResponse202, Error]]\nawait asyncio(client=client, body=body) -> Optional[Union[CreateScrapeBulkResponse202, Error]]\n```\n\n## Get Scrape Bulk\n\nGet scrape bulk job status\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[Error, GetScrapeBulkResponse200]]\nsync(id=id, client=client) -> Optional[Union[Error, GetScrapeBulkResponse200]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[Error, GetScrapeBulkResponse200]]\nawait asyncio(id=id, client=client) -> Optional[Union[Error, GetScrapeBulkResponse200]]\n```"
|
|
401
426
|
},
|
|
402
427
|
"sdk/python/screenshots": {
|
|
403
428
|
"title": "Screenshots",
|
|
404
429
|
"section": "SDK Reference",
|
|
405
|
-
"body": "# Screenshots\n\
|
|
430
|
+
"body": "# Screenshots\n\nFunctions for interacting with the `screenshots` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Screenshot\n\nCapture a screenshot\n\nSync by default (holds up to 28s). Pass `?async=true` to return 202 immediately.\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**Parameters**\n\n- `async_ (Union[Unset, bool])`\n- `body (ScreenshotRequest)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body, async_=async_) -> Response[Union[Error, ScreenshotResponse, Union['Error', 'ScreenshotResponse']]]\nsync(client=client, body=body, async_=async_) -> Optional[Union[Error, ScreenshotResponse, Union['Error', 'ScreenshotResponse']]]\nawait asyncio_detailed(client=client, body=body, async_=async_) -> Response[Union[Error, ScreenshotResponse, Union['Error', 'ScreenshotResponse']]]\nawait asyncio(client=client, body=body, async_=async_) -> Optional[Union[Error, ScreenshotResponse, Union['Error', 'ScreenshotResponse']]]\n```\n\n## Get Screenshot\n\nGet screenshot status\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[Error, ScreenshotResponse, Union['Error', 'ScreenshotResponse']]]\nsync(id=id, client=client) -> Optional[Union[Error, ScreenshotResponse, Union['Error', 'ScreenshotResponse']]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[Error, ScreenshotResponse, Union['Error', 'ScreenshotResponse']]]\nawait asyncio(id=id, client=client) -> Optional[Union[Error, ScreenshotResponse, Union['Error', 'ScreenshotResponse']]]\n```"
|
|
406
431
|
},
|
|
407
432
|
"sdk/python/search": {
|
|
408
433
|
"title": "Search",
|
|
409
434
|
"section": "SDK Reference",
|
|
410
|
-
"body": "# Search\n\
|
|
435
|
+
"body": "# Search\n\nFunctions for interacting with the `search` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Search\n\nSearch the web\n\nRuns a web search for `query` and returns ranked organic results with\ncontiguous `position` values from 1.\n\nUse `limit` (1–100, default 10) to request more results in a single\ncall. Results are fetched in pages of 10, so a call consumes\n`ceil(limit / 10)` credits (capped at 10) from the account's monthly\ncredits bucket — for example `limit=10` costs 1 credit and `limit=35`\ncosts 4. Credits are charged for every page fetched regardless of how\nmany results a page returns. The credit count is reported as\n`credits_used` in the response.\n\n**Parameters**\n\n- `body (CreateSearchBody)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[CreateSearchResponse200, CreateSearchResponse502, Error]]\nsync(client=client, body=body) -> Optional[Union[CreateSearchResponse200, CreateSearchResponse502, Error]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[CreateSearchResponse200, CreateSearchResponse502, Error]]\nawait asyncio(client=client, body=body) -> Optional[Union[CreateSearchResponse200, CreateSearchResponse502, Error]]\n```"
|
|
411
436
|
},
|
|
412
437
|
"sdk/python/sitemap": {
|
|
413
438
|
"title": "Sitemap",
|
|
414
439
|
"section": "SDK Reference",
|
|
415
|
-
"body": "# Sitemap\n\
|
|
440
|
+
"body": "# Sitemap\n\nFunctions for interacting with the `sitemap` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Sitemap\n\nDiscover 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\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `body (SitemapRequest)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[Error, SitemapResponse]]\nsync(client=client, body=body) -> Optional[Union[Error, SitemapResponse]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[Error, SitemapResponse]]\nawait asyncio(client=client, body=body) -> Optional[Union[Error, SitemapResponse]]\n```\n\n## Get Sitemap\n\nGet sitemap job status\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[Error, SitemapResponse]]\nsync(id=id, client=client) -> Optional[Union[Error, SitemapResponse]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[Error, SitemapResponse]]\nawait asyncio(id=id, client=client) -> Optional[Union[Error, SitemapResponse]]\n```"
|
|
416
441
|
},
|
|
417
442
|
"sdk/python/usage": {
|
|
418
443
|
"title": "Usage",
|
|
419
444
|
"section": "SDK Reference",
|
|
420
|
-
"body": "# Usage\n\
|
|
445
|
+
"body": "# Usage\n\nFunctions for interacting with the `usage` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Get Usage\n\nGet current billing period usage\n\n**Call styles**\n\n```python\nsync_detailed(client=client) -> Response[GetUsageResponse200]\nsync(client=client) -> Optional[GetUsageResponse200]\nawait asyncio_detailed(client=client) -> Response[GetUsageResponse200]\nawait asyncio(client=client) -> Optional[GetUsageResponse200]\n```\n\n## Get Usage By Endpoint\n\nGet per-endpoint bandwidth breakdown\n\nReturns bandwidth usage broken down by endpoint (screenshots, recordings, scrape, scrape_md, fetch,\nfetch_md, crawl, crawl_links, sitemap, monitors) for a date range. Each row carries raw bytes, the\nbilling multiplier, and billable bytes. Endpoints with zero raw bytes for the range are omitted from\n`rows`; `totals` is always present. Default range is the last 30 days; max 366 days.\n\n**Parameters**\n\n- `from_ (Union[Unset, datetime.date])`\n- `to (Union[Unset, datetime.date])`\n- `api_key (Union[Unset, str])`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, from_=from_, to=to, api_key=api_key) -> Response[GetUsageByEndpointResponse200]\nsync(client=client, from_=from_, to=to, api_key=api_key) -> Optional[GetUsageByEndpointResponse200]\nawait asyncio_detailed(client=client, from_=from_, to=to, api_key=api_key) -> Response[GetUsageByEndpointResponse200]\nawait asyncio(client=client, from_=from_, to=to, api_key=api_key) -> Optional[GetUsageByEndpointResponse200]\n```\n\n## Get Usage Daily\n\nGet daily usage breakdown\n\nDefault range is last 30 days. Max range is 366 days.\n\n**Parameters**\n\n- `from_ (Union[Unset, datetime.date])`\n- `to (Union[Unset, datetime.date])`\n- `api_key (Union[Unset, str])`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, from_=from_, to=to, api_key=api_key) -> Response[GetUsageDailyResponse200]\nsync(client=client, from_=from_, to=to, api_key=api_key) -> Optional[GetUsageDailyResponse200]\nawait asyncio_detailed(client=client, from_=from_, to=to, api_key=api_key) -> Response[GetUsageDailyResponse200]\nawait asyncio(client=client, from_=from_, to=to, api_key=api_key) -> Optional[GetUsageDailyResponse200]\n```"
|
|
421
446
|
},
|
|
422
447
|
"sdk/python/webhooks": {
|
|
423
448
|
"title": "Webhooks",
|
|
424
449
|
"section": "SDK Reference",
|
|
425
|
-
"body": "# Webhooks\n\
|
|
450
|
+
"body": "# Webhooks\n\nFunctions for interacting with the `webhooks` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## List Webhook Deliveries\n\nList webhook deliveries\n\n**Parameters**\n\n- `limit (Union[Unset, int])`\n- `cursor (Union[Unset, str])`\n- `status (Union[Unset, ListWebhookDeliveriesStatus])`\n- `since (Union[Unset, datetime.datetime])`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, limit=limit, cursor=cursor, status=status, since=since) -> Response[ListWebhookDeliveriesResponse200]\nsync(client=client, limit=limit, cursor=cursor, status=status, since=since) -> Optional[ListWebhookDeliveriesResponse200]\nawait asyncio_detailed(client=client, limit=limit, cursor=cursor, status=status, since=since) -> Response[ListWebhookDeliveriesResponse200]\nawait asyncio(client=client, limit=limit, cursor=cursor, status=status, since=since) -> Optional[ListWebhookDeliveriesResponse200]\n```\n\n## Retry Webhook Delivery\n\nRetry a webhook delivery\n\nRequeues a failed or exhausted webhook delivery for another attempt.\n\n**Limits:** this endpoint takes no request body; any body sent is\ncapped at 64 KB. An oversized body returns a `400` with error code\n`request_too_large`.\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[Error, WebhookDeliveryResponse]]\nsync(id=id, client=client) -> Optional[Union[Error, WebhookDeliveryResponse]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[Error, WebhookDeliveryResponse]]\nawait asyncio(id=id, client=client) -> Optional[Union[Error, WebhookDeliveryResponse]]\n```"
|
|
426
451
|
},
|
|
427
452
|
"sdk/typescript/account": {
|
|
428
453
|
"title": "Account",
|
|
429
454
|
"section": "SDK Reference",
|
|
430
|
-
"body": "# Account\n\nAccount info and API key management
|
|
455
|
+
"body": "# Account\n\nAccount info and API key management. Accessed via `client.account`.\n\n## get\n\n```ts\nclient.account.get(requestOptions?: RequestOptions): Promise<GetAccountResponse>\n```\n\nGET /v1/account — get the authenticated account.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default.\n\n## apiKeys\n\n### create\n\n```ts\nclient.account.apiKeys.create(opts?: CreateApiKeyRequest, requestOptions?: RequestOptions): Promise<CreateApiKeyResponse>\n```\n\nPOST /v1/account/api-keys — create a new API key.\n\n`opts` is optional: the spec declares the request body itself as optional,\nso `create()` with no arguments is valid and sends no body.\n\n### list\n\n```ts\nclient.account.apiKeys.list(requestOptions?: RequestOptions): Promise<ListApiKeysResponse>\n```\n\nGET /v1/account/api-keys — list all API keys for the account\n\n### get\n\n```ts\nclient.account.apiKeys.get(id: ApiKeyId, requestOptions?: RequestOptions): Promise<GetApiKeyResponse>\n```\n\nGET /v1/account/api-keys/\\{id\\} — get an API key by ID\n\n### update\n\n```ts\nclient.account.apiKeys.update(id: ApiKeyId, opts: UpdateApiKeyRequest, requestOptions?: RequestOptions): Promise<UpdateApiKeyResponse>\n```\n\nPATCH /v1/account/api-keys/\\{id\\} — update an API key\n\n### revoke\n\n```ts\nclient.account.apiKeys.revoke(id: ApiKeyId, requestOptions?: RequestOptions): Promise<void>\n```\n\nDELETE /v1/account/api-keys/\\{id\\} — revoke an API key (idempotent).\n\nReturns 204 No Content: `operations['revokeApiKey']['responses'][204]`\ndeclares `content?: never`, so there is no JSON arm to derive a payload\nfrom — hence `Promise<void>`.\n\n`client.request()` short-circuits an empty body (204 or any empty response)\nto `undefined` before it would parse the body as JSON (#2450), so this\nmethod resolves cleanly on the gateway's empty 204 body.\n\n### reveal\n\n```ts\nclient.account.apiKeys.reveal(id: ApiKeyId, requestOptions?: RequestOptions): Promise<RevealApiKeyResponse>\n```\n\nPOST /v1/account/api-keys/\\{id\\}/reveal — reveal the plaintext API key value"
|
|
431
456
|
},
|
|
432
457
|
"sdk/typescript/bulk": {
|
|
433
458
|
"title": "Bulk",
|
|
434
459
|
"section": "SDK Reference",
|
|
435
|
-
"body": "# Bulk\n\nFan out many URLs in parallel with per-item webhooks
|
|
460
|
+
"body": "# Bulk\n\nFan out many URLs in parallel with per-item webhooks. Accessed via `client.bulk`.\n\n## create\n\n```ts\nclient.bulk.create(opts: BulkCreateRequest, requestOptions?: RequestOptions): Promise<BulkCreateResponse>\n```\n\nPOST /v1/bulk — create a bulk screenshots job.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default.\n\n## get\n\n```ts\nclient.bulk.get(id: BulkId, requestOptions?: RequestOptions): Promise<BulkGetResponse>\n```\n\nGET /v1/bulk/\\{id\\} — get a bulk job status\n\n## cancel\n\n```ts\nclient.bulk.cancel(id: BulkId, requestOptions?: RequestOptions): Promise<BulkCancelResponse>\n```\n\nDELETE /v1/bulk/\\{id\\} — cancel an in-flight bulk job\n\n## screenshots\n\n### list\n\n```ts\nclient.bulk.screenshots.list(id: BulkId, requestOptions?: RequestOptions): Promise<ListBulkScreenshotsResponse>\n```\n\nGET /v1/bulk/\\{id\\}/screenshots — list screenshots in a bulk job"
|
|
436
461
|
},
|
|
437
462
|
"sdk/typescript/client": {
|
|
438
463
|
"title": "Client",
|
|
439
464
|
"section": "SDK Reference",
|
|
440
|
-
"body": "# Client\n\
|
|
465
|
+
"body": "# Client\n\nThe ByteKit TypeScript SDK is a thin, type-safe wrapper over the REST API. Create a\n client with your API key, then call resource methods.\n\n```ts\nimport { ByteKit } from '@hunt-labs/bytekit-sdk';\n\nconst client = new ByteKit({\n apiKey: process.env.BYTEKIT_API_KEY!, // your sk_live_… key\n});\n```\n\n## Options (`ByteKitOptions`)\n\n- `apiKey` (required) — `string`\n- `baseUrl` — `string` Defaults to `https://api.bytekit.com`.\n- `timeoutMs` — `number` — Default CLIENT-SIDE request timeout in ms — the abort budget for the whole HTTP\nround-trip made by this SDK, covering time-to-headers **and** the response body\nread (so a large legitimate body counts against it too). `0` disables the SDK-side\ntimeout. Default 120000.\n\nNOT the same thing as `ScrapeOpts.timeout_ms`, which is the SERVER-side budget the\ngateway applies to the scrape itself. Override per call with\n`RequestOptions.requestTimeoutMs`.\n\n## Resources\n\nThe client exposes one property per resource:\n\n- [`client.scrape`](https://bytekit.com/docs/sdk/typescript/scrape) — Fetch a URL as raw HTML, clean markdown, or structured content.\n- [`client.screenshots`](https://bytekit.com/docs/sdk/typescript/screenshots) — Capture full-page or viewport screenshots.\n- [`client.bulk`](https://bytekit.com/docs/sdk/typescript/bulk) — Fan out many URLs in parallel with per-item webhooks.\n- [`client.fetch`](https://bytekit.com/docs/sdk/typescript/fetch) — Low-latency raw HTTP fetch with optional conversion.\n- [`client.monitors`](https://bytekit.com/docs/sdk/typescript/monitors) — Watch a URL on a schedule and webhook on change.\n- [`client.sitemap`](https://bytekit.com/docs/sdk/typescript/sitemap) — Discover URLs from a domain's sitemap or by crawling.\n- [`client.search`](https://bytekit.com/docs/sdk/typescript/search) — Run a web search and return ranked organic results.\n- [`client.account`](https://bytekit.com/docs/sdk/typescript/account) — Account info and API key management.\n- [`client.usage`](https://bytekit.com/docs/sdk/typescript/usage) — Billing-period and daily usage breakdowns.\n- [`client.webhooks`](https://bytekit.com/docs/sdk/typescript/webhooks) — List and retry webhook deliveries.\n\n## Errors\n\nAny non-2xx response throws a `ByteKitError` carrying the HTTP `status` and the API `code`.\n\n```ts\nimport { ByteKit, ByteKitError } from '@hunt-labs/bytekit-sdk';\n\ntry {\n await client.scrape.create({ url: 'https://example.com' });\n} catch (err) {\n if (err instanceof ByteKitError) {\n console.error(`${err.status} ${err.code}: ${err.message}`);\n }\n}\n```"
|
|
441
466
|
},
|
|
442
467
|
"sdk/typescript/fetch": {
|
|
443
468
|
"title": "Fetch",
|
|
444
469
|
"section": "SDK Reference",
|
|
445
|
-
"body": "# Fetch\n\nLow-latency raw HTTP fetch with optional conversion
|
|
470
|
+
"body": "# Fetch\n\nLow-latency raw HTTP fetch with optional conversion. Accessed via `client.fetch`.\n\n## create\n\n```ts\nclient.fetch.create(opts: FetchOpts, requestOptions?: RequestOptions): Promise<FetchResult>\n```\n\nPOST /v1/fetch — fetch URL content via POST body.\n\nResolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.\nThe body is returned verbatim — a JSON-serving upstream comes back as the\nraw JSON string, not a parsed object.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`. It matters most here: the gateway's own ceiling for a\nfetch is 60 s, so without a per-call budget a slow upstream holds the caller for\nthe constructor default (2 minutes) rather than a duration the caller chose.\n\n## get\n\n```ts\nclient.fetch.get(opts: FetchGetOpts, requestOptions?: RequestOptions): Promise<FetchResult>\n```\n\nGET /v1/fetch — fetch URL content via query params.\n\nResolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.\n\nAccepts only the five params the spec declares for this endpoint. `custom`\n(#2481) and the `markdown_*` / `with_*` tuning fields (#2539) are POST-body\noptions with no GET query param — they were silently dropped by this builder,\nso they are now compile errors instead. Use `create()` (POST) for those.\n\nThe query string is built by iterating `FETCH_GET_QUERY_KEYS`, the same list\n`FetchGetOpts` is derived from, so every accepted option is necessarily\nserialized.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`. As on `create`, the gateway's own ceiling for a fetch is\n60 s, so a per-call budget is what keeps a slow upstream from holding the caller\nfor the constructor default.\n\n## Options (`FetchOpts`)\n\n- `url` (required) — `string`\n- `format` — `'markdown' | 'html'` — Output format. `'markdown'` runs the HTML→markdown pipeline; `'html'` returns raw HTML. Narrowed to the spec union — off-spec values (e.g. `'pdf'`) are rejected at compile time.\n- `country` — `string`\n- `timeout_ms` — `number`\n- `markdown_mode` — `'article' | 'raw' | 'llm'` — Markdown processing mode. Only used when `format=markdown`. article/raw/llm.\n- `markdown_query` — `string` — BM25 query string for relevance-ranked filtering. Only used when `format=markdown`.\n- `markdown_links` — `'inline' | 'references' | 'none' | 'text'` — Link rendering style. Only used when `format=markdown`.\n- `markdown_images` — `'inline' | 'references' | 'none' | 'text'` — Image retention mode. Only used when `format=markdown`.\n- `with_links_summary` — `boolean` — Append a `Links:` footer to the markdown output. Only used when `format=markdown`.\n- `with_images_summary` — `boolean` — Append an `Images:` footer to the markdown output. Only used when `format=markdown`.\n- `markdown_compact` — `boolean` — Compact whitespace output. Only used when `format=markdown`.\n- `markdown_filter_images` — `boolean` — Filter low-signal images. Only used when `format=markdown`.\n- `markdown_include_media` — `boolean` — When true, `formats.links`/`formats.images` return rich objects and a top-level `tables` array is included. Only used when `format=markdown`.\n- `markdown_include_warnings` — `boolean` — When true, enables markdown-pipeline and tag-filter warnings for affected html/markdown requests.\n- `markdown_include_stats` — `boolean` — When true, includes a top-level `stats` object (chars, tokens, blocks). Only used when `format=markdown`.\n- `cache_ttl` — `string | 0` — How long a freshly fetched URL may be served from cache. Matches the\nOpenAPI `FetchRequest.cache_ttl` schema: a duration string (`\"48h\"`,\n`\"2d\"`, up to `168h` / `7d`) or the integer `0` to disable caching.\nDefaults to `\"48h\"` server-side when omitted.\n- `custom` — `Record<string, unknown>` — User-supplied JSON payload, base64-encoded into the `X-Fetch-Custom`\nresponse header so callers can correlate the response to caller-side\nstate. Capped at 4096 UTF-8 bytes after JSON serialization. Does NOT\naffect cache-key inputs."
|
|
446
471
|
},
|
|
447
472
|
"sdk/typescript/fetch-bulk": {
|
|
448
473
|
"title": "Fetch Bulk",
|
|
449
474
|
"section": "SDK Reference",
|
|
450
|
-
"body": "# Fetch Bulk\n\nCreate and poll bulk fetch jobs
|
|
475
|
+
"body": "# Fetch Bulk\n\nCreate and poll bulk fetch jobs. Accessed via `client.fetch.bulk`.\n\n## create\n\n```ts\nclient.fetch.bulk.create(opts: FetchBulkCreateRequest, requestOptions?: RequestOptions): Promise<FetchBulkCreateResponse>\n```\n\nPOST /v1/fetch/bulk — create a bulk fetch job\n\n## get\n\n```ts\nclient.fetch.bulk.get(id: BulkId, requestOptions?: RequestOptions): Promise<FetchBulkGetResponse>\n```\n\nGET /v1/fetch/bulk/\\{id\\} — get a bulk fetch job"
|
|
451
476
|
},
|
|
452
477
|
"sdk/typescript/monitors": {
|
|
453
478
|
"title": "Monitors",
|
|
454
479
|
"section": "SDK Reference",
|
|
455
|
-
"body": "# Monitors\n\nWatch a URL on a schedule and webhook on change
|
|
480
|
+
"body": "# Monitors\n\nWatch a URL on a schedule and webhook on change. Accessed via `client.monitors`.\n\n## create\n\n```ts\nclient.monitors.create(opts: MonitorCreateRequest, requestOptions?: RequestOptions): Promise<MonitorCreateResponse>\n```\n\nPOST /v1/monitors — create a page-change monitor (screenshot or scrape capture).\nFirst-capture behavior is the same for both types: the first capture is a silent baseline (has_change=false, change_pct=null) with no change_detected webhook, whether the monitor is `scrape` or `screenshot`. From the second capture onward both types diff against the previous capture.\n\n## list\n\n```ts\nclient.monitors.list(params?: ListMonitorsParams, requestOptions?: RequestOptions): Promise<ListMonitorsResponse>\n```\n\nGET /v1/monitors — list monitors for the account.\n\n`params` is optional and each key is omitted-when-absent, so `list()` with no argument\nserializes the bare `/v1/monitors` URL unchanged — existing zero-arg callers are unaffected.\n\n## get\n\n```ts\nclient.monitors.get(id: MonitorId, requestOptions?: RequestOptions): Promise<MonitorResponse>\n```\n\nGET /v1/monitors/\\{id\\} — get a monitor by ID\n\n## update\n\n```ts\nclient.monitors.update(id: MonitorId, opts: MonitorUpdateRequest, requestOptions?: RequestOptions): Promise<UpdateMonitorResponse>\n```\n\nPATCH /v1/monitors/\\{id\\} — update a monitor\n\n## delete\n\n```ts\nclient.monitors.delete(id: MonitorId, requestOptions?: RequestOptions): Promise<void>\n```\n\nDELETE /v1/monitors/\\{id\\} — delete a monitor.\n\nReturns 204 No Content (`operations['deleteMonitor']['responses'][204]`\ndeclares `content?: never`), so there is no JSON arm to derive a payload\nfrom — hence `Promise<void>`. `client.request()` short-circuits the empty\nbody to `undefined` before it would parse as JSON (#2450).\n\n## captures\n\n### list\n\n```ts\nclient.monitors.captures.list(id: MonitorId, params?: ListMonitorCapturesParams, requestOptions?: RequestOptions): Promise<ListMonitorCapturesResponse>\n```\n\nGET /v1/monitors/\\{id\\}/captures — list captures for a monitor.\n\n`params` is optional and each key is omitted-when-absent (#2594), so `list(id)` with no\nsecond argument serializes the bare `/v1/monitors/\\{id\\}/captures` URL unchanged — existing\nzero-arg callers are unaffected (inverse case)."
|
|
456
481
|
},
|
|
457
482
|
"sdk/typescript/scrape": {
|
|
458
483
|
"title": "Scrape",
|
|
459
484
|
"section": "SDK Reference",
|
|
460
|
-
"body": "# Scrape\n\nFetch a URL as raw HTML, clean markdown, or structured content
|
|
485
|
+
"body": "# Scrape\n\nFetch a URL as raw HTML, clean markdown, or structured content. Accessed via `client.scrape`.\n\n## create\n\n```ts\nclient.scrape.create(opts: ScrapeOpts, requestOptions?: RequestOptions): Promise<ScrapeCreateResponse>\n```\n\nPOST /v1/scrape — create a scrape job.\n\nResolves to the 200 success envelope, or the 202 queued envelope when\n`async: true`. Narrow on `status` before reading the result.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default. They\nare a different axis from `opts.timeout_ms`, which is the SERVER-side scrape budget.\n\n## get\n\n```ts\nclient.scrape.get(id: ScrapeId, requestOptions?: RequestOptions): Promise<ScrapeGetResponse>\n```\n\nGET /v1/scrape/\\{id\\} — poll a scrape by ID\n\n## Options (`ScrapeOpts`)\n\n- `url` (required) — `string`\n- `formats` — `Array<'raw_html' | 'html' | 'markdown' | 'links' | 'images'>`\n- `country` — `string`\n- `cookies` — `ScrapeCookie[]` — Cookies to set before loading the page. `name` and `value` are required (spec `Cookie` schema).\n- `headers` — `Record<string, string>`\n- `delay_ms` — `number`\n- `timeout_ms` — `number` — SERVER-side scrape budget in ms — how long the gateway may spend on the scrape itself. For the CLIENT-side abort budget (when this SDK gives up on the wire), see `RequestOptions.requestTimeoutMs`.\n- `async` — `boolean`\n- `webhook_url` — `string`\n- `events` — `Array<'queued' | 'completed' | 'failed'>`\n- `markdown_mode` — `MarkdownMode` — Markdown processing mode. article=article extraction (default), raw=minimal cleanup, llm=compact LLM-optimised output.\n- `markdown_query` — `string` — BM25 query string for relevance-ranked content filtering. Omit or leave empty to disable.\n- `markdown_links` — `MarkdownLinks` — Link rendering style in the markdown output.\n- `markdown_images` — `MarkdownImages` — Image retention mode in the markdown output. Distinct from `markdown_filter_images` (which drops low-signal images before conversion).\n- `with_links_summary` — `boolean` — When true, appends a `Links:` footer to the markdown output. Automatically enabled when `markdown_links` is `'references'`.\n- `with_images_summary` — `boolean` — When true, appends an `Images:` footer to the markdown output.\n- `markdown_compact` — `boolean` — Collapse excessive whitespace for a more compact output.\n- `markdown_filter_images` — `boolean` — Filter low-signal images from the markdown output.\n- `markdown_include_media` — `boolean` — When true, `formats.links` and `formats.images` return `ScrapeScoredLink[]` / `ScrapeScoredImage[]` (rich objects) instead of `string[]`, and a top-level `tables` array is included. Only effective when `markdown` is in `formats`.\n- `markdown_include_warnings` — `boolean` — When true, the response includes markdown-pipeline and tag-filter warnings. `artifact_unavailable` may appear independently when a requested persisted format cannot be rehydrated.\n- `markdown_include_stats` — `boolean` — When true, the response includes a top-level `stats` object with `ScrapeStats` (chars, tokens, blocks). Only effective when `markdown` is in `formats`.\n- `token_budget` — `number` — Maximum token count for the markdown output. Truncates at the last paragraph → sentence → token boundary under the limit. Absent → no truncation.\n- `token_encoding` — `TokenEncoding` — Tokenizer encoding hint for `token_budget`. `cl100k_base` (default) matches GPT-4/4o; `o200k_base` matches GPT-4o-mini / o-series.\n- `mobile` — `boolean` — When true, emulate a mobile device (mobile UA + viewport). Default false (desktop). Part of the cache key, so mobile and desktop responses cache independently.\n- `remove_base64_images` — `boolean` — When true (default), base64-encoded `data:` image sources are stripped before markdown conversion and from `html` output. Set false to preserve them. Does not affect `raw_html`.\n- `include_tags` — `string[]` — HTML element names (not CSS selectors) to keep. When non-empty, only content within these elements is included in `html`/`markdown` output. Applied before `exclude_tags`. Does not affect `raw_html`.\n- `exclude_tags` — `string[]` — HTML element names (not CSS selectors) to strip from `html`/`markdown` output. Applied after `include_tags`. Does not affect `raw_html`.\n- `clean_markdown` — `boolean` — When true and `markdown` is in `formats`, the converted markdown is sent to Groq for cleaning before return. Graceful degradation on any Groq failure. Billing: 3× credits and bytes applied only when cleaning succeeds.\n- `cache_ttl` — `string | 0` — How long a freshly fetched URL may be served from cache. `'0'`/`0` skips the\ncache read (the result is still written), `'Nh'`/`'Nd'` set a TTL (capped at\n168h / 7d). Default `'48h'`. Honoured on both the synchronous and asynchronous\npaths; the async success envelope reports the outcome via the `cache` field.\n- `custom` — `Record<string, unknown>` — User-supplied JSON payload, echoed back on the success envelope so callers\ncan correlate the response to caller-side state (job IDs, batch metadata).\nCapped at 4096 UTF-8 bytes after JSON serialization. Does NOT affect\ncache-key inputs — two requests differing only in `custom` share the same\ncache slot."
|
|
461
486
|
},
|
|
462
487
|
"sdk/typescript/scrape-bulk": {
|
|
463
488
|
"title": "Scrape Bulk",
|
|
464
489
|
"section": "SDK Reference",
|
|
465
|
-
"body": "# Scrape Bulk\n\nCreate and poll bulk scrape jobs
|
|
490
|
+
"body": "# Scrape Bulk\n\nCreate and poll bulk scrape jobs. Accessed via `client.scrape.bulk`.\n\n## create\n\n```ts\nclient.scrape.bulk.create(opts: ScrapeBulkCreateRequest, requestOptions?: RequestOptions): Promise<ScrapeBulkCreateResponse>\n```\n\nPOST /v1/scrape/bulk — create a bulk scrape job.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default.\n\n## get\n\n```ts\nclient.scrape.bulk.get(id: BulkId, requestOptions?: RequestOptions): Promise<ScrapeBulkGetResponse>\n```\n\nGET /v1/scrape/bulk/\\{id\\} — get a bulk scrape job"
|
|
466
491
|
},
|
|
467
492
|
"sdk/typescript/screenshots": {
|
|
468
493
|
"title": "Screenshots",
|
|
469
494
|
"section": "SDK Reference",
|
|
470
|
-
"body": "# Screenshots\n\nCapture full-page or viewport screenshots
|
|
495
|
+
"body": "# Screenshots\n\nCapture full-page or viewport screenshots. Accessed via `client.screenshots`.\n\n## create\n\n```ts\nclient.screenshots.create(opts: ScreenshotCreateRequest, params?: { async?: boolean }, requestOptions?: RequestOptions): Promise<ScreenshotCreateResponse>\n```\n\nPOST /v1/screenshots — capture a screenshot.\n\n`params.async` maps to the `?async=true` query param (queued 202 capture). It is a QUERY\nparam on `createScreenshot`, distinct from scrape where `async` is a body field. `params` is\noptional and `async` omitted-when-absent: `create(opts)` with no second argument posts to the\nbare `/v1/screenshots` URL unchanged — existing single-arg callers are unaffected.\n\n`requestOptions` is the THIRD positional parameter (after `params`) so both existing call\nshapes stay unaffected. It carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default.\n\n## get\n\n```ts\nclient.screenshots.get(id: ScreenshotId, requestOptions?: RequestOptions): Promise<ScreenshotGetResponse>\n```\n\nGET /v1/screenshots/\\{id\\} — poll a screenshot by ID.\n\nA terminal-`failed` screenshot returns the `Error` envelope on a 200\n(issue #2027), so narrow the result before reading `image_url`.\n\n## createWithResponse\n\n```ts\nclient.screenshots.createWithResponse(opts: ScreenshotCreateRequest, params?: { async?: boolean }, requestOptions?: RequestOptions): Promise<ApiResponse<ScreenshotCreateResponse>>\n```\n\nPOST /v1/screenshots, returning the header set alongside the body (#2547).\n\nSame request as `screenshots.create` — same method, path, body and\n`RequestOptions` precedence — and `data` is exactly what `create()` resolves to.\n`create()`'s own return type is UNCHANGED; this is an additive sibling.\n\nThe spec documents the `X-Screenshot-*` family (`ID`, `Status`, `URL`,\n`Credits-Charged`, `Duration-Ms`, `Created-At`, `Completed-At`, `Expires-At`,\n`Status-Code`, `Cache`, `Cache-Age`) plus `X-Raw-Bytes` / `X-Billable-Bytes` /\n`X-Billing-Multiplier`; every one of them is on `headers`.\n\n## getWithResponse\n\n```ts\nclient.screenshots.getWithResponse(id: ScreenshotId, requestOptions?: RequestOptions): Promise<ApiResponse<ScreenshotGetResponse>>\n```\n\nGET /v1/screenshots/\\{id\\}, returning the header set alongside the body (#2547).\n\nSame request as `screenshots.get`, and `data` is exactly what `get()`\nresolves to (including the #2027 failed-envelope arm). `get()`'s own return type is\nUNCHANGED; this is an additive sibling.\n\nCall it for the typed body, NOT for header metadata: the spec declares\n`GET /v1/screenshots/\\{id\\}` with NO `X-*` response headers, and a live GET returns\nnone, so `headers` carries only the transport's own entries (`Content-Type`, …).\nThe `X-Screenshot-*` / `X-Raw-Bytes` / `X-Billable-Bytes` / `X-Billing-Multiplier`\nfamily is emitted by `POST /v1/screenshots` — use `screenshots.createWithResponse`\nto read it (issue #2957). This matches `ByteKit.requestWithResponse` and the README,\nwhich are the truth for what this endpoint emits."
|
|
471
496
|
},
|
|
472
497
|
"sdk/typescript/search": {
|
|
473
498
|
"title": "Search",
|
|
474
499
|
"section": "SDK Reference",
|
|
475
|
-
"body": "# Search\n\nRun a web search and return ranked organic results
|
|
500
|
+
"body": "# Search\n\nRun a web search and return ranked organic results. Accessed via `client.search`.\n\n## query\n\n```ts\nclient.search.query(opts: SearchOpts, requestOptions?: RequestOptions): Promise<SearchResponse>\n```\n\nPOST /v1/search — run a web search and return ranked organic results.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default."
|
|
476
501
|
},
|
|
477
502
|
"sdk/typescript/sitemap": {
|
|
478
503
|
"title": "Sitemap",
|
|
479
504
|
"section": "SDK Reference",
|
|
480
|
-
"body": "# Sitemap\n\nDiscover URLs from a domain's sitemap or by crawling
|
|
505
|
+
"body": "# Sitemap\n\nDiscover URLs from a domain's sitemap or by crawling. Accessed via `client.sitemap`.\n\n## create\n\n```ts\nclient.sitemap.create(opts: SitemapCreateRequest, requestOptions?: RequestOptions): Promise<SitemapCreateResponse>\n```\n\nPOST /v1/sitemap — start a sitemap crawl.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default.\n\n## get\n\n```ts\nclient.sitemap.get(id: SitemapId, requestOptions?: RequestOptions): Promise<SitemapGetResponse>\n```\n\nGET /v1/sitemap/\\{id\\} — get a sitemap job by ID\n\n## getWithResponse\n\n```ts\nclient.sitemap.getWithResponse(id: SitemapId, requestOptions?: RequestOptions): Promise<ApiResponse<SitemapGetResponse>>\n```\n\nGET /v1/sitemap/\\{id\\}, returning the header set alongside the body (#2547).\n\nSame request as `sitemap.get` — same method, path and `RequestOptions`\nprecedence — and `data` is exactly what `get()` resolves to. `get()`'s own return type\nis UNCHANGED; this is an additive sibling, not a replacement.\n\nThe spec documents `X-Sitemap-ID`, `X-Raw-Bytes`, `X-Billing-Multiplier` and\n`X-Billable-Bytes` on this endpoint's 200; every one of them is on `headers`."
|
|
481
506
|
},
|
|
482
507
|
"sdk/typescript/usage": {
|
|
483
508
|
"title": "Usage",
|
|
484
509
|
"section": "SDK Reference",
|
|
485
|
-
"body": "# Usage\n\nBilling-period and daily usage breakdowns
|
|
510
|
+
"body": "# Usage\n\nBilling-period and daily usage breakdowns. Accessed via `client.usage`.\n\n## get\n\n```ts\nclient.usage.get(requestOptions?: RequestOptions): Promise<GetUsageResponse>\n```\n\nGET /v1/usage — get current billing period usage.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default.\n\n## daily\n\n```ts\nclient.usage.daily(params?: GetUsageDailyParams, requestOptions?: RequestOptions): Promise<GetUsageDailyResponse>\n```\n\nGET /v1/usage/daily — get daily usage breakdown.\nDefault range is the last 30 days; max range is 366 days.\n\n## byEndpoint\n\n```ts\nclient.usage.byEndpoint(params?: GetUsageByEndpointParams, requestOptions?: RequestOptions): Promise<GetUsageByEndpointResponse>\n```\n\nGET /v1/usage/by-endpoint — get per-endpoint bandwidth breakdown.\nDefault range is the last 30 days; max range is 366 days."
|
|
486
511
|
},
|
|
487
512
|
"sdk/typescript/webhooks": {
|
|
488
513
|
"title": "Webhooks",
|
|
489
514
|
"section": "SDK Reference",
|
|
490
|
-
"body": "# Webhooks\n\nList and retry webhook deliveries
|
|
515
|
+
"body": "# Webhooks\n\nList and retry webhook deliveries. Accessed via `client.webhooks`.\n\n## list\n\n```ts\nclient.webhooks.list(params?: ListWebhookDeliveriesParams, requestOptions?: RequestOptions): Promise<ListWebhookDeliveriesResponse>\n```\n\nGET /v1/webhook-deliveries — list webhook deliveries.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default.\n\n## retry\n\n```ts\nclient.webhooks.retry(id: WebhookDeliveryId, requestOptions?: RequestOptions): Promise<RetryWebhookDeliveryResponse>\n```\n\nPOST /v1/webhook-deliveries/\\{id\\}/retry — requeue a failed or exhausted delivery."
|
|
491
516
|
}
|
|
492
517
|
}
|
|
@@ -80,7 +80,17 @@ export declare function sortBundleKeys<T>(bundle: Record<string, T>): Record<str
|
|
|
80
80
|
/**
|
|
81
81
|
* Extracts the page title from the rendered markdown.
|
|
82
82
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
83
|
+
* Every page the docs app renders opens with a level-1 heading on its first
|
|
84
|
+
* line: `# <title>`. We strip it and return just the text.
|
|
85
|
+
*
|
|
86
|
+
* That heading has two sources since issue #2953. For a page whose MDX body
|
|
87
|
+
* opens with prose or an H2, getLLMText() synthesizes it from the frontmatter
|
|
88
|
+
* title. For a page whose body already leads with its own H1 — every generated
|
|
89
|
+
* SDK reference page — the body's heading is used verbatim and nothing is
|
|
90
|
+
* synthesized on top of it, which is what stopped those pages shipping the
|
|
91
|
+
* title block twice. Either way the first line is the page's single title, so
|
|
92
|
+
* this function reads it the same way; the "exactly one H1, leading the body"
|
|
93
|
+
* invariant is asserted over the committed bundle in
|
|
94
|
+
* `src/__tests__/build-docs-bundle.test.ts`.
|
|
85
95
|
*/
|
|
86
96
|
export declare function extractTitle(markdown: string): string;
|
|
@@ -138,8 +138,18 @@ export function sortBundleKeys(bundle) {
|
|
|
138
138
|
/**
|
|
139
139
|
* Extracts the page title from the rendered markdown.
|
|
140
140
|
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
141
|
+
* Every page the docs app renders opens with a level-1 heading on its first
|
|
142
|
+
* line: `# <title>`. We strip it and return just the text.
|
|
143
|
+
*
|
|
144
|
+
* That heading has two sources since issue #2953. For a page whose MDX body
|
|
145
|
+
* opens with prose or an H2, getLLMText() synthesizes it from the frontmatter
|
|
146
|
+
* title. For a page whose body already leads with its own H1 — every generated
|
|
147
|
+
* SDK reference page — the body's heading is used verbatim and nothing is
|
|
148
|
+
* synthesized on top of it, which is what stopped those pages shipping the
|
|
149
|
+
* title block twice. Either way the first line is the page's single title, so
|
|
150
|
+
* this function reads it the same way; the "exactly one H1, leading the body"
|
|
151
|
+
* invariant is asserted over the committed bundle in
|
|
152
|
+
* `src/__tests__/build-docs-bundle.test.ts`.
|
|
143
153
|
*/
|
|
144
154
|
export function extractTitle(markdown) {
|
|
145
155
|
const firstLine = markdown.split('\n')[0] ?? '';
|
|
@@ -35,12 +35,18 @@ export function renderScreenshotResult(result) {
|
|
|
35
35
|
// The image URL is a short-lived SIGNED link (issue #2687 item 4). Nothing in the
|
|
36
36
|
// render said so, and an agent that stashed the URL and fetched it later got an
|
|
37
37
|
// opaque 403. Emitted only alongside an actual image URL — a pending screenshot has
|
|
38
|
-
// nothing to expire.
|
|
39
|
-
//
|
|
38
|
+
// nothing to expire.
|
|
39
|
+
//
|
|
40
|
+
// `expires_at` (openapi.yaml ScreenshotResponse) is NOT the signed URL's validity —
|
|
41
|
+
// it is the plan's artifact-retention date computed by
|
|
42
|
+
// gateway/src/routes/screenshots.ts (~30 days out), describing how long the
|
|
43
|
+
// screenshot ROW survives, not how long the B2-signed link stays valid (~600s,
|
|
44
|
+
// `X-Amz-Expires=600`, fixed independently of retention). Presenting `expires_at` as
|
|
45
|
+
// the URL's expiry (issue #2947) handed an agent a link that read as good for weeks
|
|
46
|
+
// and died in ~10 minutes. The signature-expiry wording therefore always wins for
|
|
47
|
+
// this note, regardless of whether `expires_at` is present.
|
|
40
48
|
result.image_url
|
|
41
|
-
?
|
|
42
|
-
? `Note: the image URL is a signed link that expires at ${result.expires_at} — download it before then.`
|
|
43
|
-
: 'Note: the image URL is a signed link that expires roughly 600s after it is issued — download it before then.'
|
|
49
|
+
? 'Note: the image URL is a signed link that expires roughly 600s after it is issued — download it before then.'
|
|
44
50
|
: null,
|
|
45
51
|
result.image_width && result.image_height
|
|
46
52
|
? `Size: ${result.image_width}x${result.image_height}`
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scrape `formats` vocabulary this server speaks, in ONE place (issue #2959).
|
|
3
|
+
*
|
|
4
|
+
* `docs/api/openapi.yaml`, the published SDKs and every bundled doc page spell the
|
|
5
|
+
* raw-HTML format `raw_html`. The gateway's INTERNAL `Format` type — which
|
|
6
|
+
* `scrape-contract.generated.ts` mirrors, because it is generated verbatim from
|
|
7
|
+
* `packages/scrape-shared/src/envelope-types.ts` — spells it `rawHtml`.
|
|
8
|
+
*
|
|
9
|
+
* Until #2959 the tool translated public → internal and sent `rawHtml` on the wire. That
|
|
10
|
+
* request only succeeded because `gateway/src/validators/wire-keys.ts` happens to accept
|
|
11
|
+
* both spellings; nothing in the published contract promised it, so this server depended
|
|
12
|
+
* on an undocumented leniency it could not see. It now sends the public spelling, and
|
|
13
|
+
* depends on nothing.
|
|
14
|
+
*
|
|
15
|
+
* The legacy alias below is the other half: #2588 made the tool ACCEPT `rawHtml` from an
|
|
16
|
+
* agent, and #2959 does not take that back — it only changes what leaves. The alias lives
|
|
17
|
+
* here rather than in `tools/scrape-url.ts` so the wire-facing tool file names exactly one
|
|
18
|
+
* spelling (the pre-merge grep gate for #2959 pins that), and so the two halves of the
|
|
19
|
+
* vocabulary — what we accept, what we send — are read together instead of a file apart.
|
|
20
|
+
*
|
|
21
|
+
* NOT in `scrape-contract.generated.ts`: that file is overwritten verbatim on every
|
|
22
|
+
* `pnpm generate:scrape-contract`, so anything hand-written into it is silently wiped
|
|
23
|
+
* (issue #2588 failure mode E2).
|
|
24
|
+
*/
|
|
25
|
+
/** Every format value the public spec enumerates. This is what goes on the wire. */
|
|
26
|
+
export declare const PUBLIC_SCRAPE_FORMATS: readonly ["raw_html", "html", "markdown", "links", "images"];
|
|
27
|
+
export type PublicScrapeFormat = (typeof PUBLIC_SCRAPE_FORMATS)[number];
|
|
28
|
+
/**
|
|
29
|
+
* Legacy spellings still accepted FROM an agent (#2588), mapped to the public value they
|
|
30
|
+
* mean. Only the raw-HTML format ever diverged; the other four are identical on both sides.
|
|
31
|
+
*/
|
|
32
|
+
export declare const LEGACY_FORMAT_ALIASES: Record<string, PublicScrapeFormat>;
|
|
33
|
+
/** Every value the tool's `formats` enum accepts: the public set plus the legacy aliases. */
|
|
34
|
+
export declare const ACCEPTED_SCRAPE_FORMATS: [string, ...string[]];
|
|
35
|
+
/** Normalize one accepted value to the public spelling that goes on the wire. */
|
|
36
|
+
export declare function toPublicFormat(value: string): PublicScrapeFormat;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scrape `formats` vocabulary this server speaks, in ONE place (issue #2959).
|
|
3
|
+
*
|
|
4
|
+
* `docs/api/openapi.yaml`, the published SDKs and every bundled doc page spell the
|
|
5
|
+
* raw-HTML format `raw_html`. The gateway's INTERNAL `Format` type — which
|
|
6
|
+
* `scrape-contract.generated.ts` mirrors, because it is generated verbatim from
|
|
7
|
+
* `packages/scrape-shared/src/envelope-types.ts` — spells it `rawHtml`.
|
|
8
|
+
*
|
|
9
|
+
* Until #2959 the tool translated public → internal and sent `rawHtml` on the wire. That
|
|
10
|
+
* request only succeeded because `gateway/src/validators/wire-keys.ts` happens to accept
|
|
11
|
+
* both spellings; nothing in the published contract promised it, so this server depended
|
|
12
|
+
* on an undocumented leniency it could not see. It now sends the public spelling, and
|
|
13
|
+
* depends on nothing.
|
|
14
|
+
*
|
|
15
|
+
* The legacy alias below is the other half: #2588 made the tool ACCEPT `rawHtml` from an
|
|
16
|
+
* agent, and #2959 does not take that back — it only changes what leaves. The alias lives
|
|
17
|
+
* here rather than in `tools/scrape-url.ts` so the wire-facing tool file names exactly one
|
|
18
|
+
* spelling (the pre-merge grep gate for #2959 pins that), and so the two halves of the
|
|
19
|
+
* vocabulary — what we accept, what we send — are read together instead of a file apart.
|
|
20
|
+
*
|
|
21
|
+
* NOT in `scrape-contract.generated.ts`: that file is overwritten verbatim on every
|
|
22
|
+
* `pnpm generate:scrape-contract`, so anything hand-written into it is silently wiped
|
|
23
|
+
* (issue #2588 failure mode E2).
|
|
24
|
+
*/
|
|
25
|
+
/** Every format value the public spec enumerates. This is what goes on the wire. */
|
|
26
|
+
export const PUBLIC_SCRAPE_FORMATS = ['raw_html', 'html', 'markdown', 'links', 'images'];
|
|
27
|
+
/**
|
|
28
|
+
* Legacy spellings still accepted FROM an agent (#2588), mapped to the public value they
|
|
29
|
+
* mean. Only the raw-HTML format ever diverged; the other four are identical on both sides.
|
|
30
|
+
*/
|
|
31
|
+
export const LEGACY_FORMAT_ALIASES = {
|
|
32
|
+
rawHtml: 'raw_html',
|
|
33
|
+
};
|
|
34
|
+
/** Every value the tool's `formats` enum accepts: the public set plus the legacy aliases. */
|
|
35
|
+
export const ACCEPTED_SCRAPE_FORMATS = [
|
|
36
|
+
...PUBLIC_SCRAPE_FORMATS,
|
|
37
|
+
...Object.keys(LEGACY_FORMAT_ALIASES),
|
|
38
|
+
];
|
|
39
|
+
/** Normalize one accepted value to the public spelling that goes on the wire. */
|
|
40
|
+
export function toPublicFormat(value) {
|
|
41
|
+
return LEGACY_FORMAT_ALIASES[value] ?? value;
|
|
42
|
+
}
|
|
@@ -39,7 +39,7 @@ export interface ScrapeStats {
|
|
|
39
39
|
tokens: number;
|
|
40
40
|
blocks: number;
|
|
41
41
|
}
|
|
42
|
-
export type ScrapeEnvelopeErrorCode = 'validation_error' | '
|
|
42
|
+
export type ScrapeEnvelopeErrorCode = 'validation_error' | 'invalid_url' | 'request_too_large' | 'payload_too_large' | 'unsupported_content_type' | 'rate_limited' | 'upstream_error' | 'timeout' | 'blocked' | 'internal_error';
|
|
43
43
|
export interface ScrapeFormats {
|
|
44
44
|
/** Raw HTML format (#1535: renamed from rawHtml in the response key). */
|
|
45
45
|
raw_html?: string;
|
|
@@ -119,18 +119,45 @@ export interface ScrapeSuccessEnvelope {
|
|
|
119
119
|
};
|
|
120
120
|
/**
|
|
121
121
|
* Per-call billing multiplier for this scrape (1.0 base, +0.5/billable format).
|
|
122
|
-
*
|
|
123
|
-
*
|
|
122
|
+
* Reports the BASE-endpoint composition: on a cache hit it is a flat 0.5 for
|
|
123
|
+
* every requested format, because the per-endpoint factor is applied later, at
|
|
124
|
+
* report time by GET /v1/usage/by-endpoint (issue #2313), not here. It equals
|
|
125
|
+
* the X-Scrape-Credits-Charged header and the persisted credits_charged column
|
|
126
|
+
* (both 0.5 on a cache hit), but it does NOT always equal the
|
|
127
|
+
* X-Billing-Multiplier header, which composes the REAL endpoint: on a markdown
|
|
128
|
+
* cache hit the header is 0.75 (scrape_md 1.5 x cacheHit 0.5) while this field
|
|
129
|
+
* stays 0.5 (Exception D-scrape, issue #2315). Raw cache hits are 0.5 in both.
|
|
124
130
|
* NOTE: pre-clean_markdown-multiplier; on clean_markdown:true the final billed
|
|
125
131
|
* usage is 3x this. Omitted on paths with no billing value (issue #1899).
|
|
132
|
+
* LEGACY (issue #3139): `billing` below is now the explanation of the charge —
|
|
133
|
+
* it names every factor and composes to the X-Billing-Multiplier header. Read
|
|
134
|
+
* that; this field is removed in the final slice of #3135.
|
|
126
135
|
*/
|
|
127
136
|
billing_multiplier?: number;
|
|
128
137
|
/**
|
|
129
|
-
* Metered wire bytes for this call = round(content_length x billing_multiplier)
|
|
130
|
-
*
|
|
131
|
-
* the header
|
|
138
|
+
* Metered wire bytes for this call = round(content_length x billing_multiplier),
|
|
139
|
+
* derived from the body multiplier above rather than from the header's. Same
|
|
140
|
+
* value as the X-Billable-Bytes header wherever the two multipliers agree; on a
|
|
141
|
+
* markdown cache hit the header carries round(content_length x 0.75) and this
|
|
142
|
+
* field round(content_length x 0.5), per Exception D-scrape (issue #2315).
|
|
143
|
+
* (pre-clean_markdown-multiplier, like the header). Omitted on paths with no
|
|
144
|
+
* billing value (issue #1899).
|
|
145
|
+
* LEGACY (issue #3139): read `billing.billed_bytes` below instead — it equals
|
|
146
|
+
* the X-Billable-Bytes header on the same response.
|
|
132
147
|
*/
|
|
133
148
|
billed_bytes?: number;
|
|
149
|
+
/**
|
|
150
|
+
* The named billing factor list (issue #3139) — the DEFINITION of what this
|
|
151
|
+
* call is charged. `factors` lists every applying factor in composition order
|
|
152
|
+
* (`endpoint` -> `cache_hit` -> `clean_markdown`), non-applying factors
|
|
153
|
+
* absent; their product is `multiplier`, and `round(raw_bytes x multiplier)`
|
|
154
|
+
* is `billed_bytes`. `multiplier` and `billed_bytes` equal the
|
|
155
|
+
* X-Billing-Multiplier and X-Billable-Bytes headers on the same response,
|
|
156
|
+
* because both are rendered from this one list. Where this node and any other
|
|
157
|
+
* billing surface disagree, this node is correct and the other is the bug.
|
|
158
|
+
* Omitted on paths that produce no billing value.
|
|
159
|
+
*/
|
|
160
|
+
billing?: BillingNode;
|
|
134
161
|
}
|
|
135
162
|
export interface ScrapeErrorEnvelope {
|
|
136
163
|
schema_version: ScrapeEnvelopeSchemaVersion;
|
|
@@ -169,3 +196,31 @@ export interface ScrapeQueuedEnvelope {
|
|
|
169
196
|
* remains valid only at explicit read/delivery boundaries typed more loosely.
|
|
170
197
|
*/
|
|
171
198
|
export type ScrapeEnvelope = ScrapeSuccessEnvelope | ScrapeErrorEnvelope | ScrapeQueuedEnvelope;
|
|
199
|
+
/**
|
|
200
|
+
* The complete billing factor vocabulary — fixed and TOTAL, in the order the
|
|
201
|
+
* factors compose. A charge is explained by these three names or it is not
|
|
202
|
+
* explained at all.
|
|
203
|
+
*/
|
|
204
|
+
export type BillingFactorName = 'endpoint' | 'cache_hit' | 'clean_markdown';
|
|
205
|
+
export interface BillingFactor {
|
|
206
|
+
name: BillingFactorName;
|
|
207
|
+
/** This factor's multiplicative contribution. */
|
|
208
|
+
value: number;
|
|
209
|
+
/**
|
|
210
|
+
* Human-readable explanation. Explanatory, NOT contractual — never branch on
|
|
211
|
+
* it; `name` + `value` are the machine-readable half.
|
|
212
|
+
*/
|
|
213
|
+
reason: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The customer-visible billing node. Emitted verbatim by buildSuccessEnvelope
|
|
217
|
+
* and rendered into the X-Raw-Bytes / X-Billable-Bytes / X-Billing-Multiplier
|
|
218
|
+
* trio, so body and headers agree by construction rather than by two
|
|
219
|
+
* computations that happen to match.
|
|
220
|
+
*/
|
|
221
|
+
export interface BillingNode {
|
|
222
|
+
raw_bytes: number;
|
|
223
|
+
factors: BillingFactor[];
|
|
224
|
+
multiplier: number;
|
|
225
|
+
billed_bytes: number;
|
|
226
|
+
}
|
package/dist/tools/scrape-url.js
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { renderScrapeResult } from '../lib/render-scrape.js';
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
// This map lives here, in the hand-written tool file, deliberately — NOT in
|
|
9
|
-
// scrape-contract.generated.ts. That file is overwritten verbatim from
|
|
10
|
-
// packages/scrape-shared/src/envelope-types.ts on every
|
|
11
|
-
// `pnpm generate:scrape-contract` regen, so anything hand-edited into it would be
|
|
12
|
-
// silently wiped on the next regen (see issue #2588 failure mode E2). Keeping the
|
|
13
|
-
// widened vocabulary local to this file means a regen can never touch it.
|
|
14
|
-
const PUBLIC_TO_INTERNAL_FORMAT = {
|
|
15
|
-
raw_html: 'rawHtml',
|
|
16
|
-
};
|
|
17
|
-
function toInternalFormat(value) {
|
|
18
|
-
return (PUBLIC_TO_INTERNAL_FORMAT[value] ?? value);
|
|
19
|
-
}
|
|
3
|
+
// The accepted-vs-sent format vocabulary (issue #2959). This server sends the PUBLIC
|
|
4
|
+
// spelling and depends on no gateway leniency; the legacy alias #2588 added stays
|
|
5
|
+
// accepted from the agent. Both halves live in ../lib/scrape-formats.js.
|
|
6
|
+
import { ACCEPTED_SCRAPE_FORMATS, toPublicFormat } from '../lib/scrape-formats.js';
|
|
20
7
|
/**
|
|
21
8
|
* Issue #2687 item 11 — EXCLUDE side of the unexposed-option decision table.
|
|
22
9
|
*
|
|
@@ -60,14 +47,14 @@ export function scrapeUrlTool(server, client) {
|
|
|
60
47
|
// error at the boundary teaches it faster than a format it never requested. An
|
|
61
48
|
// ABSENT array is untouched by this and still falls through to the default below.
|
|
62
49
|
formats: z
|
|
63
|
-
.array(z.enum(
|
|
50
|
+
.array(z.enum(ACCEPTED_SCRAPE_FORMATS))
|
|
64
51
|
.min(1, 'formats must list at least one format; omit it entirely for the markdown default')
|
|
65
52
|
.optional()
|
|
66
|
-
.describe('Content formats to return. Default: ["markdown"]. Options: markdown, raw_html
|
|
53
|
+
.describe('Content formats to return. Default: ["markdown"]. Options: markdown, raw_html, html, links, images. Omit the parameter for the default; an empty array is rejected.'),
|
|
67
54
|
country: z.string().optional().describe('Two-letter country code for geo-targeted scraping'),
|
|
68
55
|
}, async (params) => {
|
|
69
56
|
try {
|
|
70
|
-
const formats = (params.formats ?? ['markdown']).map(
|
|
57
|
+
const formats = (params.formats ?? ['markdown']).map(toPublicFormat);
|
|
71
58
|
const result = await client.scrape({
|
|
72
59
|
url: params.url,
|
|
73
60
|
formats,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hunt-labs/bytekit-mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
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",
|