GeminiGemini
SandboxGet API key
  • Crypto Trading
  • Prediction Markets
  • SDKs & Tools
Changelog
Gemini Crypto Exchange LogoGemini Crypto Exchange Logo

© 2026 Gemini Space Station, Inc.

Overview
TypeScript SDK
    QuickstartAuthenticationWebSocketError HandlingPatterns & Recipes
    API Reference
      Overview
      Market Data
      Trading
      Prediction Markets
      Account Services
      Clearing & Instant
      PerpetualsMarginWebSocket
    Deep Dives
API Reference

TypeScript SDK — WebSocket Reference

Every WebSocket stream and method, with the exact payload field names. WebSocket messages use a compact wire format with single-letter field names — this page maps each letter to its meaning so you never need to inspect the source.

All streams and methods are on client.websocket. See the WebSocket guide for lifecycle, reconnection, and usage patterns.

Public streams

No authentication required. Each returns a WebSocketStream<T> you subscribe to with .on("message", …).

MethodPayload typeDescription
trades(symbol, options?)TradeReal-time trade prints
bookTicker(symbol, options?)BookTickerBest bid/ask updates
depthUpdates(symbol, options?)DepthUpdateIncremental order book diffs
depth(symbol, options)OrderBookSnapshotPeriodic top-N depth snapshots (options.levels: 5, 10, or 20)
contractStatus(options?)ContractStatusPrediction market contract status changes
rfqs(options?)RfqPublicEventPublic request-for-quote events (sandbox/planning only — not enabled in production)

Authenticated streams

Require an auth strategy and the server entry point (browser WebSocket cannot set upgrade headers).

MethodPayload typeDescription
orders(options)OrderUpdateOrder lifecycle updates (options.scope: "account" or "session")
balances(options?)BalanceUpdateBalance changes (options.intervalMs: 0 or 1000)
positions(options?)PositionReportPosition updates (options.intervalMs: 0 or 1000)
rfqDeliveries(options)RfqPrivateDeliveryPrivate RFQ delivery confirmations (options.scope) (sandbox/planning only — not enabled in production)

Request/response methods

These send a request and resolve with a response, rather than streaming.

MethodReturnsDescription
placeOrder(params, options?)OrderActionResponsePlace an order over WebSocket
cancelOrder(params, options?)OrderActionResponseCancel a single order
cancelAllOrders(options)OrderActionResponseCancel all orders (options.confirm must be true)
cancelSessionOrders(options)OrderActionResponseCancel session orders (options.confirm must be true)
ping(options?)GenericSuccessResponseRound-trip liveness check
time(options?)GenericSuccessResponseServer time
conninfo(options?)GenericSuccessResponseConnection info
listSubscriptions(options?)ListSubscriptionsResponseCurrent active subscriptions
depthSnapshot(symbol, options?)DepthResponseOne-shot depth snapshot

RFQ quote methods

Note: RFQ streams and methods are currently sandbox/planning only and are not enabled in production.

Accessed via client.websocket.rfq:

MethodParamsReturns
rfq.submitQuote(params, options?)RfqSubmitQuoteParamsRfqSubmitQuoteResponse
rfq.withdrawQuote(params, options?)RfqWithdrawQuoteParamsRfqWithdrawQuoteResponse
rfq.confirmQuote(params, options?)RfqConfirmQuoteParamsRfqConfirmQuoteResponse

Wire format

WebSocket payloads use single-letter field names. These are the exact fields on each type. Prices and quantities are decimal strings (never floats — see Data Types); timestamps and IDs may be bigint.

Trade

Code
const trades = client.websocket.trades("BTCUSD"); trades.on("message", (t) => console.log(t.p, t.q, t.m));
FieldTypeMeaning
Enumber | bigintEvent time (nanoseconds)
sstringSymbol
tnumber | bigintTrade ID
pstringPrice
qstringQuantity
mbooleanWhether the buyer is the maker

BookTicker

FieldTypeMeaning
unumber | bigintUpdate ID
Enumber | bigintEvent time (nanoseconds)
sstringSymbol
bstringBest bid price
BstringBest bid quantity
astringBest ask price
AstringBest ask quantity
cstring?Last trade price (present once the book has traded)
Cstring?Last trade quantity

DepthUpdate

FieldTypeMeaning
e"depthUpdate"Event type discriminator
Enumber | bigintEvent time (nanoseconds)
sstringSymbol
Unumber | bigintFirst update ID in this diff
unumber | bigintLast update ID in this diff
bstring[][]Bid changes as [price, quantity] pairs
astring[][]Ask changes as [price, quantity] pairs

A quantity of "0" means the level was removed. See Order Book Reconstruction for how the SDK applies these.

OrderUpdate

Code
const orders = client.websocket.orders({ scope: "session" }); orders.on("message", (o) => console.log(o.i, o.X, o.z));
FieldTypeMeaning
e"orderUpdate"Event type discriminator
Enumber | bigintEvent time (nanoseconds)
sstringSymbol
inumber | bigintOrder ID
cstring?Client order ID
S"BUY" | "SELL" (optional)Side
o"LIMIT" | "MARKET" | "STOP_LIMIT" | "STOP_MARKET" (optional)Order type
X"NEW" | "OPEN" | "FILLED" | "PARTIALLY_FILLED" | "CANCELED" | "REJECTED" | "MODIFIED"Order status
O"YES" | "NO" (optional)Prediction outcome
pstring?Order price
Pstring?Stop price
qstring?Order quantity
zstring?Remaining quantity
Zstring?Executed quantity (last fill for FILLED/PARTIALLY_FILLED; cumulative for CANCELED and other terminal events)
Lstring?Last fill price
tnumber | bigint (optional)Trade ID of the last fill
nstring?Commission
mboolean?Whether this order was the maker
rstring?Reject reason
Tnumber | bigintTransaction time (nanoseconds)

BalanceUpdate

Code
const balances = client.websocket.balances(); balances.on("message", (u) => { for (const b of u.B) console.log(b.a, b.f, b.c); });
FieldTypeMeaning
e"balanceUpdate"Event type discriminator
Enumber | bigintEvent time (nanoseconds)
unumber | bigintUpdate ID
BBalance[]Balance entries

Each Balance:

FieldTypeMeaning
astringAsset
fstringFree (available) balance
cstringLocked balance

PositionReport

FieldTypeMeaning
e"positionReport"Event type discriminator
Enumber | bigintEvent time (nanoseconds)
unumber | bigintLast account-update timestamp (nanoseconds)
Anumber | bigintAccount reference
PPositionRow[]Position entries

Each PositionRow:

FieldTypeMeaning
tstringType
sstringSymbol
aNamedAmount[]Named amounts for the position

ContractStatus

FieldTypeMeaning
e"contractStatus"Event type discriminator
Enumber | bigintEvent time (milliseconds)
sstringSymbol
kstringEvent ticker
cstringContract ticker
inumber | bigintContract ID
pstring?Price
ostringPrevious status
nstringNew status

What's next

  • Order Book Reconstruction — how depth diffs become a live book
  • RFQ Protocol — the request-for-quote maker flow
  • Data Types — why timestamps are bigint and prices are strings
Last modified on August 14, 2026
MarginDeep Dives
On this page
  • Public streams
  • Authenticated streams
  • Request/response methods
    • RFQ quote methods
  • Wire format
    • Trade
    • BookTicker
    • DepthUpdate
    • OrderUpdate
    • BalanceUpdate
    • PositionReport
    • ContractStatus
  • What's next
TypeScript
TypeScript
TypeScript