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

Install

Requires Node 18+ (uses native fetch).

Configure

Authentication

Every request to the Delphi API requires the X-API-Key header:
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.

How signing works

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 viem WalletClient) 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.

Quick example: Polymarket order

For full per-exchange flows, see the per-exchange guides:

Polymarket

EIP-712 signed orders, Gnosis Safe wallet on Polygon

Kalshi

Server-side RSA-PSS signing, US-regulated

Opinion Labs

EIP-712 + Safe on BNB Chain

Gemini Predictions

Server-side HMAC-SHA512 signing

Limitless

EIP-712 signed orders, EOA wallet on Base

Predict.fun

EIP-712 + Kernel smart wallet on BNB Chain

Order management

The same four methods work for every exchange:
The exchange argument is optional on getOrder and cancelOrder — the server can resolve it from the order store. Passing it explicitly is slightly faster.

Credentials

For Kalshi, Gemini, Opinion Labs, Limitless, and Predict.fun, register your exchange credentials once, then place orders without further auth setup:
For Polymarket, use the dedicated derive helper instead — it handles the CLOB HMAC derivation in one call:
List which exchanges you’ve connected:

Error handling

Every API error is wrapped in a DelphiError that exposes the HTTP status code and a server-provided message:
Network and timeout errors surface as standard AbortError / TypeError. The SDK does not auto-retry — that’s intentional, since order placement is non-idempotent.

TypeScript types

All public types are exported from the package root:
The package ships ESM, CJS, and .d.ts declarations for full IDE auto-completion.

Resources

GitHub

Source code, issues, releases

npm

Package page, version history