How you can place an order with the REST API
Here’s a pattern code that you should utilize to put automated bitcoin purchase orders on the CEX.IO REST API out of your terminal. To position completely different order sorts, simply alter the bottom and quote forex symbols (the primary line within the code under), together with the sort, quantity, and worth traces, in keeping with your particular wants.
For instance, if you wish to generate automated promote orders for Ethereum at predefined portions and worth ranges sooner or later, simply sort “promote” on the sort line and enter your predetermined quantities and costs into the traces under.
POST https://cex.io/api/place_order/{ETH}/{USD}
{
“key”: “HLixH1aYdOIWOoRyoHkFpHlawrM”,
“signature”: “0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9”,
“nonce”: “1513175715”,
“sort”: “purchase”,
“quantity”: 12,
“worth”: 3026.42
}
How you can place an order with the Websocket API
You can even place orders with the Websocket API just like the pattern code under. To vary your order parameters, it is advisable to alter the bottom and quote forex symbols below the pair line (BTC and USD symbols within the under pattern), together with the quantity, worth, and kind traces, in keeping with your particular requests:
{
“e”: “place-order”,
“information”: {
“pair”: [
“BTC”,
“USD”
],
“quantity”: 0.02,
“worth”: “43002.7“,
“sort”: “purchase”
},
“oid”: “1435927928274_7_place-order”
}
How you can examine your account stability with the WebSocket API
The pattern code under illustrates how one can obtain automated account stability messages with the WebSocket API.
{
“e”: “get-balance”,
“information”: {},
“oid”: “1435927928274_2_get-balance”
}
In response, the WebSocket API will return with a message that accommodates your balances for the completely different property in your CEX.IO account:
{
“e”: “get-balance”,
“information”: {
“stability”: {
‘LTC’: ‘10.00000000’,
‘USD’: ‘1024.00’,
‘EUR’: ‘217.53’,
‘BTC’: ‘9.00000000’
},
},
“time”: 1435927928597
“oid”: “1435927928274_2_get-balance”,
“okay”: “okay”
}
How you can entry your order books with the WebSocket API
Utilizing the WebSocket API, you possibly can subscribe to the order books of various cryptocurrency buying and selling pairs. Right here is how you are able to do it for the BTC/USD buying and selling pair:
{
“e”: “order-book-subscribe”,
“information”: {
“pair”: [
“BTC”,
“USD”
],
“subscribe”: false,
“depth”: -1
},
“oid”: “1435927928274_3_order-book-subscribe”
}
You may examine your orders for different pairs by adjusting the bottom and quote currencies within the pair part within the above code.