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

# Getting Started

> Install the @structbuild/sdk TypeScript SDK and make your first call.

## Overview

`@structbuild/sdk` is the official TypeScript SDK for the Struct API. It wraps the REST API, the rooms websocket, the alerts websocket, and webhook management in a single, fully-typed client. The SDK is dual-published as ESM and CJS, runs in Node, Bun, Deno, and browsers, and ships with generated types derived directly from the live OpenAPI and AsyncAPI specs.

Source: [github.com/structbuild/struct-typescript-sdk](https://github.com/structbuild/struct-typescript-sdk). For a high-level tour of every surface and a feature matrix versus raw HTTP, see [SDK Overview](/sdk/overview).

## Install

<CodeGroup>
  ```bash npm theme={null}
  npm install @structbuild/sdk
  ```

  ```bash bun theme={null}
  bun add @structbuild/sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @structbuild/sdk
  ```

  ```bash yarn theme={null}
  yarn add @structbuild/sdk
  ```
</CodeGroup>

## Quickstart

<Steps>
  <Step title="Create an account">
    Sign up at [struct.to/dashboard](https://struct.to/dashboard) and create an organisation.
  </Step>

  <Step title="Generate an API key">
    Open the [API Keys](https://struct.to/dashboard) page in your dashboard and create a new key. Copy the value somewhere safe; you won't be able to view it again. See [Authentication](/introduction/authentication) for key types, JWT public keys, and rotation.
  </Step>

  <Step title="Instantiate the client">
    ```typescript theme={null}
    import { StructClient } from "@structbuild/sdk";

    const client = new StructClient({
      apiKey: "sk_live_xxx",
    });
    ```
  </Step>

  <Step title="Make your first request">
    ```typescript theme={null}
    const { data: markets } = await client.markets.getMarkets({ limit: 10 });

    for (const market of markets) {
      console.log(market.slug, market.last_price);
    }
    ```
  </Step>

  <Step title="Stream live updates">
    ```typescript theme={null}
    import { StructWebSocket } from "@structbuild/sdk";

    const ws = new StructWebSocket({ apiKey: "sk_live_xxx" });
    await ws.connect();
    await ws.subscribe("polymarket_trades");

    ws.on("trade_stream_update", (event) => {
      console.log(event.condition_id, event.price);
    });
    ```
  </Step>
</Steps>

## What's included

<CardGroup cols={2}>
  <Card title="REST client" icon="code" href="/sdk/rest-api">
    Namespaced access to every endpoint: markets, events, trader, holders, order book, series, assets, tags, bonds, search, and webhooks.
  </Card>

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

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

  <Card title="JWT public key auth" icon="fingerprint" href="/sdk/authentication">
    Authenticate your end users with their own JWTs without shipping `sk_*` keys to the browser.
  </Card>

  <Card title="Pagination helper" icon="list" href="/sdk/pagination">
    Iterate through any paginated endpoint with a single async generator.
  </Card>

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

## Requirements

The SDK targets modern runtimes that support the Fetch API, `AbortController`, and native `WebSocket`. That covers Node 18+, Bun, Deno, Cloudflare Workers, and every evergreen browser. No polyfills are required.

## Next steps

* Configure the client: see [Configuration](/sdk/configuration).
* Browse the REST reference: see [REST API](/sdk/rest-api).
* Stream live data: see [WebSockets](/sdk/websockets).
