# 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.

```ts
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`
- `baseUrl` — `string` Defaults to `https://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). `0` disables the SDK-side
timeout. Default 120000.

NOT the same thing as `ScrapeOpts.timeout_ms`, which is the SERVER-side budget
ByteKit applies to the scrape itself. Override per call with
`RequestOptions.requestTimeoutMs`.

## Resources

The client exposes one property per resource:

- [`client.scrape`](https://bytekit.com/docs/sdk/typescript/scrape) — Fetch a URL as raw HTML, clean markdown, or structured content.
- [`client.screenshots`](https://bytekit.com/docs/sdk/typescript/screenshots) — Capture full-page or viewport screenshots.
- [`client.bulk`](https://bytekit.com/docs/sdk/typescript/bulk) — Fan out many URLs in parallel and get one webhook when the job completes.
- [`client.fetch`](https://bytekit.com/docs/sdk/typescript/fetch) — Low-latency raw HTTP fetch with byte-for-byte upstream responses.
- [`client.monitors`](https://bytekit.com/docs/sdk/typescript/monitors) — Watch a URL on a schedule and webhook on change.
- [`client.sitemap`](https://bytekit.com/docs/sdk/typescript/sitemap) — Discover URLs from a domain's sitemap or by crawling.
- [`client.search`](https://bytekit.com/docs/sdk/typescript/search) — Run a web search and return ranked organic results.
- [`client.account`](https://bytekit.com/docs/sdk/typescript/account) — Account info and API key management.
- [`client.usage`](https://bytekit.com/docs/sdk/typescript/usage) — Billing-period and daily usage breakdowns.
- [`client.webhooks`](https://bytekit.com/docs/sdk/typescript/webhooks) — List and retry webhook deliveries.

## Errors

Any non-2xx response throws a `ByteKitError` carrying the HTTP `status` and the API `code`.

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