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
ParameterInTypeRequiredDescription
exchange_idquerystringfalseFilter 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

StatusMeaningDescriptionSchema
200OK (opens in a new tab)Collection of order execution reports.OrderExecutionReports
490Not ApplicableFiltered 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
ParameterInTypeRequiredDescription
bodybodyOrderNewSingleRequesttrueOrderNewSingleRequest object.
» exchange_idbodystringtrueExchange identifier used to identify the routing destination.
» client_order_idbodystringtrueThe unique identifier of the order assigned by the client.
» symbol_id_exchangebodystringfalseExchange symbol. One of the properties (symbol_id_exchange, symbol_id_coinapi) is required to identify the market for the new order.
» symbol_id_coinapibodystringfalseCoinAPI symbol. One of the properties (symbol_id_exchange, symbol_id_coinapi) is required to identify the market for the new order.
» amount_orderbodynumbertrueOrder quantity.
» pricebodynumbertrueOrder price.
» sidebodyOrdSidetrueSide of order.
» order_typebodyOrdTypetrueOrder types are documented in the separate section: EMS / Starter Guide / Order parameters / Order type
» time_in_forcebodyTimeInForcetrueOrder time in force options are documented in the separate section: EMS / Starter Guide / Order parameters / Time in force
» expire_timebodydatefalseExpiration time. Conditionaly required for orders with time_in_force = GOOD_TILL_TIME_EXCHANGE or GOOD_TILL_TIME_OEML.
» exec_instbody[string]falseOrder execution instructions are documented in the separate section: EMS / Starter Guide / Order parameters / Execution instructions
Enumerated Values
ParameterValue
» sideBUY
» sideSELL
» order_typeLIMIT
» time_in_forceGOOD_TILL_CANCEL
» time_in_forceGOOD_TILL_TIME_EXCHANGE
» time_in_forceGOOD_TILL_TIME_OMS
» time_in_forceFILL_OR_KILL
» time_in_forceIMMEDIATE_OR_CANCEL
» exec_instMAKER_OR_CANCEL
» exec_instAUCTION_ONLY
» exec_instINDICATION_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

StatusMeaningDescriptionSchema
200OK (opens in a new tab)CreatedOrderExecutionReport
400Bad Request (opens in a new tab)Input model validation errors.ValidationError
490Not ApplicableExchange is unreachable.MessageReject
504Gateway 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
ParameterInTypeRequiredDescription
client_order_idpathstringtrueThe 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

StatusMeaningDescriptionSchema
200OK (opens in a new tab)The last execution report of the requested order.OrderExecutionReport
404Not 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
ParameterInTypeRequiredDescription
bodybodyOrderCancelSingleRequesttrueOrderCancelSingleRequest object.
» exchange_idbodystringtrueExchange identifier used to identify the routing destination.
» exchange_order_idbodystringfalseUnique 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_idbodystringfalseThe 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

StatusMeaningDescriptionSchema
200OK (opens in a new tab)The last execution report for the order for which cancelation was requested.OrderExecutionReport
400Bad Request (opens in a new tab)Input model validation errors.ValidationError
490Not ApplicableExchange 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
ParameterInTypeRequiredDescription
bodybodyOrderCancelAllRequesttrueOrderCancelAllRequest object.
» exchange_idbodystringtrueIdentifier 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

StatusMeaningDescriptionSchema
200OK (opens in a new tab)ResultMessageReject
400Bad Request (opens in a new tab)Input model validation errors.ValidationError
490Not ApplicableExchange 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
ParameterInTypeRequiredDescription
time_startquerystringtrueStart date
time_endquerystringtrueEnd 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

StatusMeaningDescriptionSchema
200OK (opens in a new tab)The last execution report of the requested order.OrderHistoryArray
400Bad Request (opens in a new tab)Orders log is not configured.MessageError

Copyright 2022 COINAPI LTD or its affiliates. All rights reserved.
StatusPage: