Orders
Order statuses and the lifecycle are documented in the separate section: EMS / Starter Guide / Order Lifecycle
Get open orders GET
Code samples
curl --request GET \
--url https://ems-gateway-aws-eu-central-1-dev.coinapi.io/v1/orders \
--header 'Accept: application/json'
GET /v1/orders
Get last execution reports for open orders across all or single exchange.
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
exchange_id | query | string | false | Filter the open orders to the specific exchange. |
Example responses
200 Response
[
{
"exchange_id": "KRAKEN",
"client_order_id": "6ab36bc1-344d-432e-ac6d-0bf44ee64c2b",
"symbol_id_exchange": "XBT/USDT",
"symbol_id_coinapi": "KRAKEN_SPOT_BTC_USDT",
"amount_order": 0.045,
"price": 0.0783,
"side": "BUY",
"order_type": "LIMIT",
"time_in_force": "GOOD_TILL_CANCEL",
"expire_time": "2020-01-01T10:45:20.1677709Z",
"exec_inst": [
"MAKER_OR_CANCEL"
],
"client_order_id_format_exchange": "f81211e2-27c4-b86a-8143-01088ba9222c",
"exchange_order_id": 3456456754,
"amount_open": 0.22,
"amount_filled": 0,
"avg_px": 0.0783,
"status": "RECEIVED",
"status_history": [
[
[
[
"RECEIVED",
"2020-05-27T11:16:20.1677709Z"
],
[
"REJECTED",
"2020-05-27T11:16:20.1677710Z"
]
]
]
],
"error_message": "{\"result\":\"error\",\"reason\":\"InsufficientFunds\",\"message\":\"Failed to place buy order on symbol 'BTCUSD' for price $7,000.00 and quantity 0.22 BTC due to insufficient funds\"}",
"fills": [
{
"time": "2020-01-01T10:45:20.1677709Z",
"price": 10799.2,
"amount": 0.002
}
]
}
]
490 Response
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK (opens in a new tab) | Collection of order execution reports. | OrderExecutionReports |
490 | Not Applicable | Filtered exchange is unreachable. | MessageReject |
Send new order POST
Code samples
curl --request POST \
--url https://ems-gateway-aws-eu-central-1-dev.coinapi.io/v1/orders \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"exchange_id":"KRAKEN","client_order_id":"6ab36bc1-344d-432e-ac6d-0bf44ee64c2b","symbol_id_exchange":"XBT/USDT","symbol_id_coinapi":"KRAKEN_SPOT_BTC_USDT","amount_order":0.045,"price":0.0783,"side":"BUY","order_type":"LIMIT","time_in_force":"GOOD_TILL_CANCEL","expire_time":"2020-01-01T10:45:20.1677709Z","exec_inst":["MAKER_OR_CANCEL"]}'
POST /v1/orders
This request creating new order for the specific exchange.
Body parameter
{
"exchange_id": "KRAKEN",
"client_order_id": "6ab36bc1-344d-432e-ac6d-0bf44ee64c2b",
"symbol_id_exchange": "XBT/USDT",
"symbol_id_coinapi": "KRAKEN_SPOT_BTC_USDT",
"amount_order": 0.045,
"price": 0.0783,
"side": "BUY",
"order_type": "LIMIT",
"time_in_force": "GOOD_TILL_CANCEL",
"expire_time": "2020-01-01T10:45:20.1677709Z",
"exec_inst": [
"MAKER_OR_CANCEL"
]
}
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
body | body | OrderNewSingleRequest | true | OrderNewSingleRequest object. |
» exchange_id | body | string | true | Exchange identifier used to identify the routing destination. |
» client_order_id | body | string | true | The unique identifier of the order assigned by the client. |
» symbol_id_exchange | body | string | false | Exchange symbol. One of the properties (symbol_id_exchange , symbol_id_coinapi ) is required to identify the market for the new order. |
» symbol_id_coinapi | body | string | false | CoinAPI symbol. One of the properties (symbol_id_exchange , symbol_id_coinapi ) is required to identify the market for the new order. |
» amount_order | body | number | true | Order quantity. |
» price | body | number | true | Order price. |
» side | body | OrdSide | true | Side of order. |
» order_type | body | OrdType | true | Order types are documented in the separate section: EMS / Starter Guide / Order parameters / Order type |
» time_in_force | body | TimeInForce | true | Order time in force options are documented in the separate section: EMS / Starter Guide / Order parameters / Time in force |
» expire_time | body | date | false | Expiration time. Conditionaly required for orders with time_in_force = GOOD_TILL_TIME_EXCHANGE or GOOD_TILL_TIME_OEML . |
» exec_inst | body | [string] | false | Order execution instructions are documented in the separate section: EMS / Starter Guide / Order parameters / Execution instructions |
Enumerated Values
Parameter | Value |
---|---|
» side | BUY |
» side | SELL |
» order_type | LIMIT |
» time_in_force | GOOD_TILL_CANCEL |
» time_in_force | GOOD_TILL_TIME_EXCHANGE |
» time_in_force | GOOD_TILL_TIME_OMS |
» time_in_force | FILL_OR_KILL |
» time_in_force | IMMEDIATE_OR_CANCEL |
» exec_inst | MAKER_OR_CANCEL |
» exec_inst | AUCTION_ONLY |
» exec_inst | INDICATION_OF_INTEREST |
Example responses
200 Response
{
"exchange_id": "KRAKEN",
"client_order_id": "6ab36bc1-344d-432e-ac6d-0bf44ee64c2b",
"symbol_id_exchange": "XBT/USDT",
"symbol_id_coinapi": "KRAKEN_SPOT_BTC_USDT",
"amount_order": 0.045,
"price": 0.0783,
"side": "BUY",
"order_type": "LIMIT",
"time_in_force": "GOOD_TILL_CANCEL",
"expire_time": "2020-01-01T10:45:20.1677709Z",
"exec_inst": [
"MAKER_OR_CANCEL"
],
"client_order_id_format_exchange": "f81211e2-27c4-b86a-8143-01088ba9222c",
"exchange_order_id": 3456456754,
"amount_open": 0.22,
"amount_filled": 0,
"avg_px": 0.0783,
"status": "RECEIVED",
"status_history": [
[
[
[
"RECEIVED",
"2020-05-27T11:16:20.1677709Z"
],
[
"REJECTED",
"2020-05-27T11:16:20.1677710Z"
]
]
]
],
"error_message": "{\"result\":\"error\",\"reason\":\"InsufficientFunds\",\"message\":\"Failed to place buy order on symbol 'BTCUSD' for price $7,000.00 and quantity 0.22 BTC due to insufficient funds\"}",
"fills": [
{
"time": "2020-01-01T10:45:20.1677709Z",
"price": 10799.2,
"amount": 0.002
}
]
}
490 Response
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK (opens in a new tab) | Created | OrderExecutionReport |
400 | Bad Request (opens in a new tab) | Input model validation errors. | ValidationError |
490 | Not Applicable | Exchange is unreachable. | MessageReject |
504 | Gateway Time-out (opens in a new tab) | Exchange didn't responded in the defined timeout. | MessageReject |
Get order execution report GET
Code samples
curl --request GET \
--url https://ems-gateway-aws-eu-central-1-dev.coinapi.io/v1/orders/status/6ab36bc1-344d-432e-ac6d-0bf44ee64c2b \
--header 'Accept: application/json'
GET /v1/orders/status/{client_order_id}
Get the last order execution report for the specified order. The requested order does not need to be active or opened.
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
client_order_id | path | string | true | The unique identifier of the order assigned by the client. |
Example responses
200 Response
{
"exchange_id": "KRAKEN",
"client_order_id": "6ab36bc1-344d-432e-ac6d-0bf44ee64c2b",
"symbol_id_exchange": "XBT/USDT",
"symbol_id_coinapi": "KRAKEN_SPOT_BTC_USDT",
"amount_order": 0.045,
"price": 0.0783,
"side": "BUY",
"order_type": "LIMIT",
"time_in_force": "GOOD_TILL_CANCEL",
"expire_time": "2020-01-01T10:45:20.1677709Z",
"exec_inst": [
"MAKER_OR_CANCEL"
],
"client_order_id_format_exchange": "f81211e2-27c4-b86a-8143-01088ba9222c",
"exchange_order_id": 3456456754,
"amount_open": 0.22,
"amount_filled": 0,
"avg_px": 0.0783,
"status": "RECEIVED",
"status_history": [
[
[
[
"RECEIVED",
"2020-05-27T11:16:20.1677709Z"
],
[
"REJECTED",
"2020-05-27T11:16:20.1677710Z"
]
]
]
],
"error_message": "{\"result\":\"error\",\"reason\":\"InsufficientFunds\",\"message\":\"Failed to place buy order on symbol 'BTCUSD' for price $7,000.00 and quantity 0.22 BTC due to insufficient funds\"}",
"fills": [
{
"time": "2020-01-01T10:45:20.1677709Z",
"price": 10799.2,
"amount": 0.002
}
]
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK (opens in a new tab) | The last execution report of the requested order. | OrderExecutionReport |
404 | Not Found (opens in a new tab) | The requested order was not found. | MessageReject |
Cancel order request POST
Code samples
curl --request POST \
--url https://ems-gateway-aws-eu-central-1-dev.coinapi.io/v1/orders/cancel \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"exchange_id":"KRAKEN","exchange_order_id":3456456754,"client_order_id":"6ab36bc1-344d-432e-ac6d-0bf44ee64c2b"}'
POST /v1/orders/cancel
Request cancel for an existing order. The order can be canceled using the client_order_id
or exchange_order_id
.
Body parameter
{
"exchange_id": "KRAKEN",
"exchange_order_id": 3456456754,
"client_order_id": "6ab36bc1-344d-432e-ac6d-0bf44ee64c2b"
}
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
body | body | OrderCancelSingleRequest | true | OrderCancelSingleRequest object. |
» exchange_id | body | string | true | Exchange identifier used to identify the routing destination. |
» exchange_order_id | body | string | false | Unique identifier of the order assigned by the exchange or executing system. One of the properties (exchange_order_id , client_order_id ) is required to identify the new order. |
» client_order_id | body | string | false | The unique identifier of the order assigned by the client. One of the properties (exchange_order_id , client_order_id ) is required to identify the new order. |
Example responses
200 Response
{
"exchange_id": "KRAKEN",
"client_order_id": "6ab36bc1-344d-432e-ac6d-0bf44ee64c2b",
"symbol_id_exchange": "XBT/USDT",
"symbol_id_coinapi": "KRAKEN_SPOT_BTC_USDT",
"amount_order": 0.045,
"price": 0.0783,
"side": "BUY",
"order_type": "LIMIT",
"time_in_force": "GOOD_TILL_CANCEL",
"expire_time": "2020-01-01T10:45:20.1677709Z",
"exec_inst": [
"MAKER_OR_CANCEL"
],
"client_order_id_format_exchange": "f81211e2-27c4-b86a-8143-01088ba9222c",
"exchange_order_id": 3456456754,
"amount_open": 0.22,
"amount_filled": 0,
"avg_px": 0.0783,
"status": "RECEIVED",
"status_history": [
[
[
[
"RECEIVED",
"2020-05-27T11:16:20.1677709Z"
],
[
"REJECTED",
"2020-05-27T11:16:20.1677710Z"
]
]
]
],
"error_message": "{\"result\":\"error\",\"reason\":\"InsufficientFunds\",\"message\":\"Failed to place buy order on symbol 'BTCUSD' for price $7,000.00 and quantity 0.22 BTC due to insufficient funds\"}",
"fills": [
{
"time": "2020-01-01T10:45:20.1677709Z",
"price": 10799.2,
"amount": 0.002
}
]
}
490 Response
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK (opens in a new tab) | The last execution report for the order for which cancelation was requested. | OrderExecutionReport |
400 | Bad Request (opens in a new tab) | Input model validation errors. | ValidationError |
490 | Not Applicable | Exchange is unreachable. | MessageReject |
Cancel all orders request POST
Code samples
curl --request POST \
--url https://ems-gateway-aws-eu-central-1-dev.coinapi.io/v1/orders/cancel/all \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"exchange_id":"KRAKEN"}'
POST /v1/orders/cancel/all
This request cancels all open orders on single specified exchange.
Body parameter
{
"exchange_id": "KRAKEN"
}
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
body | body | OrderCancelAllRequest | true | OrderCancelAllRequest object. |
» exchange_id | body | string | true | Identifier of the exchange from which active orders should be canceled. |
Example responses
200 Response
{
"type": "MESSAGE_REJECT",
"reject_reason": "ORDER_ID_NOT_FOUND",
"exchange_id": "BINANCE",
"message": "Order with ID: BINANCE-7d8a-4888 not found",
"rejected_message": "{\"client_order_id\":\"BINANCE-7d8a-4888\",\"exchange_id\":\"BINANCE\",\"type\":\"ORDER_CANCEL_SINGLE_REQUEST\"}"
}
490 Response
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK (opens in a new tab) | Result | MessageReject |
400 | Bad Request (opens in a new tab) | Input model validation errors. | ValidationError |
490 | Not Applicable | Exchange is unreachable. | MessageReject |
History of order changes GET
Code samples
curl --request GET \
--url 'https://ems-gateway-aws-eu-central-1-dev.coinapi.io/v1/orders/history?time_start=2022-05-01T00%3A00%3A00&time_end=2022-05-01T12%3A00%3A00' \
--header 'Accept: application/json'
GET /v1/orders/history
Based on the date range, all changes registered in the orderbook.
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
time_start | query | string | true | Start date |
time_end | query | string | true | End date |
Example responses
200 Response
[
{
"apikey": "9a55567a-b5ff-4b78-b6aa-xxxx",
"exchangeId": "BINANCE",
"clientOrderId": "6ab36bc1-344d-432e-ac6d-0bf44ee64c2b",
"symbolIdExchange": "BTCUSDT",
"symbolIdCoinapi": "BINANCE_SPOT_BTC_USDT",
"amountOrder": 0.00034,
"price": 31939.47,
"side": 2,
"orderType": "LIMIT",
"timeInForce": "GOOD_TILL_CANCEL",
"expireTime": "2022-05-01T00:00:00",
"execInst": [
[
"MAKER_OR_CANCEL"
]
],
"clientOrderIdFormatExchange": "6ab36bc1-344d-432e-ac6d-0bf44ee64c2b",
"exchangeOrderId": "6ab36bc1-344d-432e-ac6d-0bf44ee64c2b",
"amountOpen": 0.00034,
"amountFilled": 0,
"avgPx": 0,
"status": "REJECTED",
"statusHistoryStatus": [
[
"RECEIVED",
"ROUTING",
"REJECTED"
]
],
"statusHistoryTime": [
[
"2022-05-27T13:06:34.5122626Z",
"2022-05-27T13:06:37.3410216Z",
"2022-05-27T13:06:40.1342877Z"
]
],
"errorMessageResult": "string",
"errorMessageReason": "string",
"errorMessageMessage": "-2015 Invalid API-key, IP, or permissions for action. https://api.binance.com/api/v3/order?newOrderRespType",
"fillsTime": [
[
"2022-05-27T13:06:34.5122626Z",
"2022-05-27T13:06:37.3410216Z",
"2022-05-27T13:06:40.1342877Z"
]
],
"fillsPrice": [
[
31939.47,
31939.67
]
],
"fillsAmount": [
[
0.0032,
0.0009
]
],
"createdTime": "2022-06-27T07:02:33.1977903Z"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK (opens in a new tab) | The last execution report of the requested order. | OrderHistoryArray |
400 | Bad Request (opens in a new tab) | Orders log is not configured. | MessageError |