> ## Documentation Index
> Fetch the complete documentation index at: https://docs.struct.to/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Typed, batteries-included clients for the Struct API.

The fastest path to a Struct integration is the official SDK. It wraps every REST endpoint, both websocket endpoints, and webhook management in a single typed client. Types are generated directly from the live OpenAPI and AsyncAPI specs, so they match production exactly.

## Available SDKs

<CardGroup cols={2}>
  <Card title="TypeScript / JavaScript" icon="js" href="/sdk/getting-started">
    `@structbuild/sdk` runs in Node 18+, Bun, Deno, Cloudflare Workers, and every evergreen browser. Dual-published ESM/CJS, zero polyfills.
  </Card>

  <Card title="Any other language" icon="code" href="/api-reference/getting-started">
    The REST and websocket protocols are language-agnostic. Use any HTTP and WebSocket client; the type definitions in the OpenAPI and AsyncAPI specs are public.
  </Card>
</CardGroup>

## What's included

<CardGroup cols={3}>
  <Card title="REST client" icon="code" href="/sdk/rest-api">
    Namespaced access to every endpoint with typed parameters and responses.
  </Card>

  <Card title="Rooms WebSocket" icon="signal-stream" href="/sdk/websockets">
    Typed `subscribe` and `on` per room, with auto-reconnect, replay, and keepalive.
  </Card>

  <Card title="Alerts WebSocket" icon="bell" href="/sdk/alerts">
    Per-event typed filters sharing the same connection primitives.
  </Card>

  <Card title="JWT public key auth" icon="fingerprint" href="/sdk/authentication">
    Authenticate end users with their own JWTs. Safe to ship in the browser.
  </Card>

  <Card title="Pagination helper" icon="list" href="/sdk/pagination">
    Iterate any cursor-paginated endpoint with an async generator.
  </Card>

  <Card title="Typed errors" icon="triangle-exclamation" href="/sdk/errors">
    `HttpError`, `TimeoutError`, `NetworkError`, `WebSocketError`, and friends.
  </Card>

  <Card title="Webhook management" icon="webhook" href="/sdk/webhooks">
    Create, list, rotate, and delete webhook subscriptions from code.
  </Card>

  <Card title="Retries and hooks" icon="arrows-rotate" href="/sdk/configuration">
    Built-in exponential backoff and `onRequest` / `onResponse` lifecycle hooks.
  </Card>
</CardGroup>

## At a glance

```typescript theme={null}
import { StructClient, StructWebSocket } from "@structbuild/sdk";

const client = new StructClient({ apiKey: "sk_live_xxx" });

const { data: markets } = await client.markets.getMarkets({ limit: 10 });

const ws = new StructWebSocket({ apiKey: "sk_live_xxx" });
await ws.connect();
await ws.subscribe("polymarket_trades", { condition_ids: ["0xabc..."] });

ws.on("trade_stream_update", (event) => {
  console.log(event.condition_id, event.price, event.side);
});
```

## Why use the SDK?

|                  | Raw HTTP / WebSocket                  | TypeScript SDK                                      |
| ---------------- | ------------------------------------- | --------------------------------------------------- |
| **Types**        | Hand-rolled or generated from OpenAPI | Generated, shipped, versioned with the package      |
| **Auth**         | Set headers / query params manually   | `apiKey` / `jwt` / `getJwt` config fields           |
| **Pagination**   | Loop on `pagination_key` yourself     | Async iterator per endpoint                         |
| **Reconnects**   | Exponential backoff yourself          | Built in, with auto-replay of subscriptions         |
| **Retries**      | Implement around `fetch`              | Configurable retry block with `Retry-After` support |
| **Errors**       | Parse status codes and bodies         | Typed error hierarchy with `instanceof` checks      |
| **JWT rotation** | Reconstruct URL on every reconnect    | Pass `getJwt`, the SDK handles the rest             |

Everything the SDK does is supported by the raw protocols, so you can drop down to plain HTTP or WebSocket whenever you need to.

## Next steps

* [Getting Started](/sdk/getting-started): install and instantiate the client.
* [Configuration](/sdk/configuration): timeouts, retries, hooks, custom base URL.
* [Authentication](/sdk/authentication): secret keys and JWT public-key flow.
* [REST](/sdk/rest-api), [Rooms WS](/sdk/websockets), [Alerts WS](/sdk/alerts).
