Create New Order
If you wish orders to be automatically cancelled when your session ends, see the require heartbeat section, or manually send the cancel all session orders message.
Roles
The API key you use to access this endpoint must have the Trader role assigned. See Roles for more information.
The OAuth scope must have orders:create assigned to access this endpoint. See OAuth Scopes for more information.
Margin Orders
Set margin_order: true to place an order using borrowed funds on a margin-enabled account. This allows you to trade with leverage beyond your available balance.
Important: Margin trading amplifies both gains and losses. Monitor your account using the Margin Account Summary endpoint and preview order impacts with Order Preview before placing margin orders.
Stop-Limit Orders
A Stop-Limit order is an order type that allows for order placement when a price reaches a specified level. Stop-Limit orders take in both a price and and a stop_price as parameters. The stop_price is the price that triggers the order to be placed on the continous live order book at the price. For buy orders, the stop_price must be below the price while sell orders require the stop_price to be greater than the price.
What about market orders?
The API doesn't directly support market orders because they provide you with no price protection.
Instead, use the “immediate-or-cancel” order execution option, coupled with an aggressive limit price (i.e. very high for a buy order or very low for a sell order), to achieve the same result.
Order execution options
Note that options is an array. If you omit options or provide an empty array, your order will be a standard limit order - it will immediately fill against any open orders at an equal or better price, then the remainder of the order will be posted to the order book.
If you specify more than one option (or an unsupported option) in the options array, the exchange will reject your order.
No options can be applied to stop-limit orders at this time.
The available limit order options are:
| Option | Description |
|---|---|
"maker-or-cancel" | This order will only add liquidity to the order book. If any part of the order could be filled immediately, the whole order will instead be canceled before any execution occurs. If that happens, the response back from the API will indicate that the order has already been canceled ( "is_cancelled": true in JSON).Note: some other exchanges call this option "post-only". |
"immediate-or-cancel" | This order will only remove liquidity from the order book. It will fill whatever part of the order it can immediately, then cancel any remaining amount so that no part of the order is added to the order book. If the order doesn't fully fill immediately, the response back from the API will indicate that the order has already been canceled ( "is_cancelled": true in JSON). |
"fill-or-kill" | This order will only remove liquidity from the order book. It will fill the entire order immediately or cancel. If the order doesn't fully fill immediately, the response back from the API will indicate that the order has already been canceled ( "is_cancelled": true in JSON). |
Headers
X-GEMINI-APIKEYYour API key
X-GEMINI-SIGNATUREHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADBase64-encoded JSON payload
Content-TypeContent-LengthCache-ControlCreate New Order › Request Body
requestThe literal string "/v1/order/new"
nonceThe nonce, as described in Private API Invocation
symbolThe symbol for the new order
amountQuoted decimal amount to purchase
priceQuoted decimal amount to spend per unit
sidetypeThe order type. "exchange limit" for all order types except for stop-limit orders. "exchange stop limit" for stop-limit orders.
client_order_idRecommended. A client-specified order id
optionsAn optional array containing at most one supported order execution option. See Order execution options for details.
stop_priceThe price to trigger a stop-limit order. Only available for stop-limit orders.
margin_orderSet to true to place this order on a margin account using borrowed funds. Defaults to false. Only available for margin-enabled accounts. See Margin Trading for details.
accountRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group. Specifies the account on which you intend to place the order. Only available for exchange accounts.
Create New Order › Responses
Response will be the fields included in Order Status
Decision Table
| Variant | Matching Criteria |
|---|---|
| type = object | |
| type = object |
order_ididsymbolexchangeavg_execution_pricesidetypetimestamp
timestamp
is_liveis_cancelledis_hiddenwas_forcedexecuted_amountremaining_amountclient_order_idoptionspriceoriginal_amountCancel Order
This will cancel an order. If the order is already canceled, the message will succeed but have no effect.
Roles
The API key you use to access this endpoint must have the Trader role assigned. See Roles for more information.
The OAuth scope must have orders:create assigned to access this endpoint. See OAuth Scopes for more information.
All Cancellation Reasons
Under unique circumstances, orders may be automatically cancelled by the exchange. These scenarios are detailed in the table below:
| Cancel Reason | Description |
|---|---|
MakerOrCancelWouldTake | Occurs when the "maker-or-cancel" execution option is included in the order request and any part of the requested order could be filled immediately. |
ExceedsPriceLimits | Occurs when there is not sufficient liquidity on the order book to support the entered trade. Orders will be automatically cancelled when liquidity conditions are such that the order would move price +/- 5%. |
SelfCrossPrevented | Occurs when a user enters a bid that is higher than that user's lowest open ask or enters an ask that is lower than their highest open bid on the same pair. |
ImmediateOrCancelWouldPost | Occurs when the "immediate-or-cancel" execution option is included in the order request and the requested order cannot be fully filled immediately. This type of cancellation will only cancel the unfulfilled part of any impacted order. |
FillOrKillWouldNotFill | Occurs when the "fill-or-kill" execution option is included in the new order request and the entire order cannot be filled immediately. Unlike "immediate-or-cancel" orders, this execution option will result in the entire order being cancelled rather than just the unfulfilled portion. |
Requested | Cancelled via user request to /v1/order/cancel endpoint. |
MarketClosed | Occurs when an order is placed for a trading pair that is currently closed. |
TradingClosed | Occurs when an order is placed while the exchange is closed for trading. |
Headers
X-GEMINI-APIKEYYour API key
X-GEMINI-SIGNATUREHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADBase64-encoded JSON payload
Content-TypeContent-LengthCache-ControlCancel Order › Request Body
requestThe literal string "/v1/order/cancel"
timestamp
order_idThe order ID given by /order/new
accountRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group. Specifies the account on which you intend to cancel the order. Only available for exchange accounts.
Cancel Order › Responses
Response will be the fields included in Order Status. If the order was already canceled, then the request will have no effect and the status will be returned. Note the is_cancelled node will have a value of 'true'
order_ididsymbolexchangeavg_execution_pricesidetypetimestamp
timestamp
is_liveis_cancelledis_hiddenwas_forcedexecuted_amountremaining_amountreasonoptionspriceoriginal_amountCancel All Active Orders
This will cancel all outstanding orders created by all sessions owned by this account, including interactive orders placed through the UI.
Typically Cancel All Session Orders is preferable, so that only orders related to the current connected session are cancelled.
Roles
The API key you use to access this endpoint must have the Trader role assigned. See Roles for more information.
The OAuth scope must have orders:create assigned to access this endpoint. See OAuth Scopes for more information.
Headers
X-GEMINI-APIKEYYour API key
X-GEMINI-SIGNATUREHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADBase64-encoded JSON payload
Content-TypeContent-LengthCache-ControlCancel All Active Orders › Request Body
requestThe literal string "/v1/order/cancel/all"
timestamp
accountRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group. Specifies the account on which you intend to cancel the orders. Only available for exchange accounts.
Cancel All Active Orders › Responses
JSON response
resultcancelledOrders/cancelRejects with IDs of both
Cancel All Session Orders
This will cancel all orders opened by this session.
This will have the same effect as heartbeat expiration if "Require Heartbeat" is selected for the session.
Roles
The API key you use to access this endpoint must have the Trader role assigned. See Roles for more information.
The OAuth scope must have orders:create assigned to access this endpoint. See OAuth Scopes for more information.
Headers
X-GEMINI-APIKEYYour API key
X-GEMINI-SIGNATUREHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADBase64-encoded JSON payload
Content-TypeContent-LengthCache-ControlCancel All Session Orders › Request Body
requestThe literal string "/v1/order/cancel/session"
timestamp
accountRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group. Specifies the account on which you intend to cancel the orders. Only available for exchange accounts.
Cancel All Session Orders › Responses
JSON response
resultcancelledOrders/cancelRejects with IDs of both
Get Order Status
Roles
The API key you use to access this endpoint must have the Trader role assigned. See Roles for more information.
The OAuth scope must have orders:read assigned to access this endpoint. See OAuth Scopes for more information.
Headers
X-GEMINI-APIKEYYour API key
X-GEMINI-SIGNATUREHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADBase64-encoded JSON payload
Content-TypeContent-LengthCache-ControlGet Order Status › Request Body
requestThe API endpoint path
timestamp
order_idThe order id to get information on. The order_id represents a whole number and is transmitted as an unsigned 64-bit integer in JSON format. order_id cannot be used in combination with client_order_id.
accountRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group. Specifies the account on which you intend to place the order. Only available for exchange accounts.
client_order_idThe client_order_id used when placing the order. client_order_id cannot be used in combination with order_id
include_tradesEither True or False. If True the endpoint will return individual trade details of all fills from the order.
Get Order Status › Responses
The order status
order_idThe order id
client_order_idAn optional client-specified order id
symbolThe symbol of the order
exchangeWill always be "gemini"
priceThe price the order was issued at
avg_execution_priceThe average price at which this order as been executed so far. 0 if the order has not been executed at all.
sidetypeDescription of the order
optionsAn array containing at most one supported order execution option. See Order execution options for details.
timestamp
timestamp
is_livetrue if the order is active on the book (has remaining quantity and has not been canceled)
is_cancelledtrue if the order has been canceled. Note the spelling, "cancelled" instead of "canceled". This is for compatibility reasons.
reasonPopulated with the reason your order was canceled, if available.
was_forcedWill always be false.
executed_amountThe amount of the order that has been filled.
remaining_amountThe amount of the order that has not been filled.
original_amountThe originally submitted amount of the order.
is_hiddenWill always return false.
Contains an array of JSON objects with trade details.
List Active Orders
Roles
The API key you use to access this endpoint must have the Trader or Auditor role assigned. See Roles for more information.
The OAuth scope must have orders:read assigned to access this endpoint. See OAuth Scopes for more information.
Headers
X-GEMINI-APIKEYYour API key
X-GEMINI-SIGNATUREHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADBase64-encoded JSON payload
Content-TypeContent-LengthCache-ControlList Active Orders › Request Body
requestThe API endpoint path
timestamp
accountRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group. Specifies the account on which you intend to place the order. Only available for exchange accounts.
List Active Orders › Responses
The active orders
order_idThe order id
client_order_idAn optional client-specified order id
symbolThe symbol of the order
exchangeWill always be "gemini"
priceThe price the order was issued at
avg_execution_priceThe average price at which this order as been executed so far. 0 if the order has not been executed at all.
sidetypeDescription of the order
optionsAn array containing at most one supported order execution option. See Order execution options for details.
timestamp
timestamp
is_livetrue if the order is active on the book (has remaining quantity and has not been canceled)
is_cancelledtrue if the order has been canceled. Note the spelling, "cancelled" instead of "canceled". This is for compatibility reasons.
reasonPopulated with the reason your order was canceled, if available.
was_forcedWill always be false.
executed_amountThe amount of the order that has been filled.
remaining_amountThe amount of the order that has not been filled.
original_amountThe originally submitted amount of the order.
is_hiddenWill always return false.
Contains an array of JSON objects with trade details.
List Past Orders
This API retrieves (closed) orders history for an account.
Roles
The API key you use to access this endpoint must have the Trader or Auditor role assigned. See Roles for more information.
The OAuth scope must have history:read assigned to access this endpoint. See OAuth Scopes for more information.
How to retrieve your order history
To retrieve your full order history walking backwards,
- Initial request:
POSTto https://api.gemini.com/v1/orders/history with a JSON payload including atimestampkey with value0and alimit_orderskey with value500 - When you receive the list of orders, it will be sorted by
timestampdescending - so the first element in the list will have the highesttimestampvalue. For this example, say that value isX. - Create a second
POSTrequest with a JSON payload including atimestampkey with valueX+1and alimit_orderskey with value500. - Take the first element of the list returned with highest
timestampvalueYand create a thirdPOSTrequest with a JSON payload including atimestampkey with valueY+1and alimit_orderskey with value500. - Continue creating
POSTrequests and retrieving orders until an empty list is returned.
Break Types
In the rare event that a trade has been reversed (broken), the trade that is broken will have this flag set. The field will contain one of these values
| Value | Description |
|---|---|
| manual | The trade was reversed manually. This means that all fees, proceeds, and debits associated with the trade have been credited or debited to the account seperately. That means that this reported trade must be included for order for the account balance to be correct. |
| full | The trade was fully broken. The reported trade should not be accounted for. It will be as though the transfer of fund associated with the trade had simply not happened. |
Headers
X-GEMINI-APIKEYYour API key
X-GEMINI-SIGNATUREHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADBase64-encoded JSON payload
Content-TypeContent-LengthCache-ControlList Past Orders › Request Body
requestThe API endpoint /v1/orders/history
The nonce, as described in Private API Invocation
symbolThe symbol to retrieve orders for
limit_ordersThe maximum number of orders to return. Default is 50, max is 500.
In iso datetime with timezone format from that date you will get order history
accountRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group.
List Past Orders › Responses
Successful operation
order_idThe order id
client_order_idAn optional client-specified order id
symbolThe symbol of the order
exchangeWill always be "gemini"
priceThe price the order was issued at
avg_execution_priceThe average price at which this order as been executed so far. 0 if the order has not been executed at all.
sidetypeDescription of the order
optionsAn array containing at most one supported order execution option. See Order execution options for details.
timestamp
timestamp
is_livetrue if the order is active on the book (has remaining quantity and has not been canceled)
is_cancelledtrue if the order has been canceled. Note the spelling, "cancelled" instead of "canceled". This is for compatibility reasons.
reasonPopulated with the reason your order was canceled, if available.
was_forcedWill always be false.
executed_amountThe amount of the order that has been filled.
remaining_amountThe amount of the order that has not been filled.
original_amountThe originally submitted amount of the order.
is_hiddenWill always return false.
Contains an array of JSON objects with trade details.
List Past Trades
Roles
The API key you use to access this endpoint must have the Trader or Auditor role assigned. See Roles for more information.
The OAuth scope must have history:read assigned to access this endpoint. See OAuth Scopes for more information.
How to retrieve your trade history
To retrieve your full trade history walking backwards,
- Initial request:
POSTto https://api.gemini.com/v1/mytrades with a JSON payload including atimestampkey with value 0 and alimit_tradeskey with value500 - When you receive the list of trades, it will be sorted by
timestampdescending - so the first element in the list will have the highesttimestampvalue. For this example, say that value isX. - Create a second
POSTrequest with a JSON payload including atimestampkey with valueX+1and alimit_tradeskey with value500. - Take the first element of the list returned with highest
timestampvalueYand create a thirdPOSTrequest with a JSON payload including atimestampkey with valueY+1and alimit_tradeskey with value500. - Continue creating
POSTrequests and retrieving trades until an empty list is returned.
Break Types
In the rare event that a trade has been reversed (broken), the trade that is broken will have this flag set. The field will contain one of these values
| Value | Description |
|---|---|
| manual | The trade was reversed manually. This means that all fees, proceeds, and debits associated with the trade have been credited or debited to the account seperately. That means that this reported trade must be included for order for the account balance to be correct. |
| full | The trade was fully broken. The reported trade should not be accounted for. It will be as though the transfer of fund associated with the trade had simply not happened. |
Headers
X-GEMINI-APIKEYYour API key
X-GEMINI-SIGNATUREHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADBase64-encoded JSON payload
Content-TypeContent-LengthCache-ControlList Past Trades › Request Body
requestThe API endpoint path
timestamp
accountRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group. Specifies the account on which you intend to place the order. Only available for exchange accounts.
symbolThe symbol to retrieve trades for
limit_tradesThe maximum number of trades to return. Default is 50, max is 500.
timestamp
List Past Trades › Responses
The past trades
priceamounttimestamp
timestamp
typeaggressorfee_currencyfee_amounttidorder_idclient_order_idexchangeis_auction_fillbreakGet Trading Volume
Roles
The API key you use to access this endpoint must have the Trader or Auditor role assigned. See Roles for more information.
The OAuth scope must have history:read assigned to access this endpoint. See OAuth Scopes for more information.
Headers
X-GEMINI-APIKEYYour API key
X-GEMINI-SIGNATUREHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADBase64-encoded JSON payload
Content-TypeContent-LengthCache-ControlGet Trading Volume › Request Body
requestThe API endpoint path
timestamp
accountRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group. Specifies the account on which you intend to place the order. Only available for exchange accounts.
Get Trading Volume › Responses
The trade volume
symbolbase_currencyquote_currencynotional_currencydata_datetotal_volume_basemaker_buy_sell_ratiobuy_maker_basebuy_maker_notionalbuy_maker_countsell_maker_basesell_maker_notionalsell_maker_countbuy_taker_basebuy_taker_notionalbuy_taker_countsell_taker_basesell_taker_notionalsell_taker_countGet Notional Trading Volume
Roles
The API key you use to access this endpoint must have the Trader or Auditor role assigned. See Roles for more information.
The OAuth scope must have history:read assigned to access this endpoint. See OAuth Scopes for more information.
Headers
X-GEMINI-APIKEYYour API key
X-GEMINI-SIGNATUREHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADBase64-encoded JSON payload
Content-TypeContent-LengthCache-ControlGet Notional Trading Volume › Request Body
requestThe API endpoint path
timestamp
accountRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group. Specifies the account on which you intend to place the order. Only available for exchange accounts.
Get Notional Trading Volume › Responses
The notional volume
datelast_updated_msweb_maker_fee_bpsweb_taker_fee_bpsweb_auction_fee_bpsapi_maker_fee_bpsapi_taker_fee_bpsapi_auction_fee_bpsfix_maker_fee_bpsfix_taker_fee_bpsfix_auction_fee_bpsnotional_30d_volumeapi_notional_30d_volumeWrap Order
Roles
The API key you use to access this endpoint must have the Trader role assigned. See Roles for more information.
The OAuth scope must have orders:create assigned to access this endpoint. See OAuth Scopes for more information.
path Parameters
symbolTrading pair symbol
BTCUSD, etc. See symbols and minimums.
Headers
X-GEMINI-APIKEYYour API key
X-GEMINI-SIGNATUREHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADBase64-encoded JSON payload
Content-TypeContent-LengthCache-ControlWrap Order › Request Body
requestThe literal string "/v1/wrap/symbol"
The nonce, as described in Private API Invocation
amountThe amount to wrap
side"buy" or "sell"
client_order_idA client-specified order id
accountRequired for Master API keys. The name of the account within the subaccount group.
Wrap Order › Responses
Successful operation
orderIdThe order ID
pairTrading pair symbol
priceThe price of the order
priceCurrencyThe currency in which the order is priced
sideEither "buy" or "sell"
quantityThe amount that was executed
quantityCurrencyThe currency label for the quantity field
totalSpendTotal quantity spent for the order
totalSpendCurrencyCurrency of the totalSpend
feeThe amount charged
feeCurrencyCurrency that the fee was paid in
depositFeeThe deposit fee quantity
depositFeeCurrencyCurrency in which depositFee is taken

