The right way to place an order with the REST API
Here’s a pattern code that you need to use to position 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 foreign money symbols (the primary line within the code beneath), together with the kind, quantity, and worth strains, based on 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 kind “promote” on the kind line and enter your predetermined quantities and costs into the strains beneath.
POST https://cex.io/api/place_order/{ETH}/{USD}
{
“key”: “HLixH1aYdOIWOoRyoHkFpHlawrM”,
“signature”: “0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9”,
“nonce”: “1513175715”,
“kind”: “purchase”,
“quantity”: 12,
“worth”: 3026.42
}
The right way to place an order with the Websocket API
You can too place orders with the Websocket API just like the pattern code beneath. To vary your order parameters, it’s essential alter the bottom and quote foreign money symbols underneath the pair line (BTC and USD symbols within the beneath pattern), together with the quantity, worth, and kind strains, based on your particular requests:
{
“e”: “place-order”,
“information”: {
“pair”: [
“BTC”,
“USD”
],
“quantity”: 0.02,
“worth”: “43002.7“,
“kind”: “purchase”
},
“oid”: “1435927928274_7_place-order”
}
The right way to verify your account steadiness with the WebSocket API
The pattern code beneath illustrates how one can obtain automated account steadiness 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”: {
“steadiness”: {
‘LTC’: ‘10.00000000’,
‘USD’: ‘1024.00’,
‘EUR’: ‘217.53’,
‘BTC’: ‘9.00000000’
},
},
“time”: 1435927928597
“oid”: “1435927928274_2_get-balance”,
“okay”: “okay”
}
The right way to entry your order books with the WebSocket API
Utilizing the WebSocket API, you’ll be able to 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 verify your orders for different pairs by adjusting the bottom and quote currencies within the pair part within the above code.