Spot crypto
发布时间:2026-08-26 | 浏览:1
Discover crypto markets, place spot orders, and manage balances through Gemini's REST, WebSocket, and FIX interfaces.
Spot crypto REST API
Place spot orders, query market data, and manage crypto balances.
Get your API credentials
Sign up at exchange.gemini.com , navigate to Settings → API , and create a key with the Trading scope enabled.
Clone the samples repo and install dependencies
Clone the Gemini API samples repository, navigate to the Python directory, and install the required packages ( requests and python-dotenv ).
Configure your environment
Create a .env file with your API credentials and the sandbox base URL. The sample uses python-dotenv to load these automatically.
Run the place order example
Run the example to place a sandbox limit order. The script handles HMAC-SHA384 signing automatically.
Your order is live in the sandbox. Check the response for order_id and use it to query status or cancel.
Stream real-time prices, place orders, and receive fill notifications over a persistent WebSocket connection to wss://ws.gemini.com .
Set up credentials
Export your API key and secret as environment variables. WebSocket authentication requires account-scoped keys with time-based nonces enabled — keys without these settings will be rejected at connection time.
Connect and stream prices
Connect to wss://ws.gemini.com , sign the handshake headers with your secret, then subscribe to {symbol} @bookTicker for real-time best-bid/ask updates.
Subscribe to orders@account alongside the price stream, then send order.place once you see a price. Use cancelOnDisconnect=true as a query parameter to automatically cancel open orders if your connection drops.
Listen for fills & cancel
Order lifecycle events arrive on the orders@account stream. The X field carries the status ( NEW , FILLED , etc.). To cancel, send order.cancel with the order ID from the i field.