Use this file to discover all available pages before exploring further.
The Delphi Trading SDK (@delphimarkets/sdk) is a TypeScript library that lets you place, query, and cancel orders on six prediction markets through a single unified interface. It wraps the Delphi REST API and adds client-side helpers for the on-chain exchanges that require EIP-712 signed orders.
Every request to the Delphi API requires the X-API-Key header:
X-API-Key: your_api_key_here
The SDK adds this automatically based on the apiKey you pass to DelphiClient. Don’t expose your key in client-side code (browser apps) — proxy through your own backend.
This is the most important concept to understand before you write any trading code.
On-chain exchanges require client-side EIP-712 signed orders. Your private key must produce the signature locally and never leave your machine. The Delphi server cannot — and intentionally does not — have access to your private key. If you call POST /api/v1/orders with an unsigned or invalidly-signed payload, the underlying exchange will reject it.This applies to Polymarket, Opinion Labs, Limitless, and Predict.fun.The SDK’s build*Order() helpers do all of this for you — pass in your private key (via a viemWalletClient) and they return a fully-signed payload ready for placeOrder().
For Kalshi and Gemini, the server signs with credentials you registered ahead of time (RSA private key for Kalshi, HMAC secret for Gemini). No client-side cryptography needed.
// Get a single order's statusconst status = await client.getOrder(orderId, 'polymarket');// List all of your tracked orders, optionally filtered by exchangeconst all = await client.listOrders();const polyOnly = await client.listOrders('polymarket');// Cancel a resting orderawait client.cancelOrder(orderId, 'polymarket');
The exchange argument is optional on getOrder and cancelOrder — the server can resolve it from the order store. Passing it explicitly is slightly faster.
Every API error is wrapped in a DelphiError that exposes the HTTP status code and a server-provided message:
import { DelphiError } from '@delphimarkets/sdk';try { await client.placeOrder(req);} catch (err) { if (err instanceof DelphiError) { console.error(`API error ${err.statusCode}: ${err.message}`); // 400 = bad request (malformed signed_order) // 401 = auth failed (invalid X-API-Key) // 403 = forbidden // 502 = upstream exchange returned an error }}
Network and timeout errors surface as standard AbortError / TypeError. The SDK does not auto-retry — that’s intentional, since order placement is non-idempotent.