SDK ReferenceTypeScript SDK

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) — string
  • baseUrlstring Defaults to https://api.bytekit.com.
  • timeoutMsnumber — 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). 0 disables 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:

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}`);
  }
}