GeminiGemini
Demo environmentGet API key
  • Overview
  • Crypto Trading
  • Prediction Markets
  • Perpetuals
  • Stocks
  • API Reference
  • SDKs & Tools
Changelog
Gemini logoGemini logo

© 2026 Gemini Space Station, Inc.

Overview
Core Concepts
    Events, contracts, and outcomesCombo contracts
Market Data
    OverviewFetching Markets
    Ticker formats
      OverviewCryptoSportsSports Market TaxonomyCommoditiesWeather
Trading
    QuickstartOrder lifecycle and settlement
    Full REST reference
      Combo RFQ
      Events
      Volume
      Terms
      Order Management
      Positions
      Rewards
    WebSocket APIs
      OverviewAuthenticationMessage format
      Streams
        Book tickerL2 partial depthL2 differential depthTrade streamOrder eventsBalance updatesPosition updatesContract statusPrediction
      Utility
      Subscriptions
      L2 Data
      Order management
      Combo RFQ
        OverviewWebSocket streamsQuote methodsMaker integrationExamples
Market Makers
    Maker Fee-Free Trading PromoTaker Rewards ProgramMaker Rebate ProgramLiquidity Rewards ProgramMarket Maker Program
Resources
    SchemasDemo environmentRate limitsErrors
AuthenticationMessage Format
Streams
    OverviewBook TickerL2 Partial DepthL2 Differential DepthTrade StreamOrder EventsBalance Updates
Utility
    conninfopingsubscribelist_subscriptionsunsubscribetime
L2 Data
    depth
Trading
    order.cancelorder.cancel_allorder.cancel_sessionorder.placerfq.confirm_quoterfq.createrfq.submit_quoterfq.withdraw_quote

Authentication

Core API

Prediction Markets uses the core WebSocket authentication protocol. Product access and terms acceptance are separate prerequisites.

Generate an API Key

API keys for our WebSocket API have special requirements:

  1. Navigate to API Settings
  2. Click "Create API key"
  3. Scope: Select the account you want to trade with
  4. Settings:
    • Enable "Uses a time-based nonce"
    • Select Trader for trading methods such as order.place; Auditor or Trader is sufficient for positions@account
  5. Save your API key and secret securely

Only account-scoped keys with time-based nonces are accepted. Account keys use the account-... prefix. Master or group keys, such as master-... keys, are rejected with HTTP 401.


Create an Authenticated Connection

Connect to wss://ws.gemini.com and pass the following headers when establishing the WebSocket connection:

HeaderValue
X-GEMINI-APIKEYYour account-scoped Gemini API key
X-GEMINI-NONCEDecimal nonce
X-GEMINI-PAYLOADbase64(string(nonce))
X-GEMINI-SIGNATUREhex(hmac_sha384(payload, api_secret))

Auditor or Trader role is sufficient for positions@account. Trader role is required for trading operations such as order.place.

Before sending trading orders, check GET /v1/prediction-markets/terms/status. If hasAcceptedLatest is false, display GET /v1/prediction-markets/terms and accept with POST /v1/prediction-markets/terms/accept, then retry the order.

Authentication headers must be provided during the initial WebSocket handshake. You cannot authenticate after the connection is established.

Signature Generation Step-by-Step

Code
# Create a monotonically increasing integer nonce. # Unix seconds or Unix milliseconds are both accepted, but the value must # increase across connections for the same key. nonce = current_unix_timestamp_in_seconds_or_milliseconds # Base64 encode the string form of the nonce. payload = base64_encode(string(nonce)) # Generate a signature using the hmac_sha384 algorithm. signature = hmac_sha384(payload, api_secret) # Convert the signature to hex so it can be passed in the headers. hexSignature = hex(signature)

Alternative: OAuth 2.0 Bearer Token

If your application uses OAuth 2.0 to access the Gemini API, you can authenticate the WebSocket connection with the same access token instead of provisioning an API key.

Pass the access token in the Authorization header on the WebSocket upgrade request:

HeaderValue
AuthorizationBearer <access_token>

When using OAuth, you do not send the X-GEMINI-APIKEY, X-GEMINI-NONCE, X-GEMINI-PAYLOAD, or X-GEMINI-SIGNATURE headers.

The access token must include a position scope for positions@account: positions:read or predictions:positions:read. See OAuth scopes.

Access tokens are short-lived (default 24 hours). If the token expires during a session, the server will close the connection and you must reconnect with a refreshed token — tokens cannot be rotated on a live connection. See Using Refresh Tokens.

Streams
On this page
  • Generate an API Key
  • Create an Authenticated Connection
    • Signature Generation Step-by-Step
  • Alternative: OAuth 2.0 Bearer Token