For information on changes for our US clients, please visit our Support Center article.

Cerca
WebSocket API v1 Trading - addOrder and cancelOrder
  • Placing orders - addOrder
  • Cancelling orders - cancelOrder
Trading (placing and cancelling orders) via the WebSocket API v1 is provided by the addOrder and cancelOrder endpoints. Similar to trading via the REST API, the addOrder endpoint is used to place new orders, and the cancelOrder endpoint is used to cancel existing (open) orders.
Once a connection to the WebSocket API has been established, orders can be placed and cancelled via the following steps:
  1. 1
    retrieve an authentication token via the REST API GetWebSocketsToken endpoint (once a valid token has been retrieved, the same token can be used for multiple addOrder/cancelOrder requests),
  2. 2
    send the appropriate addOrder/cancelOrder request,
  3. 3
    receive a response indicating whether the request was successful or not.

Placing orders - addOrder

Our WebSocket API documentation provides the complete specification for the addOrder endpoint, including the JSON format that must be used, along with descriptions of each required and optional field.
As an example, the following JSON message would place a new order to buy 0.25 ETH/EUR at a limit price of €150:
{
"event": "addOrder",
"token": "WOg6IVQ5RfogMzkhH25WOg6IVQ5RqhP+U3ZprQVnh7f",
"pair": "ETH/EUR",
"type": "buy",
"ordertype": "limit",
"price": "150",
"volume": "0.25"
}
Assuming that the above order was placed successfully (sufficient funds available in the account balance, etc.), the following JSON message would be received in response:
{
"event": "addOrderStatus",
"status": "ok",
"descr": "buy 0.25000000 ETHEUR @ limit 150",
"txid": "OUEMWD-CUO73-YYCBEK"
}

Cancelling orders - cancelOrder

Our WebSocket API documentation provides the complete specification for the cancelOrder endpoint, including the JSON format that must be used, along with descriptions of each required and optional field.
Unlike the REST API, the WebSocket API cancelOrder endpoint can be used to cancel multiple orders simultaneously, by specifying each order ID (or user reference) in the txid array.
As an example, the following JSON message would cancel any open order with the matching order IDs:
{
"event": "cancelOrder",
"token": "WOg6IVQ5RfogMzkhH25WOg6IVQ5RqhP+U3ZprQVnh7f",
"txid": ["OUEMWD-CUO73-YYCBEK", "OBW5ID-MAGEW-HENTE7"]
}
Assuming that the orders were cancelled successfully, the following JSON message would be received in response:
{
"event": "cancelOrderStatus",
"status": "ok"
}