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-APIKEY
string · requiredYour API key
X-GEMINI-SIGNATURE
string · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOAD
string · requiredBase64-encoded JSON payload
Content-Type
stringDefault: text/plainContent-Length
stringDefault: 0Cache-Control
stringDefault: no-cache
Request Body
request
string · requiredThe literal string "/v1/order/new"
Example: /v1/order/newnonce
number · requiredThe nonce, as described in Private API Invocation
amount
string · requiredQuoted decimal amount to purchase
Example: 5price
string · requiredQuoted decimal amount to spend per unit
Example: 3633.00side
string · enum · requiredEnum values:buysellExample: buytype
string · 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_id
stringRecommended. A client-specified order id
options
string[]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_price
stringThe price to trigger a stop-limit order. Only available for stop-limit orders.
account
stringRequired 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
order_id
stringid
stringsymbol
stringexchange
stringavg_execution_price
stringside
string · enumEnum values:buyselltype
string · enumEnum values:exchange limitexchange stop limitexchange markettimestamp
timestamp
timestampms
timestamp
is_live
booleanis_cancelled
booleanis_hidden
booleanwas_forced
booleanexecuted_amount
stringremaining_amount
string · doubleclient_order_id
stringoptions
string[]price
string · doubleoriginal_amount
string · doubleorder_id
stringid
stringsymbol
stringexchange
stringavg_execution_price
stringside
string · enumEnum values:buyselltype
string · enumEnum values:exchange stop limittimestamp
timestamp
timestampms
timestamp
is_live
booleanis_cancelled
booleanis_hidden
booleanwas_forced
booleanexecuted_amount
stringoptions
string[]stop_price
string · doubleprice
string · doubleoriginal_amount
string · 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-APIKEY
string · requiredYour API key
X-GEMINI-SIGNATURE
string · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOAD
string · requiredBase64-encoded JSON payload
Content-Type
stringDefault: text/plainContent-Length
stringDefault: 0Cache-Control
stringDefault: no-cache
Request Body
request
string · requiredThe literal string "/v1/order/cancel"
Example: /v1/order/cancelnonce
requiredtimestamp
order_id
integer · requiredThe order ID given by
/order/new
Example: 106817811
account
stringRequired 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
order_id
string · integerid
string · integersymbol
stringexchange
stringavg_execution_price
string · doubleside
string · enumEnum values:buyselltype
string · enumEnum values:exchange limitexchange stop limitexchange markettimestamp
timestamp
timestampms
timestamp
is_live
booleanis_cancelled
booleanis_hidden
booleanwas_forced
booleanexecuted_amount
string · doubleremaining_amount
string · doublereason
string · enumEnum values:MakerOrCancelWouldTakeExceedsPriceLimitsSelfCrossPreventedImmediateOrCancelWouldPostFillOrKillWouldNotFillRequestedMarketClosedTradingClosedoptions
string[]price
string · doubleoriginal_amount
string · 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-APIKEY
string · requiredYour API key
X-GEMINI-SIGNATURE
string · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOAD
string · requiredBase64-encoded JSON payload
Content-Type
stringDefault: text/plainContent-Length
stringDefault: 0Cache-Control
stringDefault: no-cache
Request Body
request
string · requiredThe literal string "/v1/order/cancel/all"
Example: /v1/order/cancel/allnonce
requiredtimestamp
account
stringRequired 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
result
stringExample: okdetails
objectcancelledOrders/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-APIKEY
string · requiredYour API key
X-GEMINI-SIGNATURE
string · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOAD
string · requiredBase64-encoded JSON payload
Content-Type
stringDefault: text/plainContent-Length
stringDefault: 0Cache-Control
stringDefault: no-cache
Request Body
request
string · requiredThe literal string "/v1/order/cancel/session"
Example: /v1/order/cancel/sessionnonce
requiredtimestamp
account
stringRequired 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
result
stringExample: okdetails
objectcancelledOrders/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-APIKEY
string · requiredYour API key
X-GEMINI-SIGNATURE
string · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOAD
string · requiredBase64-encoded JSON payload
Content-Type
stringDefault: text/plainContent-Length
stringDefault: 0Cache-Control
stringDefault: no-cache
Request Body
request
string · requiredThe API endpoint path
Example: /v1/order/statusnonce
requiredtimestamp
order_id
integer · requiredThe 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 withclient_order_id
.Example: 123456789012345
account
stringRequired 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_id
stringThe
client_order_id
used when placing the order.client_order_id
cannot be used in combination withorder_id
include_trades
booleanEither
True
orFalse
. IfTrue
the endpoint will return individual trade details of all fills from the order.
Responses
order_id
string · integerThe order id
client_order_id
string · integerAn optional client-specified order id
symbol
stringThe symbol of the order
exchange
stringWill always be "gemini"
price
string · decimalThe price the order was issued at
avg_execution_price
string · decimalThe average price at which this order as been executed so far. 0 if the order has not been executed at all.
side
string · enumEnum values:buyselltype
string · enumDescription of the order
Enum values:exchange limitexchange stop limitexchange marketoptions
string[]An array containing at most one supported order execution option. See Order execution options for details.
timestamp
timestamp
timestampms
timestamp
is_live
booleantrue
if the order is active on the book (has remaining quantity and has not been canceled)is_cancelled
booleantrue
if the order has been canceled. Note the spelling, "cancelled" instead of "canceled". This is for compatibility reasons.reason
stringPopulated with the reason your order was canceled, if available.
was_forced
booleanWill always be
false
.executed_amount
string · decimalThe amount of the order that has been filled.
remaining_amount
string · decimalThe amount of the order that has not been filled.
original_amount
string · decimalThe originally submitted amount of the order.
is_hidden
booleanWill always return
false
.trades
object[]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-APIKEY
string · requiredYour API key
X-GEMINI-SIGNATURE
string · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOAD
string · requiredBase64-encoded JSON payload
Content-Type
stringDefault: text/plainContent-Length
stringDefault: 0Cache-Control
stringDefault: no-cache
Request Body
request
string · requiredThe API endpoint path
Example: /v1/ordersnonce
requiredtimestamp
account
stringRequired 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
order_id
string · integerThe order id
client_order_id
string · integerAn optional client-specified order id
symbol
stringThe symbol of the order
exchange
stringWill always be "gemini"
price
string · decimalThe price the order was issued at
avg_execution_price
string · decimalThe average price at which this order as been executed so far. 0 if the order has not been executed at all.
side
string · enumEnum values:buyselltype
string · enumDescription of the order
Enum values:exchange limitexchange stop limitexchange marketoptions
string[]An array containing at most one supported order execution option. See Order execution options for details.
timestamp
timestamp
timestampms
timestamp
is_live
booleantrue
if the order is active on the book (has remaining quantity and has not been canceled)is_cancelled
booleantrue
if the order has been canceled. Note the spelling, "cancelled" instead of "canceled". This is for compatibility reasons.reason
stringPopulated with the reason your order was canceled, if available.
was_forced
booleanWill always be
false
.executed_amount
string · decimalThe amount of the order that has been filled.
remaining_amount
string · decimalThe amount of the order that has not been filled.
original_amount
string · decimalThe originally submitted amount of the order.
is_hidden
booleanWill always return
false
.trades
object[]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:
POST
to https://api.gemini.com/v1/orders/history with a JSON payload including atimestamp
key with value0
and alimit_orders
key with value500
- When you receive the list of orders, it will be sorted by
timestamp
descending - so the first element in the list will have the highesttimestamp
value. For this example, say that value isX
. - Create a second
POST
request with a JSON payload including atimestamp
key with valueX+1
and alimit_orders
key with value500
. - Take the first element of the list returned with highest
timestamp
valueY
and create a thirdPOST
request with a JSON payload including atimestamp
key with valueY+1
and alimit_orders
key with value500
. - Continue creating
POST
requests 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-APIKEY
string · requiredYour API key
X-GEMINI-SIGNATURE
string · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOAD
string · requiredBase64-encoded JSON payload
Content-Type
stringDefault: text/plainContent-Length
stringDefault: 0Cache-Control
stringDefault: no-cache
Request Body
request
string · requiredThe API endpoint
/v1/orders/history
symbol
stringThe symbol to retrieve orders for
limit_orders
integerThe maximum number of orders to return. Default is 50, max is 500.
Default: 50timestamp
In iso datetime with timezone format from that date you will get order history
account
stringRequired for Master API keys as described in Private API Invocation. The name of the account within the subaccount group.
Responses
order_id
string · integerThe order id
client_order_id
string · integerAn optional client-specified order id
symbol
stringThe symbol of the order
exchange
stringWill always be "gemini"
price
string · decimalThe price the order was issued at
avg_execution_price
string · decimalThe average price at which this order as been executed so far. 0 if the order has not been executed at all.
side
string · enumEnum values:buyselltype
string · enumDescription of the order
Enum values:exchange limitexchange stop limitexchange marketoptions
string[]An array containing at most one supported order execution option. See Order execution options for details.
timestamp
timestamp
timestampms
timestamp
is_live
booleantrue
if the order is active on the book (has remaining quantity and has not been canceled)is_cancelled
booleantrue
if the order has been canceled. Note the spelling, "cancelled" instead of "canceled". This is for compatibility reasons.reason
stringPopulated with the reason your order was canceled, if available.
was_forced
booleanWill always be
false
.executed_amount
string · decimalThe amount of the order that has been filled.
remaining_amount
string · decimalThe amount of the order that has not been filled.
original_amount
string · decimalThe originally submitted amount of the order.
is_hidden
booleanWill always return
false
.trades
object[]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:
POST
to https://api.gemini.com/v1/mytrades with a JSON payload including atimestamp
key with value 0 and alimit_trades
key with value500
- When you receive the list of trades, it will be sorted by
timestamp
descending - so the first element in the list will have the highesttimestamp
value. For this example, say that value isX
. - Create a second
POST
request with a JSON payload including atimestamp
key with valueX+1
and alimit_trades
key with value500
. - Take the first element of the list returned with highest
timestamp
valueY
and create a thirdPOST
request with a JSON payload including atimestamp
key with valueY+1
and alimit_trades
key with value500
. - Continue creating
POST
requests 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-APIKEY
string · requiredYour API key
X-GEMINI-SIGNATURE
string · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOAD
string · requiredBase64-encoded JSON payload
Content-Type
stringDefault: text/plainContent-Length
stringDefault: 0Cache-Control
stringDefault: no-cache
Request Body
request
string · requiredThe API endpoint path
Example: /v1/mytradesnonce
requiredtimestamp
account
stringRequired 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_trades
integerThe maximum number of trades to return. Default is 50, max is 500.
Example: 50timestamp
timestamp
Responses
price
stringExample: 9100amount
stringExample: 1.5timestamp
timestamp
timestampms
timestamp
type
string · enumEnum values:BuySellExample: Buyaggressor
booleanExample:fee_currency
stringExample: USDfee_amount
stringExample: 13.65tid
integerExample: 123456789order_id
stringExample: 123456789client_order_id
stringexchange
stringExample: geminiis_auction_fill
booleanbreak
string · enumEnum values:trade correct
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-APIKEY
string · requiredYour API key
X-GEMINI-SIGNATURE
string · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOAD
string · requiredBase64-encoded JSON payload
Content-Type
stringDefault: text/plainContent-Length
stringDefault: 0Cache-Control
stringDefault: no-cache
Request Body
request
string · requiredThe API endpoint path
Example: /v1/tradevolumenonce
requiredtimestamp
account
stringRequired 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
symbol
stringExample: btcusdbase_currency
stringExample: BTCquote_currency
stringExample: USDnotional_currency
stringExample: USDdata_date
stringExample: 2020-06-02total_volume_base
stringExample: 10.5maker_buy_sell_ratio
stringExample: 1.2buy_maker_base
stringExample: 5.5buy_maker_notional
stringExample: 50050buy_maker_count
integerExample: 10sell_maker_base
stringExample: 5sell_maker_notional
stringExample: 45500sell_maker_count
integerExample: 8buy_taker_base
stringExample: 8.5buy_taker_notional
stringExample: 77350buy_taker_count
integerExample: 15sell_taker_base
stringExample: 7.5sell_taker_notional
stringExample: 68250sell_taker_count
integerExample: 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-APIKEY
string · requiredYour API key
X-GEMINI-SIGNATURE
string · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOAD
string · requiredBase64-encoded JSON payload
Content-Type
stringDefault: text/plainContent-Length
stringDefault: 0Cache-Control
stringDefault: no-cache
Request Body
request
string · requiredThe API endpoint path
Example: /v1/notionalvolumenonce
requiredtimestamp
account
stringRequired 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
date
string · dateExample: 2020-06-02last_updated_ms
integerExample: 1591084414622web_maker_fee_bps
integerExample: 25web_taker_fee_bps
integerExample: 35web_auction_fee_bps
integerExample: 25api_maker_fee_bps
integerExample: 10api_taker_fee_bps
integerExample: 35api_auction_fee_bps
integerExample: 20fix_maker_fee_bps
integerExample: 10fix_taker_fee_bps
integerExample: 35fix_auction_fee_bps
integerExample: 20notional_30d_volume
stringExample: 1000000notional_1d_volume
object[]api_notional_30d_volume
stringExample: 750000fee_tier
object
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
symbol
string · requiredTrading pair symbol
BTCUSD
, etc. See symbols and minimums.
Headers
X-GEMINI-APIKEY
string · requiredYour API key
X-GEMINI-SIGNATURE
string · requiredHEX-encoded HMAC-SHA384 of payload signed with API secret
X-GEMINI-PAYLOAD
string · requiredBase64-encoded JSON payload
Content-Type
stringDefault: text/plainContent-Length
stringDefault: 0Cache-Control
stringDefault: no-cache
Request Body
request
string · requiredThe literal string "/v1/wrap/symbol"
amount
string · requiredThe amount to wrap
side
string · enum"buy" or "sell"
Enum values:buysellclient_order_id
stringA client-specified order id
account
stringRequired for Master API keys. The name of the account within the subaccount group.
Responses
orderId
stringThe order ID
pair
stringTrading pair symbol
price
stringThe price of the order
priceCurrency
stringThe currency in which the order is priced
side
stringEither "buy" or "sell"
quantity
stringThe amount that was executed
quantityCurrency
stringThe currency label for the quantity field
totalSpend
stringTotal quantity spent for the order
totalSpendCurrency
stringCurrency of the totalSpend
fee
stringThe amount charged
feeCurrency
stringCurrency that the fee was paid in
depositFee
stringThe deposit fee quantity
depositFeeCurrency
stringCurrency in which depositFee is taken