Skip to main content
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

TypeScript / JavaScript

@structbuild/sdk runs in Node 18+, Bun, Deno, Cloudflare Workers, and every evergreen browser. Dual-published ESM/CJS, zero polyfills.

Any other language

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.

What’s included

REST client

Namespaced access to every endpoint with typed parameters and responses.

Rooms WebSocket

Typed subscribe and on per room, with auto-reconnect, replay, and keepalive.

Alerts WebSocket

Per-event typed filters sharing the same connection primitives.

JWT public key auth

Authenticate end users with their own JWTs. Safe to ship in the browser.

Pagination helper

Iterate any cursor-paginated endpoint with an async generator.

Typed errors

HttpError, TimeoutError, NetworkError, WebSocketError, and friends.

Webhook management

Create, list, rotate, and delete webhook subscriptions from code.

Retries and hooks

Built-in exponential backoff and onRequest / onResponse lifecycle hooks.

At a glance

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 / WebSocketTypeScript SDK
TypesHand-rolled or generated from OpenAPIGenerated, shipped, versioned with the package
AuthSet headers / query params manuallyapiKey / jwt / getJwt config fields
PaginationLoop on pagination_key yourselfAsync iterator per endpoint
ReconnectsExponential backoff yourselfBuilt in, with auto-replay of subscriptions
RetriesImplement around fetchConfigurable retry block with Retry-After support
ErrorsParse status codes and bodiesTyped error hierarchy with instanceof checks
JWT rotationReconstruct URL on every reconnectPass 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

Last modified on May 27, 2026