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.
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-APIKEYstring · requiredYour API key
X-GEMINI-SIGNATUREstring · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADstring · requiredBase64-encoded JSON payload
Content-TypestringDefault: text/plainContent-LengthstringDefault: 0Cache-ControlstringDefault: no-cache
Request Body
requeststring · requiredThe literal string "/v1/order/new"
Example: /v1/order/newnoncenumber · requiredThe nonce, as described in Private API Invocation
amountstring · requiredQuoted decimal amount to purchase
Example: 5pricestring · requiredQuoted decimal amount to spend per unit
Example: 3633.00sidestring · enum · requiredEnum values:buysellExample: buytypestring · enum · requiredThe order type. "exchange limit" for all order types except for stop-limit orders. "exchange stop limit" for stop-limit orders.
Enum values:exchange limitexchange stop limitexchange marketExample: exchange limit
client_order_idstringRecommended. A client-specified order id
optionsstring[]An optional array containing at most one supported order execution option. See Order execution options for details.
Enum values:maker-or-cancelimmediate-or-cancelfill-or-killExample: ["maker-or-cancel"]stop_pricestringThe price to trigger a stop-limit order. Only available for stop-limit orders.
accountstringRequired 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.
Responses
Response will be the fields included in Order Status
Decision Table
| Variant | Matching Criteria |
|---|---|
| type = object | |
| type = object |
order_idstringidstringsymbolstringexchangestringavg_execution_pricestringsidestring · enumEnum values:buyselltypestring · enumEnum values:exchange limitexchange stop limitexchange markettimestamptimestamp
timestampmstimestamp
is_livebooleanis_cancelledbooleanis_hiddenbooleanwas_forcedbooleanexecuted_amountstringremaining_amountstring · doubleclient_order_idstringoptionsstring[]pricestring · doubleoriginal_amountstring · double
Cancel 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-APIKEYstring · requiredYour API key
X-GEMINI-SIGNATUREstring · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADstring · requiredBase64-encoded JSON payload
Content-TypestringDefault: text/plainContent-LengthstringDefault: 0Cache-ControlstringDefault: no-cache
Request Body
requeststring · requiredThe literal string "/v1/order/cancel"
Example: /v1/order/cancelnoncerequiredtimestamp
order_idinteger · requiredThe order ID given by
/order/newExample: 106817811
accountstringRequired 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.
Example: primary
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_idstring · integeridstring · integersymbolstringexchangestringavg_execution_pricestring · doublesidestring · enumEnum values:buyselltypestring · enumEnum values:exchange limitexchange stop limitexchange markettimestamptimestamp
timestampmstimestamp
is_livebooleanis_cancelledbooleanis_hiddenbooleanwas_forcedbooleanexecuted_amountstring · doubleremaining_amountstring · doublereasonstring · enumEnum values:MakerOrCancelWouldTakeExceedsPriceLimitsSelfCrossPreventedImmediateOrCancelWouldPostFillOrKillWouldNotFillRequestedMarketClosedTradingClosedoptionsstring[]pricestring · doubleoriginal_amountstring · double
Cancel 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-APIKEYstring · requiredYour API key
X-GEMINI-SIGNATUREstring · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADstring · requiredBase64-encoded JSON payload
Content-TypestringDefault: text/plainContent-LengthstringDefault: 0Cache-ControlstringDefault: no-cache
Request Body
requeststring · requiredThe literal string "/v1/order/cancel/all"
Example: /v1/order/cancel/allnoncerequiredtimestamp
accountstringRequired 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.
Example: primary
Responses
JSON response
resultstringExample: okdetailsobjectcancelledOrders/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-APIKEYstring · requiredYour API key
X-GEMINI-SIGNATUREstring · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADstring · requiredBase64-encoded JSON payload
Content-TypestringDefault: text/plainContent-LengthstringDefault: 0Cache-ControlstringDefault: no-cache
Request Body
requeststring · requiredThe literal string "/v1/order/cancel/session"
Example: /v1/order/cancel/sessionnoncerequiredtimestamp
accountstringRequired 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.
Example: primary
Responses
JSON response
resultstringExample: okdetailsobjectcancelledOrders/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-APIKEYstring · requiredYour API key
X-GEMINI-SIGNATUREstring · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADstring · requiredBase64-encoded JSON payload
Content-TypestringDefault: text/plainContent-LengthstringDefault: 0Cache-ControlstringDefault: no-cache
Request Body
requeststring · requiredThe API endpoint path
Example: /v1/order/statusnoncerequiredtimestamp
order_idinteger · requiredThe order id to get information on. The
order_idrepresents a whole number and is transmitted as an unsigned 64-bit integer in JSON format.order_idcannot be used in combination withclient_order_id.Example: 123456789012345
accountstringRequired 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.
Example: primaryclient_order_idstringThe
client_order_idused when placing the order.client_order_idcannot be used in combination withorder_idinclude_tradesbooleanEither
TrueorFalse. IfTruethe endpoint will return individual trade details of all fills from the order.
Responses
The order status
order_idstring · integerThe order id
client_order_idstring · integerAn optional client-specified order id
symbolstringThe symbol of the order
exchangestringWill always be "gemini"
pricestring · decimalThe price the order was issued at
avg_execution_pricestring · decimalThe average price at which this order as been executed so far. 0 if the order has not been executed at all.
sidestring · enumEnum values:buyselltypestring · enumDescription of the order
Enum values:exchange limitexchange stop limitexchange marketoptionsstring[]An array containing at most one supported order execution option. See Order execution options for details.
timestamptimestamp
timestampmstimestamp
is_livebooleantrueif the order is active on the book (has remaining quantity and has not been canceled)is_cancelledbooleantrueif the order has been canceled. Note the spelling, "cancelled" instead of "canceled". This is for compatibility reasons.reasonstringPopulated with the reason your order was canceled, if available.
was_forcedbooleanWill always be
false.executed_amountstring · decimalThe amount of the order that has been filled.
remaining_amountstring · decimalThe amount of the order that has not been filled.
original_amountstring · decimalThe originally submitted amount of the order.
is_hiddenbooleanWill always return
false.tradesobject[]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-APIKEYstring · requiredYour API key
X-GEMINI-SIGNATUREstring · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADstring · requiredBase64-encoded JSON payload
Content-TypestringDefault: text/plainContent-LengthstringDefault: 0Cache-ControlstringDefault: no-cache
Request Body
requeststring · requiredThe API endpoint path
Example: /v1/ordersnonceTimestampType · requiredtimestamp
accountstringRequired 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.
Example: primary
Responses
The active orders
order_idstring · integerThe order id
client_order_idstring · integerAn optional client-specified order id
symbolstringThe symbol of the order
exchangestringWill always be "gemini"
pricestring · decimalThe price the order was issued at
avg_execution_pricestring · decimalThe average price at which this order as been executed so far. 0 if the order has not been executed at all.
sidestring · enumEnum values:buyselltypestring · enumDescription of the order
Enum values:exchange limitexchange stop limitexchange marketoptionsstring[]An array containing at most one supported order execution option. See Order execution options for details.
timestamptimestamp
timestampmstimestamp
is_livebooleantrueif the order is active on the book (has remaining quantity and has not been canceled)is_cancelledbooleantrueif the order has been canceled. Note the spelling, "cancelled" instead of "canceled". This is for compatibility reasons.reasonstringPopulated with the reason your order was canceled, if available.
was_forcedbooleanWill always be
false.executed_amountstring · decimalThe amount of the order that has been filled.
remaining_amountstring · decimalThe amount of the order that has not been filled.
original_amountstring · decimalThe originally submitted amount of the order.
is_hiddenbooleanWill always return
false.tradesobject[]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-APIKEYstring · requiredYour API key
X-GEMINI-SIGNATUREstring · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADstring · requiredBase64-encoded JSON payload
Content-TypestringDefault: text/plainContent-LengthstringDefault: 0Cache-ControlstringDefault: no-cache
Request Body
requeststring · requiredThe API endpoint
/v1/orders/history
symbolstringThe symbol to retrieve orders for
limit_ordersintegerThe maximum number of orders to return. Default is 50, max is 500.
Default: 50timestampIn iso datetime with timezone format from that date you will get order history
accountstringRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group.
Responses
Successful operation
order_idstring · integerThe order id
client_order_idstring · integerAn optional client-specified order id
symbolstringThe symbol of the order
exchangestringWill always be "gemini"
pricestring · decimalThe price the order was issued at
avg_execution_pricestring · decimalThe average price at which this order as been executed so far. 0 if the order has not been executed at all.
sidestring · enumEnum values:buyselltypestring · enumDescription of the order
Enum values:exchange limitexchange stop limitexchange marketoptionsstring[]An array containing at most one supported order execution option. See Order execution options for details.
timestamptimestamp
timestampmstimestamp
is_livebooleantrueif the order is active on the book (has remaining quantity and has not been canceled)is_cancelledbooleantrueif the order has been canceled. Note the spelling, "cancelled" instead of "canceled". This is for compatibility reasons.reasonstringPopulated with the reason your order was canceled, if available.
was_forcedbooleanWill always be
false.executed_amountstring · decimalThe amount of the order that has been filled.
remaining_amountstring · decimalThe amount of the order that has not been filled.
original_amountstring · decimalThe originally submitted amount of the order.
is_hiddenbooleanWill always return
false.tradesobject[]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-APIKEYstring · requiredYour API key
X-GEMINI-SIGNATUREstring · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADstring · requiredBase64-encoded JSON payload
Content-TypestringDefault: text/plainContent-LengthstringDefault: 0Cache-ControlstringDefault: no-cache
Request Body
requeststring · requiredThe API endpoint path
Example: /v1/mytradesnoncerequiredtimestamp
accountstringRequired 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.
Example: primarylimit_tradesintegerThe maximum number of trades to return. Default is 50, max is 500.
Example: 50timestamptimestamp
Responses
The past trades
pricestringExample: 9100amountstringExample: 1.5timestamptimestamp
timestampmstimestamp
typestring · enumEnum values:BuySellExample: BuyaggressorbooleanExample: truefee_currencystringExample: USDfee_amountstringExample: 13.65tidintegerExample: 123456789order_idstringExample: 123456789client_order_idstringexchangestringExample: geminiis_auction_fillbooleanExample: falsebreakstring · enumEnum values:trade correctExample:
Get 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-APIKEYstring · requiredYour API key
X-GEMINI-SIGNATUREstring · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADstring · requiredBase64-encoded JSON payload
Content-TypestringDefault: text/plainContent-LengthstringDefault: 0Cache-ControlstringDefault: no-cache
Request Body
requeststring · requiredThe API endpoint path
Example: /v1/tradevolumenonceTimestampType · requiredtimestamp
accountstringRequired 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.
Example: primary
Responses
The trade volume
symbolstringExample: btcusdbase_currencystringExample: BTCquote_currencystringExample: USDnotional_currencystringExample: USDdata_datestringExample: 2020-06-02total_volume_basestringExample: 10.5maker_buy_sell_ratiostringExample: 1.2buy_maker_basestringExample: 5.5buy_maker_notionalstringExample: 50050buy_maker_countintegerExample: 10sell_maker_basestringExample: 5sell_maker_notionalstringExample: 45500sell_maker_countintegerExample: 8buy_taker_basestringExample: 8.5buy_taker_notionalstringExample: 77350buy_taker_countintegerExample: 15sell_taker_basestringExample: 7.5sell_taker_notionalstringExample: 68250sell_taker_countintegerExample: 12
Get 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-APIKEYstring · requiredYour API key
X-GEMINI-SIGNATUREstring · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADstring · requiredBase64-encoded JSON payload
Content-TypestringDefault: text/plainContent-LengthstringDefault: 0Cache-ControlstringDefault: no-cache
Request Body
requeststring · requiredThe API endpoint path
Example: /v1/notionalvolumenonceTimestampType · requiredtimestamp
accountstringRequired 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.
Example: primary
Responses
The notional volume
datestring · dateExample: 2020-06-02last_updated_msintegerExample: 1591084414622web_maker_fee_bpsintegerExample: 25web_taker_fee_bpsintegerExample: 35web_auction_fee_bpsintegerExample: 25api_maker_fee_bpsintegerExample: 10api_taker_fee_bpsintegerExample: 35api_auction_fee_bpsintegerExample: 20fix_maker_fee_bpsintegerExample: 10fix_taker_fee_bpsintegerExample: 35fix_auction_fee_bpsintegerExample: 20notional_30d_volumestringExample: 1000000notional_1d_volumeobject[]api_notional_30d_volumestringExample: 750000fee_tierobject
Wrap 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
symbolstring · requiredTrading pair symbol
BTCUSD, etc. See symbols and minimums.
Headers
X-GEMINI-APIKEYstring · requiredYour API key
X-GEMINI-SIGNATUREstring · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOADstring · requiredBase64-encoded JSON payload
Content-TypestringDefault: text/plainContent-LengthstringDefault: 0Cache-ControlstringDefault: no-cache
Request Body
requeststring · requiredThe literal string "/v1/wrap/symbol"
amountstring · requiredThe amount to wrap
sidestring · enum"buy" or "sell"
Enum values:buysellclient_order_idstringA client-specified order id
accountstringRequired for Master API keys. The name of the account within the subaccount group.
Responses
Successful operation
orderIdstringThe order ID
pairstringTrading pair symbol
pricestringThe price of the order
priceCurrencystringThe currency in which the order is priced
sidestringEither "buy" or "sell"
quantitystringThe amount that was executed
quantityCurrencystringThe currency label for the quantity field
totalSpendstringTotal quantity spent for the order
totalSpendCurrencystringCurrency of the totalSpend
feestringThe amount charged
feeCurrencystringCurrency that the fee was paid in
depositFeestringThe deposit fee quantity
depositFeeCurrencystringCurrency in which depositFee is taken

