Skip to main content

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

Install

npm install @structbuild/sdk

Quickstart

1

Create an API key

Sign up at struct.to/dashboard, create an organisation, and generate an API key.
2

Instantiate the client

import { StructClient } from "@structbuild/sdk";

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

Make your first request

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

for (const market of markets) {
  console.log(market.slug, market.last_price);
}
4

Stream live updates

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

What’s included

REST client

Namespaced access to every endpoint: markets, events, trader, holders, order book, series, assets, tags, bonds, search, and webhooks.

WebSocket rooms

Typed subscribe / on for every room, with auto-reconnect, replay, and keepalive.

Alerts

Per-event typed filters for the alerts websocket, sharing the same connection primitives.

JWT public key auth

Authenticate your end users with their own JWTs without shipping sk_* keys to the browser.

Pagination helper

Iterate through any paginated endpoint with a single async generator.

Typed errors

HttpError, TimeoutError, NetworkError, WebSocketError, and friends.

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

Last modified on April 14, 2026