Client
Instantiate and configure the ByteKit TypeScript client.
Client
The ByteKit TypeScript SDK is a thin, type-safe wrapper over the REST API. Create a client with your API key, then call resource methods.
import { ByteKit } from '@hunt-labs/bytekit-sdk';
const client = new ByteKit({
apiKey: process.env.BYTEKIT_API_KEY!, // your sk_live_… key
});Options (ByteKitOptions)
apiKey(required) —stringbaseUrl—stringDefaults tohttps://api.bytekit.com.timeoutMs—number— Default CLIENT-SIDE request timeout in ms — the abort budget for the whole HTTP round-trip made by this SDK, covering time-to-headers and the response body read (so a large legitimate body counts against it too).0disables the SDK-side timeout. Default 120000.
NOT the same thing as ScrapeOpts.timeout_ms, which is the SERVER-side budget the
gateway applies to the scrape itself. Override per call with
RequestOptions.requestTimeoutMs.
Resources
The client exposes one property per resource:
client.scrape— Fetch a URL as raw HTML, clean markdown, or structured content.client.screenshots— Capture full-page or viewport screenshots.client.bulk— Fan out many URLs in parallel with per-item webhooks.client.fetch— Low-latency raw HTTP fetch with optional conversion.client.monitors— Watch a URL on a schedule and webhook on change.client.sitemap— Discover URLs from a domain's sitemap or by crawling.client.search— Run a web search and return ranked organic results.client.account— Account info and API key management.client.usage— Billing-period and daily usage breakdowns.client.webhooks— List and retry webhook deliveries.
Errors
Any non-2xx response throws a ByteKitError carrying the HTTP status and the API code.
import { ByteKit, ByteKitError } from '@hunt-labs/bytekit-sdk';
try {
await client.scrape.create({ url: 'https://example.com' });
} catch (err) {
if (err instanceof ByteKitError) {
console.error(`${err.status} ${err.code}: ${err.message}`);
}
}POST /v1/webhook-deliveries/{id}/retryRetry a webhook delivery
Requeues a failed or exhausted webhook delivery for another attempt. **Limits:** this endpoint takes no request body; any body sent is capped at 64 KB. An oversized body returns a `400` with error code `request_too_large`.
Scrape
Fetch a URL as raw HTML, clean markdown, or structured content.