This documentation is archived for reference only. These APIs have been replaced by the new WebSocket API. Start new integrations with the new WebSocket API.
Order Events
Order events is a private API that gives you information about your orders in real time. When you connect, you get a book of your active orders. Then in real time you receive information about order events like acceptance, booking, fills, cancels, and more.
WebSocket Request
wss://api.gemini.com/v1/order/events
The API key must have the Trader or Auditor role assigned.
Using a Master scoped API key receives event data for all accounts in the group.
Headers
| Header | Value |
|---|---|
X-GEMINI-APIKEY | Your Gemini API session key |
X-GEMINI-PAYLOAD | Base64-encoded JSON: {"request": "/v1/order/events", "nonce": 123456} |
X-GEMINI-SIGNATURE | See Private API Invocation |
URL Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
symbolFilter | string | No | Optional symbol filter |
apiSessionFilter | string | No | Optional API session key filter |
eventTypeFilter | string | No | Optional event type filter |
heartbeat | boolean | No | Stream heartbeats (default: false) |
Python Example
Code
Response
Once your WebSocket session is established, you will receive:
- A subscription acknowledgement
- A list of your active orders (unless filtered out)
- Ongoing order events interspersed with heartbeats every five seconds
Common Fields
These fields are common to all order events except subscription_ack and heartbeat.
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Event type: accepted, booked, fill, cancelled, etc. |
socket_sequence | integer | Yes | Monotonic increasing sequence number |
order_id | string | Yes | Order ID assigned by Gemini |
event_id | string | Yes* | Event ID (not present for initial events) |
account_name | string | No | Account name (Master scoped API keys only) |
api_session | string | Yes* | API session key (UI for website orders) |
client_order_id | string | No | Client-specified order ID |
symbol | string | Yes | Symbol of the order |
side | string | Yes | buy or sell |
behavior | string | No | immediate-or-cancel, fill-or-kill, or maker-or-cancel |
order_type | string | Yes | Description of the order |
timestamp | string | Yes | Timestamp in seconds (use timestampms instead) |
timestampms | timestampms | Yes | Timestamp in milliseconds |
is_live | boolean | Yes | true if the order is active on the book |
is_cancelled | boolean | Yes | true if the order has been canceled |
is_hidden | boolean | Yes | true if the order is active but not visible |
avg_execution_price | decimal | No | Average execution price (0 if unfilled) |
executed_amount | decimal | No | Amount filled |
remaining_amount | decimal | No | Amount remaining (absent for market buys) |
original_amount | decimal | No | Original quantity (absent for market buys) |
price | decimal | No | Limit order price (absent for market orders) |
total_spend | decimal | No | Total spend for market buys |
Event Types
| Event Type | Filterable | Description |
|---|---|---|
subscription_ack | No | Acknowledges your subscription and echoes back parsed filters |
heartbeat | Yes | Sent every 5 seconds to show connection is alive |
initial | Yes | Current active orders at subscription time |
accepted | Yes | Order accepted for initial processing |
rejected | Yes | Order rejected |
booked | Yes | Order visible on the order book |
fill | Yes | Order filled (partial or complete) |
cancelled | Yes | Order cancelled |
cancel_rejected | Yes | Cancel request could not be fulfilled |
closed | Yes | Last event in order lifecycle |
Subscription Acknowledgement
Code
Heartbeat
Code
Active Orders (Initial)
Code
Accepted
Your order is now live on the exchange. Possible outcomes:
- Immediate fill followed by
booked(remaining qty) orclosed(fully filled) cancelledthenclosed(behavior constraints not met)- Market orders:
fillevent(s) followed byclosed
Code
Rejected
Code
Booked
When limit orders are booked, they have a non-zero quantity visible on the exchange. Market orders are never booked.
Code
Fill
A fill event indicates a partial or complete fill. A complete fill is distinguished by remaining_amount of 0. The fill.price is the execution price (always present), while price is the original limit order price.
| Field | Type | Description |
|---|---|---|
fill.trade_id | string | Event id the order was filled at |
fill.liquidity | string | Maker or Taker |
fill.price | decimal | Execution price |
fill.amount | decimal | Amount of the trade fill |
fill.fee | decimal | Fee for this side of the trade |
fill.fee_currency | string | Currency code of the fee |
Code
Cancelled
Orders may be cancelled because you requested it, behavior constraints couldn't be fulfilled, FIX connection was disconnected, or heartbeat timeout.
| Field | Type | Description |
|---|---|---|
cancel_command_id | string | Event id of the cancel command |
reason | string | Reason for cancellation |
Code
Cancel Rejected
Code
Closed
The closed event is the last event in the lifecycle of any order that has been accepted. Your order has been removed from the book.
Code
Filtering
Filtering is completely optional. If you don't specify any filters, you'll see all your order events for every symbol, every API session and the UI, every event type.
Filtering works by whitelisting. You can filter on any combination of:
- One or more supported symbols
- One or more API session keys (use
UIfor website orders) - One or more event types
To provide multiple arguments, repeat the parameter:
Code
You cannot filter out heartbeat events or your subscription acknowledgement.
Workflow
- Client submits order to Gemini exchange
- Is the order accepted?
- Yes: Gemini sends
accepted, then zero or morefillevents- If remaining quantity:
bookedevent, order rests until cancelled or filled - If fully filled:
closedevent
- If remaining quantity:
- No: Gemini sends
rejected, no further events
- Yes: Gemini sends

