MultiversX Tracker is Live!

A Guide to Automated Crypto Trading With CEX.IO API Solutions

CEX.IO

Cryptocoins Exchanges / CEX.IO 233 Views

How to place an order with the REST API

Here is a sample code that you can use to place automated bitcoin buy orders on the CEX.IO REST API from your terminal. To place different order types, just adjust the base and quote currency symbols (the first line in the code below), along with the type, amount, and price lines, according to your specific needs.

 For example, if you want to generate automated sell orders for Ethereum at predefined quantities and price levels in the future, just type “sell” on the type line and input your predetermined amounts and prices into the lines below. 

POST https://cex.io/api/place_order/{ETH}/{USD}

{

  “key”: “HLixH1aYdOIWOoRyoHkFpHlawrM”,

  “signature”: “0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9”,

  “nonce”: “1513175715”,

  “type”: “buy”,

  “amount”: 12,

  “price”: 3026.42

}

How to place an order with the Websocket API

You can also place orders with the Websocket API like the sample code below. To change your order parameters, you need to adjust the base and quote currency symbols under the pair line (BTC and USD symbols in the below sample), along with the amount, price, and type lines, according to your specific requests:

{

  “e”: “place-order”,

  “data”: {

    “pair”: [

      “BTC”,

      “USD”

    ],

    “amount”: 0.02,

    “price”: “43002.7“,

    “type”: “buy”

  },

  “oid”: “1435927928274_7_place-order”

}

How to check your account balance with the WebSocket API

The sample code below illustrates how you can receive automated account balance messages with the WebSocket API. 

{

    “e”: “get-balance”,

    “data”: {},

    “oid”: “1435927928274_2_get-balance”

}

In response, the WebSocket API will return with a message that contains your balances for the different assets in your CEX.IO account:

{

    “e”: “get-balance”,

    “data”: {

           “balance”: {

            ‘LTC’: ‘10.00000000’, 

            ‘USD’: ‘1024.00’,

            ‘EUR’: ‘217.53’, 

            ‘BTC’: ‘9.00000000’

        },

                 },

       “time”: 1435927928597

    “oid”: “1435927928274_2_get-balance”,

    “ok”: “ok”

}

How to access your order books with the WebSocket API 

Using the WebSocket API, you can subscribe to the order books of different cryptocurrency trading pairs. Here is how you can do it for the BTC/USD trading pair:

 {

  “e”: “order-book-subscribe”,

  “data”: {

  “pair”: [

        “BTC”,

        “USD”

        ],

        “subscribe”: false,

        “depth”: -1

  },

  “oid”: “1435927928274_3_order-book-subscribe”

  }

You can check your orders for other pairs by adjusting the base and quote currencies in the pair section in the above code.


Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
💰 Install these recommended apps:
💲 SocialGood - 100% Crypto Back on Everyday Shopping
💲 xPortal - The DeFi For The Next Billion
💲 CryptoTab Browser - Lightweight, fast, and ready to mine!
💰 Register on these recommended exchanges:
🟡 Binance🟡 Bitfinex🟡 Bitmart🟡 Bittrex🟡 Bitget
🟡 CoinEx🟡 Crypto.com🟡 Gate.io🟡 Huobi🟡 Kucoin.



Comments