Cryptocurrency Rest API
Introduction
Welcome to the CEX.IO Exchange V2 API reference documentation.
The CEX.IO Exchange provides developers with a REST and websocket API. The majority of API calls are available across both mediums in the same request and response formats, allowing smooth transition and a reduced learning curve between the two platforms. Where applicable, all API calls come with detailed information on both the request and response parameters, all in a simple JSON format, as well as sample requests and code snippets in JavaScript, Python, C#, and Java which can be viewed on the right.
Change logs
05/19/22
REST API - added timestamp_ms to response in Orderbook
API Key
Authentication
To get access to CEX.IO data, you should be authorized.
To authorize your account with CEX.IO, please get required keys using the following instructions:
- Log in to CEX.IO account.
- Go to the profile page.
- Select type of required permissions.
- Click
Generate Key
button and save your secret key, as it will become inaccessible after activation. - Activate your key.
Rest API Authorization
We have 2 type of methods Public (GET requests), which don't need authorization at all, and Private (POST requests) which need additional fields inside the request for user authorization.
To call private method you must add 3 fields (nonce, key, signature) into your request.
nonce - is integer field which must be bigger in each next request (good practice is using of timestamp)
key - is a string generated by CEX.IO to access to API
signature - is hash of strings nonce
+username
+key
by sha256 algorithm encrypted with APISecret
like salt
Encryption method example: sha256(string: "nonce"+"username"+"api_key", string: "api_secret")
Example of private request:
POST: https://cex.io/api/cancel_orders/BTC/USD
{
"nonce": 1529420368,
"key": "xcvxcv",
"signature": "70758FC6ABB1CEA18ADD719D69564EBC9DA956CE091E40605188E0AD4B38A60A"
}
Limits per requests
REST API public methods are limited with 600 requests per 10 minutes;
Private methods are limited with 2000 requests per 10 minutes.
WS API is limited with 600 requests for auth and 2000 for all other methods.
However, we strongly recommend to use both - REST + WebSocket subscriptions if possible.
Although you can reach us regarding your rate limits increase via email.
WS API
WebSocket API console available here.
WebSocket API allows getting real-time notifications without sending extra requests, making it a faster way to obtain data from the exchange.
For better experience of running functions connected with archived data, please use REST API.
Version
Please note that CEX.IO WebSocket API is currently in beta and, therefore, is not versioned yet. Some functions are presented in legacy format, because they are used in implementation of CEX.IO Web Client, and will be refactored eventually.
WebSocket URL
wss://ws.cex.io/ws/
Message encoding
- All messages are encoded in JSON format.
- Prices and amounts are presented as strings to avoid rounding errors at JSON parsing on client side
- Some deprecated functions present amount and prices as numbers
- Deprecated functions often present prices and amounts as 'not formatted' - as integer number
- Compression of WebSocket frames is not supported by server. Thus, REST API might be a better option for 'long' requests
- Time is presented as integer UNIX timestamp in seconds in new functions and as integer java timestamp in milliseconds in older functions; further, reffered as 'timestamp' and 'timestamp-ms' correspondently
Authentication
var crypto = require('crypto');
function createSignature(timestamp, apiKey, apiSecret){
var hmac = crypto.createHmac('sha256', apiSecret );
hmac.update( timestamp + apiKey );
return hmac.digest('hex');
}
function createAuthRequest(apiKey, apiSecret ){
var timestamp = Math.floor(Date.now() / 1000); // Note: java and javascript timestamp presented in miliseconds
var args = { e: 'auth', auth: { key: apiKey,
signature: createSignature(timestamp, apiKey, apiSecret), timestamp: timestamp } };
var authMessage = JSON.stringify( args );
return authMessage;
}
import hmac
import hashlib
import datetime
import json
# Python 2.7
#
def create_signature_Py27(key, secret): # (string key, string secret)
timestamp = int(datetime.datetime.now().timestamp()) # UNIX timestamp in seconds
string = "{}{}".format(timestamp, key)
return hmac.new(secret, string, hashlib.sha256).hexdigest()
# Python 2.7 - 3.5+
# Note: latest versions of hmac lib requires 'secret' and 'string' as byte strings but not unicode
#
def create_signature(key, secret): # (string key, string secret)
timestamp = int(datetime.datetime.now().timestamp()) # UNIX timestamp in seconds
string = "{}{}".format(timestamp, key)
return timestamp, hmac.new(secret.encode(), string.encode(), hashlib.sha256).hexdigest()
def auth_request(key, secret):
timestamp, signature = create_signature(key, secret)
return json.dumps({'e': 'auth',
'auth': {'key': key, 'signature': signature, 'timestamp': timestamp,}, 'oid': 'auth', })
auth_request = auth_request('1WZbtMTbMbo2NsW12vOz9IuPM', '1IuUeW4IEWatK87zBTENHj1T17s')
using System;
using Newtonsoft.Json;
public class AuthExample {
private class AuthArgs {
public string key { get; set; }
public string signature { get; set; }
public int timestamp { get; set; }
}
private class Args {
public string e { get; set; }
public AuthArgs auth { get; set; }
}
private string SerializeJson(object obj) {
return Newtonsoft.Json.JsonConvert.SerializeObject(obj);
}
private int getUnixTimestamp() {
var epochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return (int)(DateTime.UtcNow - epochStart).TotalSeconds;
}
public string CreateSignature(string timestamp, string apiKey, string apiSecret) {
var hmac = new System.Security.Cryptography.HMACSHA256(System.Text.Encoding.UTF8.GetBytes(apiSecret));
var hash = hmac.ComputeHash(System.Text.Encoding.UTF8.GetBytes(timestamp + apiKey));
var signature = BitConverter.ToString(hash).Replace("-", ""); // Convert to Hex
return signature;
}
public string CreateAuthRequest(string apiKey, string apiSecret) {
int timestamp = getUnixTimestamp();
var authArgs = new AuthArgs {
key = apiKey,
signature = CreateSignature(timestamp.ToString(), apiKey, apiSecret),
timestamp = timestamp
};
var args = new Args {
e = "auth",
auth = authArgs
};
var authMessage = SerializeJson(args);
return authMessage;
}
public void Main() {
var AuthRequest = CreateAuthRequest("apiKey", "apiSecret");
}
}
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
public class AuthExample {
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
private static final String MAC_ALGORITHM = "HmacSHA256";
private static final ObjectMapper JSON = new ObjectMapper();
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for (int j = 0; j < bytes.length; j++) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = HEX_ARRAY[v >>> 4];
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
}
return new String(hexChars);
}
private static String createSignature(String apiKey, String apiSecret, String timestamp) {
try {
Mac hmacSHA256 = Mac.getInstance(MAC_ALGORITHM);
hmacSHA256.init(new SecretKeySpec(apiSecret.getBytes(), MAC_ALGORITHM));
return bytesToHex(hmacSHA256.doFinal((timestamp + apiKey).getBytes()));
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
return null;
}
}
private static String createAuthRequest(String apiKey, String apiSecret) {
long timestamp = System.currentTimeMillis() / 1000L;
String signature = createSignature(apiKey, apiSecret, String.valueOf(timestamp));
Map<String, Object> args = new HashMap<>();
args.put("e", "auth");
Map<String, Object> auth = new HashMap<>();
auth.put("key", apiKey);
auth.put("signature", signature);
auth.put("timestamp", timestamp);
args.put("auth", auth);
try {
return JSON.writeValueAsString(args);
} catch (JsonProcessingException e) {
return null;
}
}
public static void main(String[] args) {
String authRequest = createAuthRequest("apiKey", "apiSecret");
}
}
To get access to CEX.IO WebSocket data, you should be authorized.
To authorize your account with CEX.IO, please get required keys using the following instructions:
- Log in to CEX.IO account.
- Go to https://cex.io/trade/profile#/api page.
- Select type of required permissions.
- Click "Generate Key" button and save your secret key, as it will become inaccessible after activation.
- Activate your key.
Authentication Request Parameters:
Parameter Name | Type | Description |
---|---|---|
key | string | API key |
signature | string | Client signature (digest of HMAC-rsa256 with client's API Secret Key, applied to the string, which is concatenation |
timestamp | timestamp | timestimp in seconds, used for signature |
Request example:
{
"e": "auth",
"auth": {
"key": "1WZbtMTbMbo2NsW12vOz9IuPM.",
"signature": "02483c01efc26fac843dd34d0342d269bacf4daa906a32cb71806eb7467dcf58",
"timestamp": 1448034533
}
}
Response example:
{
"e": "auth",
"data": {
"ok": "ok"
},
"ok": "ok",
"timestamp": 1448034593
}
Test case 1 for createSignature:
Parameter | Value |
---|---|
apiSecret | 1IuUeW4IEWatK87zBTENHj1T17s |
timestamp | 1448034533 |
apiKey | 1WZbtMTbMbo2NsW12vOz9IuPM |
signature | 7d581adb01ad22f1ed38e1159a7f08ac5d83906ae1a42fe17e7d977786fe9694 |
Note: timestamp 1448034533 means Fri Nov 20 2015 17:48:53 GMT+0200 (EET)
Test case 2 for createSignature:
Parameter | Value |
---|---|
apiSecret | 1IuUeW4IEWatK87zBTENHj1T17s |
timestamp | 1448035135 |
apiKey | 1WZbtMTbMbo2NsW12vOz9IuPM |
signature | 9a84b70f51ea2b149e71ef2436752a1a7c514f521e886700bcadd88f1767b7db |
Note: timestamp 1448035135 means Fri Nov 20 2015 17:58:55 GMT+0200 (EET)
Connectivity & Protocol Special Messages
Connected message
Server sends 'Connected' message just after WebSocket handshake
{
"e": "connected"
}
- can be received in case WebSocket client has reconnected, which means that client needs to send 'authenticate' request and subscribe for notifications, like by first connection
Heartbeat (Ping - Pong) message
Some clarifications to Heartbeat messages:
- If a connected Socket is inactive for 15 seconds, CEX.IO server will send a PING message.
- Only server can be an Initiator of PING request.
- Server sends ping only to authenticated user.
- The user has to respond with a PONG message. Otherwise, the WebSocket will be DISCONNECTED.
- The PING message contains a 'time' property as timestamp-ms.
- Client can send another request, instead of pong. It will have the same effect.
- For authenticated user, in case there is no notification or ping from server within 15 seconds, it would be safer to send a request like 'ticker' or 'get-balance' and receive response, in order to ensure connectivity and authentication.
Example of PING request:
{
"e": "ping",
"time": 1435927943922
}
Example of PONG response:
{
"e": "pong"
}
Disconnecting message
In case Server is disconnecting, it sends a 'disconnecting' message prior to actual disconnection.
'Disconnecting' message:
{
"e": "disconnecting",
"reason": "no pong response",
"time": 1456946866378
}
- currently, the message is sent only if there is no pong response on time.
Dropping connection by server
- From time to time (0.5-1 hour), server drops connection without sending 'disconnecting' message. This is a technical issue that is not going to be solved within CEX.IO v1.0. Therefore, user apps should implement kind of proxy connector to ensure that connection is alive and re-connect when not.
- Server may also drop connection intentially, for example due to unexpected requests.
Rate Limit
- Server limits WebSocket client to 600 requests per 10 minutes.
- If client exceeds the limit, all responses to further requests will have an error, like shown in this example:
Error: 'Rate limit exceeded':
{
"e": "ticker",
"data": {
"time": 1457092944426,
"error": "Rate limit exceeded"
}
}
- server will continue to process requests within 10 minutes
Public Channels
- Ticker feed with only price of transaction made on all pairs (deprecated)
- OHLCV chart feeds with Open, High, Low, Close, Volume numbers (deprecated)
- Market Depth feed (deprecated)
- Order Book feed (deprecated)
Ticker subscription
- Ticker subscription allows you to subscribe to real-time updates of executed trades.
- Notification does not include information like lowest and highest prices, volume, but indicates that trading is happening.
Request:
{
"e": "subscribe",
"rooms": [
"tickers"
]
}
Notification example:
This notification represents the currency pair and price of last submitted trade. The message is sent any time when trade transaction on any pair is executed.
{
"e": "tick",
"data": {
"symbol1": "BTC",
"symbol2": "USD",
"price": "428.0123"
}
}
OHLCV charts subscriptions
- OHLCV initial chart (snapshot): 1m 3m 5m 15m 30m 1h 2h 4h 6h 12h 1d 3d 1w
- OHLCV requested chart updates
- 1m OHLCV chart update is sent regardless of which initial chart has been requested
- 1d OHLCV chart update is sent regardless of which one has been requested
Web page, visualizing all data the subscription gives:
https://cex.io/btc-usd
- Note: In WebSocket notifications, volumes are presented as not formatted integers; WebClient formats them appropriately, using functions given by server. Thus, presentation approach to a given currency may change at any time.
- Note: "new" means subscription instead of the older one, which is also available.
Request Example:
{
"e": "init-ohlcv",
"i": "1m",
"rooms": [
"pair-BTC-USD"
]
}
Results in following Notification Examples:
1d OHLCV chart update
{
"e": "ohlcv24",
"pair": "BTC:USD",
"data": [
"418.2936",
"420.277",
"412.09",
"416.9778",
"201451078368"
]
}
Array of data for the last 120 minutes
{
"e": "ohlcv-init-new",
"data": [ [
[
1457512080,
"417.0058",
"417.0058",
"416.7174",
"416.9364",
"122379919"
], [
1457512140,
"416.848",
"417.15",
"416.8423",
"416.8423",
"826080001"
],
...
],
"pair": "BTC:USD"
}
- Please note that data in array doesn"t include the last element of array.
- There can also be less than 120 elements in response array in case they are not available.
Array with data about latest block (may include a few blocks next to the latest)
{
"e": "ohlcv-new",
"data": [
[
1457519400,
"414.64",
"417.5",
"414.64",
"416.9778",
"880702380"
],
...
]
"pair": "BTC:USD"
},
Data with changes happened during the last period (1M in this case)
{
"e": "ohlcv1m",
"data": {
"c": "417.1519",
"d": 28570000,
"l": "417.1519",
"o": "417.1519",
"h": "417.1519",
"v": 28570000
"pair": "BTC:USD",
"time": "1457519460",
}
}
Old Pair-Room Subscription
- This is the oldest subscription, on which Server is sending almost all public data to WebClient. The data, in fact, represents Order Book, Market Depth, Trade History and History Updates, 1d OHLCV updates. Therefore, the subscription is overlapping with new OHLCV subscriptions, Order Book subscription for authenticated user. Authenticated user can use either new, old or both.
Request:
{
"e": "subscribe",
"rooms": ["pair-BTC-USD"]
}
Results in following Notification Examples:
1d OHLCV updates
{
"e": "ohlcv24",
"pair": "BTC:USD",
"data": [
"415.5804",
"418.94",
"413.0568",
"416.8241",
239567198169
]
}
Order Book snapshot
{
"e": "md",
"data": {
"pair": "BTC:USD",
"buy_total": 63221099,
"sell_total": 112430315118,
"id": 11296131,
"sell": [
[426.45, 10000000],
[426.5, 66088429300],
[427, 1000000],
... 50 pairs overaall
],
"buy": [
[423.3, 4130702],
[423.2701, 10641168],
[423.2671, 1000000],
... 50 pairs overaall
]
}
}
- presents Order Book snapshot with depth 50
- amounts presented as unformated integers - in given sample BTC in "Satoshi"
Market Depth
{
"e": "md_groupped",
"data": {
"pair": "BTC:USD",
"id": 11296131,
"sell": {
"427.5000": 1000000,
"480.0000": 263544334,
...
},
"buy": {
"385.0000": 3630000,
"390.0000": 1452458642,
... 400+ pairs together with "sell" pairs
}
}
}
- presents aggregated price / amount chart
- counted on the snapshot of full Order Book with the same ID
- id is incremental id of Order Book at the time of counting
- price/amount pairs are presented as key-value dictionary, thus they are unordered
- amounts are presented as unformatted integers - in given sample BTC in "Satoshi"
- each amount presents the sum for given price interval
History snapshot
{
"e": "history",
"data": {
"buy:1457703205200:46860000:423.7125:735479",
"sell:1457703191363:35430000:423.7125:735478",
... 201 items
}
}
- presents trade history of 201 records
- is sent once after subscription
- does not indicate requested pair
- format: "sell/buy:timestamp_ms:amount:price:transaction_id"
- amounts presented as unformatted integers - in given sample BTC in "Satoshi"
History update
{
"e": "history-update",
"data": [
["sell", "1457703218519", "41140000", "423.7125", "735480"],
... 0 to n records
]
}
- presents history update, is being sent regulary
- does not indicate requested pair
- doesn"t have incremental id
- format: ["sell"/"buy", timestamp_ms, amount, price, transaction_id]
- amounts presented as unformatted integers - in given sample BTC in "Satoshi"
Private Channels
In addition to public channels, an authorized user has access to:
- Private account information, like balances, placed orders, executed orders
- Trading functionality
- Order Book feed (new)
- Trade feeds
Common format
All new API functionality is implemented in uniformat:
Mandatory blocks/parameters of request:
Parameter/block name | Description |
---|---|
e | message(event) name |
data | data block in request |
oid | string object identifier, needed for client to associate response with sent request. It's up to client how to generate oid, unique in required skope. In any case, server simply sends it back in response. It may be, for example, concatenation of timestamp, incremental number and request name. |
Response correspondently has:
Parameter/block name | Description |
---|---|
e | event name - the same as in request |
data | data block of the response |
oid | object identifier, the same as in request |
ok | status code: 'ok' or 'error' |
data[error] | in case of 'error' result, the error message is added to the data block as 'error' |
Note: All requests sent via PUSH method HAVE NO OID parameters at all
Note: All newly created functions use this format of request / response
'Ticker' request
- This is the simplest request to ensure that client is connected and authenticated.
- Returns the response with the lowest ask price and highest bid price for the pair.
- The request might be descoped, because it's not very informative and it is not a subscription for ticker.
Request:
Parameter Name | Value | Description |
---|---|---|
ccy1 | ISO 4217 | Currency 1 |
ccy2 | ISO 4217 | Currency 2 |
oid | string | OID identifier (number / text) |
Request example:
{
"e": "ticker",
"data": [
"BTC",
"USD"
],
"oid": "1435927928274_1_ticker"
}
Response:
Parameter Name | Value | Description |
---|---|---|
pair | list | Requested currency pair. Consists of ccy1 and ccy2 parameters |
bid | decimal | Bid price value |
ask | decimal | Ask price value |
oid | string | OID identifier (number / text) |
low | string | Last 24 hours price low |
high | string | Last 24 hours price high |
last | string | Last BTC price |
volume | string | Last 24 hours volume |
volume30d | string | Last 30 days volume |
Response example:
{
"e": "ticker",
"data": {
"timestamp": "1471427037",
"low": "290",
"high": "290",
"last": "290",
"volume": "0.02062068",
"volume30d": "14.38062068",
"bid": 240,
"ask": 290,
"pair": [
"BTC",
"USD"
]
},
"oid": "1471427036908_1_ticker",
"ok": "ok"
}
'not authenticated' response example:
{
"ok": "error",
"e": "ticker",
"oid": "1457513058865_1_ticker",
"data": {"error": "Please Login"}
}
Get balance request
Request:
Parameter Name | Value | Description |
---|---|---|
oid | ISO 4217 | Currency 1 |
Request example:
{
"e": "get-balance",
"data": {},
"oid": "1435927928274_2_get-balance"
}
Response:
Parameter Name | Value | Description |
---|---|---|
balance | array | Returns list of all currencies in wallet with current balances |
obalance | array | Balance of user's orders |
time | timestamp-ms | Time identifier |
oid | string | OID identifier (number / text) |
Response example:
{
"e": "get-balance",
"data": {
"balance": {
"LTC": "10.00000000",
"USD": "1024.00",
"RUB": "35087.98",
"EUR": "217.53",
"GHS": "10.00000000",
"BTC": "9.00000000"
},
"obalance": {
"BTC": "0.12000000",
"USD": "512.00",
},
},
"time": 1435927928597
"oid": "1435927928274_2_get-balance",
"ok": "ok"
}
Order Book subscription
Request:
Parameter Name | Value | Description |
---|---|---|
pair | ----- | Requested currency pair. Consists of ccy1 and ccy2 parameters |
ccy1 | ISO 4217 | Currency 1 |
ccy2 | ISO 4217 | Currency 2 |
subscribe | boolean | subscribe mode |
depth | -1, 0, N | Depth of data in response |
oid | string | OID identifier (number / text) |
- -1: empty data in response
- 0: unlimited data in response
- N: depth of data mentioned in request
Request example:
{
"e": "order-book-subscribe",
"data": {
"pair": [
"BTC",
"USD"
],
"subscribe": false,
"depth": -1
},
"oid": "1435927928274_3_order-book-subscribe"
}
Response:
Parameter Name | Value | Description |
---|---|---|
timestamp | timestamp | Time identifier |
bids | array | List of bid rates |
asks | array | List of ask rates |
pair | ----- | Requested currency pair. Consists of ccy1 and ccy2 parameters. |
id | integer | incremental version |
oid | string | OID identifier (number / text) |
Incremental version id:
- is to be used to build client presentation of order book
- firstly, id is returned in the response with a snapshot of order book
- then, server is sending incremental updates (Market data update), id is incremeted by 1 with each update
- suggested approach to build order-book locally is following:
- request snapshot with subscription and start collecting updates;
- when snapshot received, increment collected updates, starting from the id, next to the id in snapshot received;
- if one update is missed, the client presentation of order-book becomes inconsistent
Empty order book:
{
"e": "order-book-subscibe",
"data": {
"timestamp": 1435927929,
"bids": [],
"asks": [],
"pair": "BTC:USD",
"id": 67809
},
"oid": "1435927928274_3_order-book-subscribe",
"ok": "ok"
}
Order book with subscription data & depth = 10
{
"e": "order-book-subscibe",
"data": {
"timestamp": 1435927929,
"bids": [
[
241.947,
155.91626
],
[
241,
981.1255
],
],
"asks": [
[
241.95,
15.4613
],
[
241.99,
17.3303
],
],
"pair": "BTC:USD",
"id": 67809
},
"oid": "1435927928274_5_order-book-subscribe",
"ok": "ok"
}
Unsubscribe from order book
Request:
Parameter Name | Value | Description |
---|---|---|
pair | ----- | Requested currency pair. Consists of ccy1 and ccy2 parameters. |
ccy1 | ISO 4217 | Currency 1 |
ccy2 | ISO 4217 | Currency 2 |
oid | string | OID identifier (number / text) |
Request example:
{
"e": "order-book-unsubscribe",
"data": {
"pair": [
"BTC",
"USD"
]
},
"oid": "1435927928274_4_order-book-unsubscribe"
}
Response:
Parameter Name | Value | Description |
---|---|---|
pair | ----- | Requested currency pair. Consists of ccy1 and ccy2 parameters. |
oid | string | OID identifier (number / text) |
Response example:
{
"e": "order-book-unsubscribe",
"data": {
"pair": "BTC:USD"
},
"oid": "1435927928274_4_order-book-unsubscribe",
"ok": "ok"
}
List of open orders
Request:
Parameter Name | Value | Description |
---|---|---|
pair | ----- | Requested currency pair. Consists of ccy1 and ccy2 parameters. |
oid | string | OID identifier (number / text) |
Request example:
{
"e": "open-orders",
"data": {
"pair": [
"BTC",
"USD"
]
},
"oid": "1435927928274_6_open-orders"
}
Response:
Parameter Name | Value | Description |
---|---|---|
id | integer | Order identifier |
time | timestamp-ms | Time identifier |
type | Buy / Sell | Order direction |
price | decimal | Order price (rate of ccy pair for order) |
amount | decimal | Order amount |
pending | decimal | Order pending amount |
oid | string | OID identifier (number / text) |
There are no open orders at the moment:
{
"e": "open-orders",
"data": [],
"oid": "1435927928274_6_open-orders",
"ok": "ok"
}
There are some open orders at the moment:
{
"e": "open-orders",
"data": [
{
"id": "2477098",
"time": "1435927928618",
"type": "buy",
"price": "241.9477",
"amount": "0.02000000",
"pending": "0.02000000"
},
{
"id": "2477101",
"time": "1435927928634",
"type": "sell",
"price": "241.9493",
"amount": "0.02000000",
"pending": "0.02000000"
}
],
"oid": "1435927928274_9_open-orders",
"ok": "ok"
}
Order placement request
Request:
Parameter Name | Value | Description |
---|---|---|
pair | ----- | Requested currency pair. Consists of ccy1 and ccy2 parameters. |
ccy1 | ISO 4217 | Currency 1 |
ccy2 | ISO 4217 | Currency 2 |
amount | decimal | Order amount |
price | decimal | Order price |
type | Buy / Sell | Order direction |
oid | string | OID identifier (number / text) |
maker_only | boolean | Optional, maker only places an order only if offers best sell (<= max) or buy(>= max) price for this pair, if not order placement will be rejected with an error - "Order is not maker" |
Request example:
{
"e": "place-order",
"data": {
"pair": [
"BTC",
"USD"
],
"amount": 0.02,
"price": "241.9477",
"type": "buy",
"maker_only": false
},
"oid": "1435927928274_7_place-order"
}
Response:
Parameter Name | Value | Description |
---|---|---|
complete | boolean | Order completion status |
id | integer | Order ID |
time | timestamp-ms | Time identifier |
pending | decimal | Order pending amount |
amount | decimal | Order amount |
type | Buy / Sell | Order direction |
price | decimal | Order price |
oid | string | OID identifier (number / text) |
Response example:
{
"e": "place-order",
"data": {
"complete": false,
"id": "2477098",
"time": 1435927928618,
"pending": "0.02000000",
"amount": "0.02000000",
"type": "buy",
"price": "241.9477"
},
"oid": "1435927928274_7_place-order",
"ok": "ok"
}
Order cancel-replace request
Do atomic cancel & place order.
Do nothing if:
- order with order_id is done/canceled/doesn't exist
- insufficient funds
- pair, order type did not match
- price & amount are out of limits
- amount = 0
- apikey does not contain acl: acl_cancel_order
Request:
Parameter Name | Value | Description |
---|---|---|
pair | ----- | Requested currency pair. Consists of ccy1 and ccy2 parameters. |
ccy1 | ISO 4217 | Currency 1 |
ccy2 | ISO 4217 | Currency 2 |
amount | decimal | Order amount |
price | decimal | Order price |
type | Buy / Sell | Order direction |
oid | string | OID identifier (number / text) |
order_id | string | Order id to replace |
Request example:
{
"e": "cancel-replace-order",
"data": {
"order_id": "2477098",
"pair": [
"BTC",
"USD"
],
"amount": 0.04,
"price": "243.2500",
"type": "buy"
},
"oid": "1443464955209_16_cancel-replace-order"
}
Response Example (the same as in place order):
Parameter Name | Value | Description |
---|---|---|
complete | boolean | Order completion status |
id | integer | Order ID |
time | timestamp-ms | Time identifier |
pending | decimal | Order pending amount |
amount | decimal | Order amount |
type | Buy / Sell | Order direction |
price | decimal | Order price |
oid | string | OID identifier (number / text) |
Response example:
{
"e": "cancel-replace-order",
"data": {
"complete": false,
"id": "2689009",
"time": 1443464955904,
"pending": "0.04000000",
"amount": "0.04000000",
"type": "buy",
"price": "243.25"
},
"oid": "1443464955209_16_cancel-replace-order",
"ok": "ok"
}
Mass cancel place orders
Example request:
{
"e": "mass-cancel-place-orders",
"data": {
"cancel-orders": [
"1987",
"1278"
],
"place-orders": [
{
"pair": [
"BTC",
"USD"
],
"amount": 0.02,
"price": "4200",
"order_type": "limit",
"type": "buy"
}
],
"cancelPlacedOrdersIfPlaceFailed": false
}
}
Example responses
success
{
"e": "mass_cancel_place_orders",
"ok": "ok",
"data": {
"cancel-orders": [
"1987",
"1278"
],
"place-orders": [
{
"pair": [
"BTC",
"USD"
],
"amount": 0.02,
"price": "4200",
"order_type": "limit",
"type": "buy"
}
],
"placed-cancelled": [
{
"order_id": "136055974",
"fremains": "11.00000000"
}
]
}
}
order was not found
{
"e": "mass_cancel_place_orders",
"ok": "ok",
"data": {
"cancel-orders": [
{
"error": "Order not found"
}
],
"place-orders": [],
"placed-cancelled": []
}
}
Request:
Parameter Name | Value | Description |
---|---|---|
cancel-orders | array of strings | Array of order_id to cancel |
place-orders | array of orders | Array of orders to place |
pair | ----- | Requested currency pair. Consists of ccy1 and ccy2 parameters. |
ccy1 | ISO 4217 | Currency 1 |
ccy2 | ISO 4217 | Currency 2 |
amount | decimal | Order amount |
price | decimal | Order price |
type | Buy / Sell | Order direction |
order_type | limit | Order type |
oid | string | OID identifier (number / text) |
order_id | string | Order id to replace |
cancelPlacedOrdersIfPlaceFailed | boolean | Optional |
Get order request
In CEX.IO system, orders can be present in trade engine or in archive database. There can be time periods (~2 seconds or more), when order is done/canceled, but still not moved to archive database. That means, you cannot see it using calls: archived-orders/open-orders. This call allows to get order information in any case. Responses can have different format depending on orders location.
Request:
Parameter Name | Value | Description |
---|---|---|
order_id | integer | Order identifier |
oid | string | OID identifier (number / text) |
Request example:
{
"e": "get-order",
"data": {
"order_id": "2689652"
},
"oid": "1443468122384_14_get-order"
}
Response Example (from archive database (active order)):
{
"e": "get-order",
"data": {
"user": "XXX",
"type": "buy",
"symbol1": "BTC",
"symbol2": "USD",
"amount": "0.02000000",
"remains": "0.02000000",
"price": "50.75",
"time": 1450214742160,
"tradingFeeStrategy": "fixedFee",
"tradingFeeBuy": "5",
"tradingFeeSell": "5",
"tradingFeeUserVolumeAmount": "nil",
"a:USD:c": "1.08",
"a:USD:s": "1.08",
"a:USD:d": "0.00",
"status": "a",
"orderId": "5582060"
},
"oid": "1450214742135_10_get-order",
"ok": "ok"
}
Response Example (from archive database (canceled order)):
{
"e": "get-order",
"data": {
"type": "buy",
"time": 1443468122895,
"user": "XXX",
"status": "c",
"symbol1": "BTC",
"symbol2": "USD",
"amount": "0.04000000",
"price": "243.25",
"remains": "0.04000000",
"a:USD:cds": "10.22",
"tradingFeeBuy": "5",
"tradingFeeSell": "5",
"tradingFeeStrategy": "fixedFee"
},
"oid": "1443468122384_21_get-order",
"ok": "ok"
}
Response example (from archive database (completed order)):
{
"e": "get-order",
"data": {
"user": "XXX",
"type": "sell",
"symbol1": "BTC",
"symbol2": "USD",
"amount": "0.01000000",
"remains": "0.00000000",
"price": "447.63",
"time": 1450341292623,
"tradingFeeStrategy": "fixedFee",
"tradingFeeBuy": "5",
"tradingFeeSell": "5",
"tradingFeeUserVolumeAmount": "nil",
"ta:USD": "4.47",
"fa:USD": "0.22",
"status": "d",
"orderId": "5668906",
"a:BTC:cds": "0.01000000",
"a:USD:cds": "4.47",
"f:USD:cds": "0.22"
},
"oid": "1450341292568_14_get-order",
"ok": "ok"
}
Fields:
Parameter Name | Value | Optional | Description |
---|---|---|---|
orderId | integer | Mandatory | Order identifier |
time | timestamp-ms | Mandatory | Time identifier |
oid | string | Mandatory | OID identifier (number / text) |
type | string | Mandatory | Order type (buy/sell) |
symbol1 | ISO 4217 | Mandatory | |
symbol2 | ISO 4217 | Mandatory | |
amount | string/float | Mandatory | Amount in symbol1 |
remains | string/float | Mandatory | Remains in symbol1 |
amount2 | string/float | Present for Instant buy orders | Amount in symbol2, for this order types amount == 0, remains == 0 |
price | string/float | Present only for limit orders | Price for limit order |
tradingFeeStrategy | string | Can be absent | Technical field telling how system calculates fee for this order |
tradingFeeBuy | string/float | Can be absent | Fee for Buy orders |
tradingFeeSell | string/float | Can be absent | Fee for Sell orders |
tradingFeeUserVolumeAmount | string/float | Can be absent or nil | User volume amount in BTC in satoshi |
a:${symbol1}:c, a:${symbol2}:c | string/float | Can be absent | Credit (total amount transferred to order) |
a:${symbol1}:d, a:${symbol2}:d | string/float | Can be absent | Debit (total amount transferred from order) |
a:${symbol1}:s, a:${symbol2}:s | string/float | Can be absent | Saldo for one symbol in case of cancelling a non-matching order |
a:${symbol1}:cds, a:${symbol2}:cds | string/float | If a:${symbol}:s == 0 and a:${symbol}:d == a:${symbol}:c | Total turnover for symbol |
status | string | Order status: "d" — done (fully executed), "c" — canceled (not executed), "cd" — cancel-done (partially executed) | |
ta:${symbol2} | string/float | Present if order matched with another order | Total amount transferred between matched orders in symbol 2. Used for fee calculation. |
fa:${symbol2} | string/float | Present if order matched with another order | Fee amount charged for this order in symbol 2. |
Order cancel request
Request:
Parameter Name | Value | Description |
---|---|---|
order_id | integer | Order identifier |
oid | string | OID identifier (number / text) |
Request example:
{
"e": "cancel-order",
"data": {
"order_id": "2477098"
},
"oid": "1435927928274_12_cancel-order"
}
Response example:
{
"e": "cancel-order",
"data": {
"order_id": "2477098"
"time": 1443468122895
},
"oid": "1435927928274_12_cancel-order",
"ok": "ok"
}
Response:
Parameter Name | Value | Description |
---|---|---|
order_id | integer | Order identifier |
time | timestam-ms | Time identifier |
oid | string | OID identifier (number / text) |
List of archived orders
Request:
Parameter Name | Value | Description |
---|---|---|
pair | ----- | Requested currency pair. Consists of ccy1 and ccy2 parameters. |
ccy1 | ISO 4217 | Currency 1 |
ccy2 | ISO 4217 | Currency 2 |
limit | integer | Number of orders in response (100 orders in response is a maximum) |
dateFrom | unix time | Starting date for search |
dateTo | unix time | Ending date for search |
oid | string | OID identifier (number / text) |
Request example:
{
"e": "archived-orders",
"data": {
"pair": [
"BTC",
"USD"
],
"limit": 6
},
"oid": "1435927928274_15_archived-orders"
}
Response example:
{
"e": "archived-orders",
"data": [
{
"type": "buy",
"symbol1": "BTC",
"symbol2": "USD",
"amount": 0,
"amount2": 5000,
"remains": 0,
"time": "2015-04-17T10:46:27.971Z",
"tradingFeeBuy": "2",
"tradingFeeSell": "2",
"ta:USD": "49.00",
"fa:USD": "0.98",
"orderId": "2340298",
"status": "d",
"a:BTC:cds": "0.18151851",
"a:USD:cds": "50.00",
"f:USD:cds": "0.98"
},
{
"type": "buy",
"symbol1": "BTC",
"symbol2": "USD",
"amount": 0,
"amount2": 10000,
"remains": 0,
"time": "2015-04-08T15:46:04.651Z",
"tradingFeeBuy": "2.99",
"tradingFeeSell": "2.99",
"ta:USD": "97.08",
"fa:USD": "2.91",
"orderId": "2265315",
"status": "d",
"a:BTC:cds": "0.39869578",
"a:USD:cds": "100.00",
"f:USD:cds": "2.91"
}
],
"oid": "1435927928274 15_archived-orders",
"ok": "ok"
}
Response:
Parameter Name | Value | Description |
---|---|---|
type | Buy / Sell | Order direction |
symbol1 | ISO 4217 | Currency 1 |
symbol2 | ISO 4217 | Currency 2 |
amount | integer | Amount of currency 1 |
amount2 | integer | Amount of currency 2 |
remains | integer | Remaining amount |
time | datetime | Archived orders request datetime |
tradingFeeBuy | integer | Buy Trading Fee size |
tradingFeeSell | integer | Buy Trading Fee size |
ta | integer | Total amount |
fa | integer | Fee amount (always relates to 2nd currency ) |
orderId | integer | Order identifier |
status | dictionary | Order status |
a: |
integer | Account turnover for currency 1 |
a: |
integer | Account turnover for currency 2 |
oid | string | OID identifier (number / text) |
Asynchronous messages
Asynchronous messages are those that can be received in asynchronous way. Usually, these messages are obtained after order book changes (order submission, cancelation, market data update, etc.).
Transaction created (Order successfully completed)
Message:
Parameter Name | Value | Description |
---|---|---|
order | integer | Order ID |
a | ISO 4217 | Purchase currency |
user | string | User ID |
symbol | ISO 4217 | Currency1 |
symbol2 | ISO 4217 | Currency2 |
amount | integer | Trade amount |
buy | integer | Order ID for BUY transaction |
sell | integer | Order ID for SELL transaction |
price | decimal | Order price |
type | Buy / Sell | Order direction |
time | timestamp-ms | Time identifier |
balance | integer | User balance in Purchase currency |
fee_amount | integer | Trade Fee size |
_id | integer | Identifier |
Message example:
{
"e": "tx",
"data": {
"d": "order:3346263232:a:USD",
"c": "user:lukianie:a:USD",
"a": 260,
"user": "lukianie",
"symbol": "USD",
"symbol2": "BTC",
"amount": 260,
"buy": 3346261766,
"sell": 3346263232,
"price": 261.2994,
"type": "sell",
"time": 1439460482708,
"balance": 286,
"fee_amount": 1,
"_id": "c773ecc60000000000000000"
}
}
Balance message
Message:
Parameter Name | Value | Description | Precision |
---|---|---|---|
symbol | ISO 4217 | Currency | |
balance | integer | Current balance per currency | 1 USD = 100 units, 1 EUR = 100 units, 1 GBP = 100 units, 1 RUB = 100 units, 1 BTC = 100000000 units, 1 LTC = 100000000 units, 1 GHS = 100000000 units, 1 ETH = 1000000 units |
Message example:
{
"e": "balance",
"data": {
"symbol": "BTC",
"balance": "292012361221"
}
}
OBalance message
Balance of user orders.
Message:
Parameter Name | Value | Description | Precision |
---|---|---|---|
symbol | ISO 4217 | Currency | |
balance | integer | Current balance per currency | 1.00 USD = 100 units |
Message example:
{
"e": "obalance",
"data": {
"symbol": "BTC",
"balance": "0"
}
}
Market data update
Parameters:
Parameter Name | Value | Description |
---|---|---|
id | integer | MD request identifier |
pair | ----- | Requested currency pair. Consists of ccy1 and ccy2 parameters. |
ccy1 | ISO 4217 | Currency 1 |
ccy2 | ISO 4217 | Currency 2 |
time | timestamp-ms | Time identifier |
bids | array | Bid values |
asks | array | Ask values |
{
"e": "md_update",
"data": {
"id": 67814,
"pair": "BTC:USD",
"time": 1435927928879,
"bids": [
[
241.9477,
0
],
...
],
"asks": []
}
}
Standalone responses
Standalone responses are responses providing up-to-date information about the order in WebSocket API. You will get constant updates about remains of the order till it is fully executed, and its remains are equal to zero. Note that amount of remains is shown in the smallest fraction of available currency (e.g. for USDC the smallest fraction is 0.000001, so 10 USDC in smallest values would be equal 10000000).
Here’s an example showing partial execution of the order:
{
"e": "order",
"data": {
"id": "150714937",
"remains": "1000000",
"price": "17513",
"amount": 2000000,
"time": "1654506118448",
"type": "buy",
"pair": {
"symbol1": "BTC",
"symbol2": "USD"
},
"fee": "0.15"
}
}
This is an example of fullfiled order
{
"e": "tx",
"data": {
"d": "order:150714937:a:BTC",
"c": "user:ud203594005:a:BTC",
"a": "0.01000000",
"ds": 0,
"cs": "1.79934955",
"user": "ud203594005",
"symbol": "BTC",
"symbol2": "USD",
"amount": "0.01000000",
"buy": 150714937,
"order": 150714937,
"sell": 150714935,
"price": 17513,
"type": "buy",
"time": "2022-06-06T09:01:58.448Z",
"balance": "1.79934955",
"fee_amount": "0.44",
"id": "150714943"
}
}
This is an example of remaining order
{
"d": "order:150714937:a:USD",
"c": "user:ud203594005:a:USD",
"a": "0.17",
"ds": "175.40",
"cs": "999026.90",
"user": "ud203594005",
"symbol": "USD",
"order": 150714937,
"amount": "-350.97",
"type": "buy",
"time": "2022-06-06T09:01:58.448Z",
"balance": "999026.90",
"id": "150714947"
}
This is an example of cancel order:
{
"e": "order",
"data": {
"id": "6310857",
"remains": "200000000"
"fremains" :"2.00000000"
"cancel": true,
"pair":
{ "symbol1": "BTC", "symbol2": "USD" }
}
}
Examples of error responses
In this section you can see some error request and responses
Authenticate
You might receive such error in auth
events:
- "Invalid Key"
- "Key not activated"
- "Invalid Signatue"
- "Timestamp is not in 20 sec range"
Request:
{
"e": "auth",
"auth": {
"key": "1WZbtMTbMbo2NsW12vOz9IuPM.",
"signature": "02483c01efc26fac843dd34d0342d269bacf4daa906a32cb71806eb7467dcf58",
"timestamp": 1448034533
}
}
Response:
{
"e": "auth",
"data": {
"error": "Invalid Key" / "Key not activated" / "Invalid Signatue" / "Timestamp is not in 20 sec range"
},
"ok": "error",
"timestamp":1448034593
}
Ticker
If you pass incorrect pair to ticker
you will get "Invalid pair:..."
error.
Request:
{
"e": "ticker",
"data": [
"undefined",
"Unknown"
],
"oid": "1435927928274_17_ticker"
}
Response:
{
"e": "ticker",
"data": {
"error": "Invalid pair:undefined:Unknown."
},
"oid": "1435927928274_17_ticker",
"ok": "error"
}
Order book subscription
If you pass incorrect pair to order-book-subscribe
you will get "Invalid pair:..."
error.
Request:
{
"e": "order-book-subscribe",
"data": {
"pair": [
"Undefined",
"Unknown"
],
"subscribe": false,
"depth": -1
},
"oid": "1435927928274_18_order-book-subscribe"
}
Response:
{
"e": "order-book-subscribe",
"data": {
"error": "Invalid pair:Undefined:Unknown."
},
"oid": "1435927928274_18_order-book-subscribe",
"ok": "error"
}
Unsubscribe from order book
If you pass incorrect pair to order-book-unsubscribe
you will get "Invalid pair:..."
error.
Request:
{
"e": "order-book-unsubscribe",
"data": {
"pair": [
"Undefined",
"Unknown"
]
},
"oid": "1435927928274_19_order-book-unsubscribe"
}
Response:
{
"e": "order-book-unsubscribe",
"data": {
"error": "Invalid pair:Undefined:Unknown."
},
"oid": "1435927928274_19_order-book-unsubscribe",
"ok": "error"
}
Order placement
If you pass incorrect pair to place-order
you will get "There was an error while placing your order: Wrong currency pair."
.
Request:
{
"e": "place-order",
"data": {
"pair": [
"Undefined",
"Unknown"
],
"amount": 0.02,
"price": 241.9485,
"type": "sell"
},
"oid": "1435927928274_20_place-order"
}
Response:
{
"e": "place-order",
"data": {
"error": "There was an error while placing your order: Wrong currency pair."
},
"oid": "1435927928274_20_place-order",
"ok": "error"
}
REST API
BASE URL: https://cex.io/api
Public API calls
Currency limits
Code samples
const headers = {
'Accept':'application/json'
};
fetch('https://cex.io/api/currency_limits',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': 'application/json'
}
r = requests.get('https://cex.io/api/currency_limits', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakeGetRequest()
{
string url = "https://cex.io/api/currency_limits";
var result = await GetAsync(url);
}
/// Performs a GET Request
public async Task GetAsync(string url)
{
//Start the request
HttpResponseMessage response = await Client.GetAsync(url);
//Validate result
response.EnsureSuccessStatusCode();
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/currency_limits");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
GET /currency_limits
Data about minimal & maximal limits per order for all pairs. Symbol1 & Symbol2 must be in range which specified in minLotSize/maxLotSize & minLotPrice2, plus price must be in range which specified in minPrice/maxPrice.
Example responses
successful operation
{
"e": "currency_limits",
"ok": "ok",
"data": {
"pairs": [
{
"symbol1": "BTC",
"symbol2": "USD",
"minLotSize": 0.01,
"minLotSizeS2": 2.5,
"maxLotSize": 30,
"minPrice": "100",
"maxPrice": "35000"
},
{
"symbol1": "ETH",
"symbol2": "USD",
"minLotSize": 0.1,
"minLotSizeS2": 2.5,
"maxLotSize": 1000,
"minPrice": "2.5",
"maxPrice": "4096"
},
{
"symbol1": "BCH",
"symbol2": "USD",
"minLotSize": 0.01,
"minLotSizeS2": 2.5,
"maxLotSize": 30,
"minPrice": "50",
"maxPrice": "5128"
}
]
}
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | successful operation | LimitsResponse |
Ticker
Code samples
const headers = {
'Accept':'*/*'
};
fetch('https://cex.io/api/ticker/{symbol1}/{symbol2}',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': '*/*'
}
r = requests.get('https://cex.io/api/ticker/{symbol1}/{symbol2}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakeGetRequest()
{
string url = "https://cex.io/api/ticker/{symbol1}/{symbol2}";
var result = await GetAsync(url);
}
/// Performs a GET Request
public async Task GetAsync(string url)
{
//Start the request
HttpResponseMessage response = await Client.GetAsync(url);
//Validate result
response.EnsureSuccessStatusCode();
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/ticker/{symbol1}/{symbol2}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
GET /ticker/{symbol1}/{symbol2}
Basic trading information about currency pair for last 24 hours. Note - pair is case-sensitive, so BTC/USD
is valid pair, but btc/usd
is not.
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
Example responses
200 Response
successful operation
{
"timestamp": "12345678",
"low": "1234.12",
"high": "1234.12",
"last": "1234.12",
"volume": "0.10000000",
"volume30d": "1234.00000200",
"bid": 1234.12,
"ask": 1234.12,
"priceChange": "-2058.3",
"priceChangePercentage": "-9.18",
"pair": "BTC:USD"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | successful operation | Ticker |
Tickers for all pairs by markets
Code samples
const headers = {
'Accept':'*/*'
};
fetch('https://cex.io/api/tickers/{symbol1}/{symbol2}/.../{marketSymbolN}',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': '*/*'
}
r = requests.get('https://cex.io/api/tickers/{symbol1}/{symbol2}/.../{marketSymbolN}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakeGetRequest()
{
string url = "https://cex.io/api/tickers/{symbol1}/{symbol2}/.../{marketSymbolN}";
var result = await GetAsync(url);
}
/// Performs a GET Request
public async Task GetAsync(string url)
{
//Start the request
HttpResponseMessage response = await Client.GetAsync(url);
//Validate result
response.EnsureSuccessStatusCode();
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/tickers/{symbol1}/{symbol2}/.../{marketSymbolN}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
GET /tickers/{symbol1}/{symbol2}/.../{marketSymbolN}
Basic trading information about requested currency pairs. The result shows tickers for all currency pairs with requested symbols. Note - pair is case-sensitive, so BTC/USD
is valid pair, hence btc/usd
is not.
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
Example responses
200 Response
OK
{
"ok": "ok",
"e": "tickers",
"data": [
{
"timestamp": "1663149107",
"pair": "BTC:USD",
"low": "19901",
"high": "22779.2",
"last": "20345.3",
"volume": "137.84582894",
"volume30d": "1669.46423487",
"priceChange": "-2059.0",
"priceChangePercentage": "-9.19",
"bid": 20347.7,
"ask": 20349.4
},
{
"timestamp": "1663149107",
"pair": "ETH:USD",
"low": "1555.96",
"high": "1759.4",
"last": "1602.53",
"volume": "3171.78101900",
"volume30d": "40308.62116300",
"priceChange": "-122.21",
"priceChangePercentage": "-7.09",
"bid": 1603.26,
"ask": 1603.57
},
{
"timestamp": "1663149107",
"pair": "BCH:USD",
"low": "116.87",
"high": "141.49",
"last": "119.75",
"volume": "196.36407693",
"volume30d": "1053.62091951",
"priceChange": "-12.39",
"priceChangePercentage": "-9.38",
"bid": 119.31,
"ask": 119.71
},
]
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Tickers |
Last price
Code samples
const headers = {
'Accept':'*/*'
};
fetch('https://cex.io/api/last_price/{symbol1}/{symbol2}',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': '*/*'
}
r = requests.get('https://cex.io/api/last_price/{symbol1}/{symbol2}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakeGetRequest()
{
string url = "https://cex.io/api/last_price/{symbol1}/{symbol2}";
var result = await GetAsync(url);
}
/// Performs a GET Request
public async Task GetAsync(string url)
{
//Start the request
HttpResponseMessage response = await Client.GetAsync(url);
//Validate result
response.EnsureSuccessStatusCode();
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/last_price/{symbol1}/{symbol2}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
GET /last_price/{symbol1}/{symbol2}
Get last price for each trading pair will be defined as the price of the last executed order for this pair.
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
Example responses
200 Response
OK
{
"lprice": "17663",
"curr1": "BTC",
"curr2": "USD"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | PairPrice |
Last prices for given markets
Code samples
const headers = {
'Accept':'*/*'
};
fetch('https://cex.io/api/last_prices/{symbol1}/{symbol2}/{symbol3}',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': '*/*'
}
r = requests.get('https://cex.io/api/last_prices/{symbol1}/{symbol2}/{symbol3}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakeGetRequest()
{
string url = "https://cex.io/api/last_prices/{symbol1}/{symbol2}/{symbol3}";
var result = await GetAsync(url);
}
/// Performs a GET Request
public async Task GetAsync(string url)
{
//Start the request
HttpResponseMessage response = await Client.GetAsync(url);
//Validate result
response.EnsureSuccessStatusCode();
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/last_prices/{symbol1}/{symbol2}/{symbol3}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
GET /last_prices/{symbol1}/{symbol2}/{symbol3}
Get last prices for given markets. The result shows last prices for all currency pairs with requested symbol1 or symbol2 or symbol3. The last price for each currency pair will be defined as the price of the last executed order for this pair.
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
symbol3 | path | string | true | The third currency code (BTC, ETH, BCH, BTG, DASH, XRP, ZEC, GHS, USD, EUR, GBP, LTC) |
Example responses
200 Response
OK
{
"e": "last_prices",
"ok": "ok",
"data": [
{
"symbol1": "BTC",
"symbol2": "USD",
"lprice": "17656.2"
},
{
"symbol1": "ETH",
"symbol2": "USD",
"lprice": "701"
},
{
"symbol1": "BCH",
"symbol2": "USD",
"lprice": "1640"
}
]
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Enumerated Values Examples
Property | Value |
---|---|
symbol1 | BTC, ETH, BCH, BTG, DASH |
symbol2 | BTC, ETH, BCH, BTG, DASH |
Converter
Code samples
const inputBody = '{
"amnt": "2.5"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/convert/{symbol1}/{symbol2}',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/convert/{symbol1}/{symbol2}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/convert/{symbol1}/{symbol2}";
string json = @"{
""amnt"": ""2.5""
}";
ConvertRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(ConvertRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(ConvertRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/convert/{symbol1}/{symbol2}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /convert/{symbol1}/{symbol2}
Converts amount of the symbol1 currency to any symbol2 currency by multiplying the amount by the last price of the chosen pair according to the current exchange rate.
Body parameter
{
"amnt": "2.5"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
body | body | ConvertRequest | false | none |
Example responses
200 Response
OK
{
"amnt": 1000
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Status Code 200
Name | Type | Description |
---|---|---|
» amnt | number | convertible amount |
» error | string | !OPTIONAL! if error occurred |
Chart
Code samples
const inputBody = '{
"lastHours": 24,
"maxRespArrSize": 100
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/price_stats/{symbol1}/{symbol2}',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/price_stats/{symbol1}/{symbol2}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/price_stats/{symbol1}/{symbol2}";
string json = @"{
""lastHours"": 24,
""maxRespArrSize"": 100
}";
PriceStatsRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(PriceStatsRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(PriceStatsRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/price_stats/{symbol1}/{symbol2}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /price_stats/{symbol1}/{symbol2}
DEPRECATED!
Allows building price change charts (daily, weekly, monthly) and showing historical point at any point of the chart
Body parameter
{
"lastHours": 24,
"maxRespArrSize": 100
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
body | body | PriceStatsRequest | false | none |
Example responses
200 Response
OK
[
{
"tmsp": 1513063800,
"price": "17288.9"
},
{
"tmsp": 1513064700,
"price": "17374"
},
{
"tmsp": 1513065600,
"price": "17393.57"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Status Code 200
Name | Type | Description |
---|---|---|
» tmsp | number | UNIX timestamp |
» price | string | price value |
Historical OHLCV Chart
Code samples
const headers = {
'Accept':'*/*'
};
fetch('https://cex.io/api/ohlcv/hd/{date}/{symbol1}/{symbol2}',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': '*/*'
}
r = requests.get('https://cex.io/api/ohlcv/hd/{date}/{symbol1}/{symbol2}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakeGetRequest()
{
string url = "https://cex.io/api/ohlcv/hd/{date}/{symbol1}/{symbol2}";
var result = await GetAsync(url);
}
/// Performs a GET Request
public async Task GetAsync(string url)
{
//Start the request
HttpResponseMessage response = await Client.GetAsync(url);
//Validate result
response.EnsureSuccessStatusCode();
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/ohlcv/hd/{date}/{symbol1}/{symbol2}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
GET /ohlcv/hd/{date}/{symbol1}/{symbol2}
Returns dataset to build 1m OHLCV chart for a given day. Relies on historical data, is not working for current day
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
date | path | string | true | date in format "YYYYMMDD" |
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
Example responses
200 Response
OK
{
"time": 20171011,
"data1m": "[[1507680000,4793.9996,4793.9996,4787.3213,4787.3229,1.03986482],[1507680060,4793.9809,4793.9993,4793.9809,4793.9932,0.81958763]]",
"data1h": "[[1507334400,4378.1725,4395,4372.7588,4387.9062,14.244019],[1507338000,4387.8018,4400,4372.911,4385,12.50705421],[1507341600,4385,4385.46,4368.9999,4374,9.03757199]]",
"data1d": "[[1499126400,2649.6085,2710,2632.2142,2668.9757,500.1209406],[1499212800,2669.2497,2690,2617.1779,2679.2315,383.08839447],[1499299200,2679.2305,2689.7435,2638.457,2675.0076,248.49638678]]"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Status Code 200
Name | Type | Description |
---|---|---|
» time | number | Date in format "YYYYMMDD" |
» data1m | string | Stringified array of candle data by minutes [timestamp, open, high, low, close, volume] |
» data1h | string | Stringified array of candle data by hours [timestamp, open, high, low, close, volume] |
» data1d | string | Stringified array of candle data by days [timestamp, open, high, low, close, volume] |
Orderbook
Code samples
const headers = {
'Accept':'*/*'
};
fetch('https://cex.io/api/order_book/{symbol1}/{symbol2}/',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': '*/*'
}
r = requests.get('https://cex.io/api/order_book/{symbol1}/{symbol2}/', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakeGetRequest()
{
string url = "https://cex.io/api/order_book/{symbol1}/{symbol2}/";
var result = await GetAsync(url);
}
/// Performs a GET Request
public async Task GetAsync(string url)
{
//Start the request
HttpResponseMessage response = await Client.GetAsync(url);
//Validate result
response.EnsureSuccessStatusCode();
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/order_book/{symbol1}/{symbol2}/");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
GET /order_book/{symbol1}/{symbol2}/
Get top of the current order book
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
depth | query | number | false | !OPTIONAL! limit the number of bid/ask records returned (optional parameter, all existing elements are returned if omitted) |
Example responses
200 Response
OK
{
"timestamp": 1513173506,
"timestamp_ms": 1513173506123,
"bids": [
[
17670.3,
0.00250037
]
],
"asks": [
[
17689.66,
0.01
]
],
"pair": "BTC:USD",
"id": 158217212,
"sell_total": "1299.73578729",
"buy_total": "10006393.37"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Status Code 200
Name | Type | Description |
---|---|---|
» timestamp | number | UNIX timestamp |
» timestamp_ms | number | timestamp in milliseconds |
» bids | [number] | lists of open orders, each order is represented as a list of [price, amount]. |
» asks | [number] | lists of open orders, each order is represented as a list of [price, amount]. |
» pair | string | Pair name ${symbol1}:${symbol2} |
» id | number | Incremental version id of order-book snapshot, may be used to check if order-book changed |
» sell_total | string | Total available in symbol1 (e.g. BTC ) |
» buy_total | string | Total available in symbol2 (e.g. USD ) |
Trade history
Code samples
const headers = {
'Accept':'*/*'
};
fetch('https://cex.io/api/trade_history/{symbol1}/{symbol2}/',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': '*/*'
}
r = requests.get('https://cex.io/api/trade_history/{symbol1}/{symbol2}/', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakeGetRequest()
{
string url = "https://cex.io/api/trade_history/{symbol1}/{symbol2}/";
var result = await GetAsync(url);
}
/// Performs a GET Request
public async Task GetAsync(string url)
{
//Start the request
HttpResponseMessage response = await Client.GetAsync(url);
//Validate result
response.EnsureSuccessStatusCode();
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/trade_history/{symbol1}/{symbol2}/");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
GET /trade_history/{symbol1}/{symbol2}/
Get trade history data
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
since | query | number | false | This is optional parameter. Response contains trades with tid >= since , and response contains not more then 1000 elements. |
Example responses
200 Response
OK
[
{
"type": "buy",
"date": "1513174106",
"amount": "0.05634990",
"price": "17698.7",
"tid": "4765364"
},
{
"type": "buy",
"date": "1513174106",
"amount": "0.02587643",
"price": "17695",
"tid": "4765363"
},
{
"type": "sell",
"date": "1513174102",
"amount": "0.03112472",
"price": "17695",
"tid": "4765362"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Status Code 200
Name | Type | Description |
---|---|---|
» type | OrderType | Type of order transaction (buy or sell only) |
» date | string | UNIX timestamp |
» amount | string | trade amount |
» price | string | price |
» tid | string | trade id |
Enumerated Values Examples
Property | Value |
---|---|
type | buy |
type | sell |
Currency profile
Code samples
const headers = {
'Accept':'application/json'
};
fetch('https://cex.io/api/currency_profile',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': 'application/json'
}
r = requests.get('https://cex.io/api/currency_profile', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakeGetRequest()
{
string url = "https://cex.io/api/currency_profile";
await GetAsync(null, url);
}
/// Performs a GET Request
public async Task GetAsync(undefined content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute GET request
HttpResponseMessage response = await Client.GetAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(undefined content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/currency_profile");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
GET /currency_profile
Returns available symbols and pairs in the system
Example responses
success
{
"e": "currency_profile",
"ok": "ok",
"data": {
"symbols": [
{
"code": "GHS",
"contract": true,
"commodity": true,
"fiat": false,
"description": "CEX.IO doesn't provide cloud mining services anymore.",
"precision": 8,
"scale": 0,
"minimumCurrencyAmount": "0.00000001",
"minimalWithdrawalAmount": -1
}
],
"pairs": [
{
"symbol1": "BTC",
"symbol2": "USD",
"pricePrecision": 1,
"priceScale": "/1000000",
"minLotSize": 0.00014213,
"minLotSizeS2": 20,
"newLabelEndDate": 1613735901213,
"tags": [
"major"
]
}
]
}
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | success | None |
Private API calls
Private API calls requires API key. Each private call should contain API key, signature and nonce in request body
Account balance
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/balance/',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/balance/', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/balance/";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715""
}";
EmptyPrivateRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(EmptyPrivateRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(EmptyPrivateRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/balance/");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /balance/
Obtain actual user's balance for all currencies
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | EmptyPrivateRequest | false | none |
Example responses
200 Response
OK
{
"timestamp": "1513177918",
"username": "ud000000000",
"BTC": {
"available": "1.38000000",
"orders": "0.00000000"
},
"BCH": {
"available": "1.00000000",
"orders": "0.00000000"
},
"ETH": {
"available": "100.00000000",
"orders": "0.00000000"
},
"DASH": {
"available": "1.00000000",
"orders": "0.00000000"
},
"ZEC": {
"available": "1.00000000",
"orders": "0.00000000"
},
"USD": {
"available": "998087.07",
"orders": "0.00"
},
"EUR": {
"available": "999562.56",
"orders": "0.00"
},
"GBP": {
"available": "1000000.00",
"orders": "0.00"
},
"LTC": {
"available": "1000000.00",
"orders": "0.00"
},
"GHS": {
"available": "0.00000000",
"orders": "0.00000000"
}
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Status Code 200
Name | Type | Description |
---|---|---|
» timestamp | string | UNIX timestamp |
» username | string | User ID |
» BTC | Balance | none |
»» available | string | available balance |
»» orders | string | balance in pending orders |
» BCH | Balance | none |
» ETH | Balance | none |
» LTC | Balance | none |
» DASH | Balance | none |
» ZEC | Balance | none |
» USD | Balance | none |
» EUR | Balance | none |
» GBP | Balance | none |
» GHS | Balance | none |
Open orders
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/open_orders/',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/open_orders/', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/open_orders/";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715""
}";
EmptyPrivateRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(EmptyPrivateRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(EmptyPrivateRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/open_orders/");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /open_orders/
Obtain actual user's opened orders
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | EmptyPrivateRequest | false | none |
Example responses
200 Response
OK
[
{
"id": "13837040",
"time": "1460020144872",
"type": "sell",
"price": "411.626",
"amount": "1.00000000",
"pending": "1.00000000",
"symbol1": "BTC",
"symbol2": "EUR"
},
{
"id": "16452929",
"time": "1462355019816",
"type": "buy",
"price": "400",
"amount": "1.00000000",
"pending": "1.00000000",
"symbol1": "BTC",
"symbol2": "USD"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Status Code 200
Name | Type | Description |
---|---|---|
» id | ShortOrder/properties/id | order id |
» time | string | timestamp |
» type | OrderType | Type of order transaction (buy or sell only) |
» price | string | price |
» amount | string | amount |
» pending | string | pending amount (if partially executed) |
» symbol1 | Symbol | Currency code |
» symbol2 | Symbol | Currency code |
» symbol1Amount | string | !OPTIONAL! amount (if market order) |
» symbol2Amount | string | !OPTIONAL! amount (if market order) |
Enumerated Values Examples
Property | Value |
---|---|
type | buy |
type | sell |
symbol1 | BTC, ETH, BCH, BTG, DASH |
symbol2 | BTC, ETH, BCH, BTG, DASH |
Open orders by pair
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/open_orders/{symbol1}/{symbol2}',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/open_orders/{symbol1}/{symbol2}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/open_orders/{symbol1}/{symbol2}";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715""
}";
EmptyPrivateRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(EmptyPrivateRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(EmptyPrivateRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/open_orders/{symbol1}/{symbol2}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /open_orders/{symbol1}/{symbol2}
Obtain actual user's opened orders for selected pair
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
body | body | EmptyPrivateRequest | false | none |
Example responses
200 Response
OK
[
{
"id": "13837040",
"time": "1460020144872",
"type": "sell",
"price": "411.626",
"amount": "1.00000000",
"pending": "1.00000000",
"symbol1": "BTC",
"symbol2": "EUR"
},
{
"id": "16452929",
"time": "1462355019816",
"type": "buy",
"price": "400",
"amount": "1.00000000",
"pending": "1.00000000",
"symbol1": "BTC",
"symbol2": "USD"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Status Code 200
Name | Type | Description |
---|---|---|
» id | ShortOrder/properties/id | order id |
» time | string | timestamp |
» type | OrderType | Type of order transaction (buy or sell only) |
» price | string | price |
» amount | string | amount |
» pending | string | pending amount (if partially executed) |
» symbol1 | Symbol | Currency code |
» symbol2 | Symbol | Currency code |
» symbol1Amount | string | !OPTIONAL! amount (if market order) |
» symbol2Amount | string | !OPTIONAL! amount (if market order) |
Enumerated Values Examples
Property | Value |
---|---|
type | buy |
type | sell |
symbol1 | BTC, ETH, BCH, BTG, DASH |
symbol2 | BTC, ETH, BCH, BTG, DASH |
Open orders by symbol
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/open_orders/{symbol1}',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/open_orders/{symbol1}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/open_orders/{symbol1}";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715""
}";
EmptyPrivateRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(EmptyPrivateRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(EmptyPrivateRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/open_orders/{symbol1}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /open_orders/{symbol1}
Obtain actual user's opened orders for selected symbol
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
body | body | EmptyPrivateRequest | false | none |
Example responses
200 Response
OK
[
{
"id": "13837040",
"time": "1460020144872",
"type": "sell",
"price": "411.626",
"amount": "1.00000000",
"pending": "1.00000000",
"symbol1": "BTC",
"symbol2": "EUR"
},
{
"id": "16452929",
"time": "1462355019816",
"type": "buy",
"price": "400",
"amount": "1.00000000",
"pending": "1.00000000",
"symbol1": "BTC",
"symbol2": "USD"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Status Code 200
Name | Type | Description |
---|---|---|
» id | ShortOrder/properties/id | order id |
» time | string | timestamp |
» type | OrderType | Type of order transaction (buy or sell only) |
» price | string | price |
» amount | string | amount |
» pending | string | pending amount (if partially executed) |
» symbol1 | Symbol | Currency code |
» symbol2 | Symbol | Currency code |
» symbol1Amount | string | !OPTIONAL! amount (if market order) |
» symbol2Amount | string | !OPTIONAL! amount (if market order) |
Enumerated Values Examples
Property | Value |
---|---|
type | buy |
type | sell |
symbol1 | BTC, ETH, BCH, BTG, DASH |
symbol2 | BTC, ETH, BCH, BTG, DASH |
Mass cancel place orders
Code samples
const inputBody = '{
"cancel-orders": [
"1987",
"1278"
],
"place-orders": [
{
"pair": [
"BTC",
"USD"
],
"amount": 0.02,
"price": "4200",
"order_type": "limit",
"type": "buy"
}
],
"cancelPlacedOrdersIfPlaceFailed": false
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json'
};
fetch('https://cex.io/api/mass_cancel_place_orders',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
r = requests.post('https://cex.io/api/mass_cancel_place_orders', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/mass_cancel_place_orders";
await PostAsync(null, url);
}
/// Performs a POST Request
public async Task PostAsync(undefined content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(undefined content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/mass_cancel_place_orders");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /mass_cancel_place_orders
Allows to cancel and place up to 50 limit orders. Only order_type=='limit' is supported
Body parameter
{
"cancel-orders": [
"1987",
"1278"
],
"place-orders": [
{
"pair": [
"BTC",
"USD"
],
"amount": 0.02,
"price": "4200",
"order_type": "limit",
"type": "buy"
}
],
"cancelPlacedOrdersIfPlaceFailed": false
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | object | false | none |
» cancel-orders | body | [any] | false | array of order IDs(string), max length 50 |
» place-orders | body | [any] | false | array of orders objects, max length 50 |
» cancelPlacedOrdersIfPlaceFailed | body | boolean | false | OPTIONAL, default = true |
Example responses
success
{
"e": "mass_cancel_place_orders",
"ok": "ok",
"data": {
"cancel-orders": [
"1987",
"1278"
],
"place-orders": [
{
"pair": [
"BTC",
"USD"
],
"amount": 0.02,
"price": "4200",
"order_type": "limit",
"type": "buy"
}
],
"placed-cancelled": [
{
"order_id": "136055974",
"fremains": "11.00000000"
}
]
}
}
order was not found
{
"e": "mass_cancel_place_orders",
"ok": "ok",
"data": {
"cancel-orders": [
{
"error": "Order not found"
}
],
"place-orders": [],
"placed-cancelled": []
}
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | success | None |
500 | Internal Server Error | order was not found | None |
Active order status
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"orders_list": [
"8550492",
"8550495",
"8550497"
]
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/active_orders_status',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/active_orders_status', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/active_orders_status";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715"",
""orders_list"": [
""8550492"",
""8550495"",
""8550497""
]
}";
ActiveOrdersRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(ActiveOrdersRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(ActiveOrdersRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/active_orders_status");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /active_orders_status
Obtain actual user's active order
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"orders_list": [
"8550492",
"8550495",
"8550497"
]
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | ActiveOrdersRequest | false | none |
Example responses
200 Response
OK
{
"e": "active_orders_status",
"ok": "ok",
"data": [
[
"8550408",
"0",
"0"
],
[
"8550495",
"0.02000000",
"0.02000000"
],
[
"8550497",
"0.04000000",
"0.02700000"
]
]
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Archived orders
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"limit": 10,
"dateTo": 1506943193,
"dateFrom": 1506943193,
"lastTxDateTo": 1506943193,
"lastTxDateFrom": 1506943193,
"status": "c"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/archived_orders/{symbol1}/{symbol2}',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/archived_orders/{symbol1}/{symbol2}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/archived_orders/{symbol1}/{symbol2}";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715"",
""limit"": 10,
""dateTo"": 1506943193,
""dateFrom"": 1506943193,
""lastTxDateTo"": 1506943193,
""lastTxDateFrom"": 1506943193,
""status"": ""c""
}";
ArchivedOrdersRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(ArchivedOrdersRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(ArchivedOrdersRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/archived_orders/{symbol1}/{symbol2}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /archived_orders/{symbol1}/{symbol2}
Obtain archived user's orders for selected pair
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"limit": 10,
"dateTo": 1506943193,
"dateFrom": 1506943193,
"lastTxDateTo": 1506943193,
"lastTxDateFrom": 1506943193,
"status": "c"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
body | body | ArchivedOrdersRequest | false | none |
Example responses
200 Response
OK
[
{
"id": "22348164",
"type": "buy",
"time": "2016-08-04T09:28:24.669Z",
"lastTxTime": "2016-08-04T09:28:58.762Z",
"lastTx": "22348407",
"status": "d",
"symbol1": "BTC",
"symbol2": "USD",
"amount": "1.00000000",
"price": "564",
"fa:USD": "0.00",
"ta:USD": "563.98",
"remains": "0.00000000",
"a:BTC:cds": "1.00000000",
"a:USD:cds": "565.13",
"f:USD:cds": "0.00",
"tradingFeeMaker": "0",
"tradingFeeTaker": "0.2",
"orderId": "22348164"
},
{
"id": "22347874",
"type": "buy",
"time": "2016-08-04T09:27:40.316Z",
"lastTxTime": "2016-08-04T09:27:47.527Z",
"lastTx": "22347950",
"status": "cd",
"symbol1": "BTC",
"symbol2": "USD",
"amount": "1.00000000",
"price": "564",
"fa:USD": "0.00",
"ta:USD": "359.72",
"remains": "0.36219371",
"a:BTC:cds": "0.63780629",
"a:USD:cds": "565.13",
"f:USD:cds": "0.00",
"tradingFeeMaker": "0",
"tradingFeeTaker": "0.2",
"orderId": "22347874"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Enumerated Values Examples
Property | Value |
---|---|
type | buy |
type | sell |
symbol1 | BTC, ETH, BCH, BTG, DASH |
symbol2 | BTC, ETH, BCH, BTG, DASH |
Cancel order
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"id": 1234
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/cancel_order/',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/cancel_order/', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/cancel_order/";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715"",
""id"": 1234
}";
OrderRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(OrderRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(OrderRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/cancel_order/");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /cancel_order/
Cancel order by provided id
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"id": 1234
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | OrderRequest | false | none |
Example responses
200 Response
OK
true
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | boolean |
Cancel all orders for given pair
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/cancel_orders/{symbol1}/{symbol2}',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/cancel_orders/{symbol1}/{symbol2}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/cancel_orders/{symbol1}/{symbol2}";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715""
}";
EmptyPrivateRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(EmptyPrivateRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(EmptyPrivateRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/cancel_orders/{symbol1}/{symbol2}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /cancel_orders/{symbol1}/{symbol2}
Cancel user's opened orders for selected pair
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
body | body | EmptyPrivateRequest | false | none |
Example responses
200 Response
OK
{
"e": "cancel_orders",
"ok": "ok",
"data": [
"2407314",
"2407317",
"2407320",
"2407323"
]
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Place order
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"order_type": "market",
"type": "buy",
"amount": 0.2,
"price": 1155.6
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/place_order/{symbol1}/{symbol2}',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/place_order/{symbol1}/{symbol2}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/place_order/{symbol1}/{symbol2}";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715"",
""order_type"": ""market"",
""type"": ""buy"",
""amount"": 0.2,
""price"": 1155.6
}";
PlaceOrderRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(PlaceOrderRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(PlaceOrderRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/place_order/{symbol1}/{symbol2}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /place_order/{symbol1}/{symbol2}
place a new order on selected pair
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"order_type": "market",
"type": "buy",
"amount": 0.2,
"price": 1155.6,
"maker_only": false
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
body | body | PlaceOrderRequest | false | none |
Example responses
200 Response
OK
{
"complete": false,
"id": "89067468",
"time": 1512054972480,
"pending": "12.00000000",
"amount": "12.00000000",
"type": "buy",
"price": "1155.67"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Enumerated Values Examples
Property | Value |
---|---|
type | buy |
type | sell |
symbol1 | BTC, ETH, BCH, BTG, DASH |
symbol2 | BTC, ETH, BCH, BTG, DASH |
Get order details
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"id": 1234
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/get_order/',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/get_order/', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/get_order/";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715"",
""id"": 1234
}";
OrderRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(OrderRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(OrderRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/get_order/");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /get_order/
Get full information about order.
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"id": 1234
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | OrderRequest | false | none |
Example responses
200 Response
OK
{
"id": "22347874",
"type": "buy",
"time": 1470302860316,
"lastTxTime": "2016-08-04T09:27:47.527Z",
"lastTx": "22347950",
"pos": null,
"user": "up12345678",
"status": "cd",
"symbol1": "BTC",
"symbol2": "USD",
"amount": "1.00000000",
"price": "564",
"fa:USD": "0.00",
"ta:USD": "359.72",
"remains": "0.36219371",
"a:BTC:cds": "0.63780629",
"a:USD:cds": "565.13",
"f:USD:cds": "0.00",
"tradingFeeMaker": "0",
"tradingFeeTaker": "0.2",
"tradingFeeStrategy": "Promo000Maker",
"orderId": "22347874"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Enumerated Values Examples
Property | Value |
---|---|
type | buy |
type | sell |
symbol1 | BTC, ETH, BCH, BTG, DASH |
symbol2 | BTC, ETH, BCH, BTG, DASH |
Get order transactions
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"id": 1234
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/get_order_tx/',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/get_order_tx/', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/get_order_tx/";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715"",
""id"": 1234
}";
OrderRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(OrderRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(OrderRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/get_order_tx/");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /get_order_tx/
Get information about all order transactions.
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"id": 1234
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | OrderRequest | false | none |
Example responses
200 Response
OK
{
"e": "get_order_tx",
"ok": "ok",
"data": {
"id": "22347874",
"type": "buy",
"time": 1470302860316,
"lastTxTime": "2016-08-04T09:27:47.527Z",
"lastTx": "22347950",
"user": "up12345678",
"status": "cd",
"symbol1": "BTC",
"symbol2": "USD",
"amount": "1.00000000",
"price": "564",
"fa:USD": "0.00",
"ta:USD": "359.72",
"remains": "0.36219371",
"a:BTC:cds": "0.63780629",
"a:USD:cds": "565.13",
"f:USD:cds": "0.00",
"tradingFeeMaker": "0",
"tradingFeeTaker": "0.2",
"tradingFeeStrategy": "Promo000Maker",
"orderId": "22347874",
"vtx": [
{
"id": "22347950",
"type": "cancel",
"time": "2016-08-04T09:27:47.527Z",
"user": "up12345678",
"c": "user:userId:a:USD",
"d": "order:22347874:a:USD",
"a": "204.28000000",
"amount": "204.28000000",
"balance": "1391212.24000000",
"symbol": "USD",
"order": "22347874",
"buy": null,
"sell": null,
"pair": null,
"pos": null,
"cs": "1391212.24",
"ds": 0
},
{
"id": "22347949",
"type": "buy",
"time": "2016-08-04T09:27:40.972Z",
"user": "up12345678",
"c": "user:userId:a:BTC",
"d": "order:22347874:a:BTC",
"a": "0.63780629",
"amount": "0.63780629",
"balance": "7633.93075975",
"symbol": "BTC",
"order": "22347874",
"buy": "22347874",
"sell": "22347877",
"pair": null,
"pos": null,
"cs": "7633.93075975",
"ds": 0,
"price": 564,
"symbol2": "USD",
"fee_amount": 0
},
{
"id": "22347876",
"type": "buy",
"time": "2016-08-04T09:27:40.316Z",
"user": "up12345678",
"c": "user:userId:a:USD",
"d": "order:22347874:a:USD",
"a": "1.13000000",
"amount": "-564.00000000",
"balance": "1391007.96000000",
"symbol": "USD",
"order": "22347874",
"buy": null,
"sell": null,
"pair": null,
"pos": null,
"cs": "1391007.96",
"ds": "564.00"
}
],
"next": false,
"prev": false
}
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Enumerated Values Examples
Property | Value | Description |
---|---|---|
type | buy | |
type | sell | |
status | d | done |
status | c | canceled |
status | cd | partially executed |
symbol1 | BTC, ETH, BCH, BTG, DASH | |
symbol2 | BTC, ETH, BCH, BTG, DASH |
Get crypto address
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"currency": "BTC"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/get_address/',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/get_address/', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/get_address/";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715"",
""currency"": ""BTC""
}";
AddressRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(AddressRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(AddressRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/get_address/");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /get_address/
Get crypto address
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"currency": "BTC"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | AddressRequest | false | none |
Example responses
200 Response
OK
{
"ok": "ok",
"e": "get_address",
"data": "3JjMEw3b2wcRuUQL7rA5JMzKXwEgiArSrb"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Get all crypto addresses
Code samples
const inputBody = '{
"currency": "BTC"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json'
};
fetch('https://cex.io/api/get_crypto_address',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
r = requests.post('https://cex.io/api/get_crypto_address', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/get_crypto_address";
await PostAsync(null, url);
}
/// Performs a POST Request
public async Task PostAsync(undefined content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(undefined content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/get_crypto_address");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /get_crypto_address
Get user's crypto addresses with blockchains for given currency
Body parameter
{
"currency": "BTC"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | object | false | none |
» currency | body | string | false | currency |
Example responses
success
{
"e": "get_crypto_address",
"ok": "ok",
"data": {
"name": "BTC",
"addresses": [
{
"blockchain": "BTC",
"address": "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh"
}
]
}
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | success | None |
Get my fee
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/get_myfee/',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/get_myfee/', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/get_myfee/";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715""
}";
EmptyPrivateRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(EmptyPrivateRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(EmptyPrivateRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/get_myfee/");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /get_myfee/
Get account fees for available pairs
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | EmptyPrivateRequest | false | none |
Example responses
200 Response
OK
{
"ok": "ok",
"e": "get_myfee",
"data": {
"ETH:USD": {
"sell": "0.15",
"buyMaker": "0",
"buy": "0.15",
"sellMaker": "0"
},
"BCH:GBP": {
"sell": "0.15",
"buyMaker": "0",
"buy": "0.15",
"sellMaker": "0"
},
"ZEC:BTC": {
"sell": "0.15",
"buyMaker": "0",
"buy": "0.15",
"sellMaker": "0"
},
"ZEC:GBP": {
"sell": "0.15",
"buyMaker": "0",
"buy": "0.15",
"sellMaker": "0"
}
}
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Status Code 200
Name | Type | Description |
---|---|---|
» e | string | event name |
» ok | string | status of request |
» data | object | Map of fees |
»» {Symbol1}:{Symbol2} | Fee | Fee description |
»»» buy | string | percents of fee |
»»» buyMaker | string | percents of fee |
»»» sell | string | percents of fee |
»»» sellMaker | string | percents of fee |
Cancel replace order
Code samples
const inputBody = '{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"type": "buy",
"amount": 1000,
"price": 24.15,
"order_id": "22348164"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'*/*'
};
fetch('https://cex.io/api/cancel_replace_order/{symbol1}/{symbol2}',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Content-Type': 'application/json',
'Accept': '*/*'
}
r = requests.post('https://cex.io/api/cancel_replace_order/{symbol1}/{symbol2}', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/cancel_replace_order/{symbol1}/{symbol2}";
string json = @"{
""key"": ""HLixH1aYdOIWOoRyoHkFpHlawrM"",
""signature"": ""0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"",
""nonce"": ""1513175715"",
""type"": ""buy"",
""amount"": 1000,
""price"": 24.15,
""order_id"": """22348164"""
}";
CancelReplaceOrderRequest content = JsonConvert.DeserializeObject(json);
await PostAsync(content, url);
}
/// Performs a POST Request
public async Task PostAsync(CancelReplaceOrderRequest content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(CancelReplaceOrderRequest content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/cancel_replace_order/{symbol1}/{symbol2}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /cancel_replace_order/{symbol1}/{symbol2}
Replace an order on selected pair
Body parameter
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"type": "buy",
"amount": 1000,
"price": 24.15,
"order_id": "22348164"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
symbol1 | path | string | true | The first currency code (BTC, ETH, BCH...) |
symbol2 | path | string | true | The second currency code (BTC, ETH, BCH...) |
body | body | CancelReplaceOrderRequest | false | none |
Example responses
200 Response
OK
{
"complete": false,
"price": "150",
"amount": "0.02000000",
"time": 1506952374430,
"type": "buy",
"id": "88646680",
"pending": "0.02000000"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | Inline |
Response Schema
Enumerated Values Examples
Property | Value |
---|---|
type | buy |
type | sell |
Currency profile
Code samples
const headers = {
'Accept':'application/json'
};
fetch('https://cex.io/api/currency_profile',
{
method: 'POST',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
import requests
headers = {
'Accept': 'application/json'
}
r = requests.post('https://cex.io/api/currency_profile', headers = headers)
print(r.json())
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
/// <<summary>>
/// Example of Http Client
/// <</summary>>
public class HttpExample
{
private HttpClient Client { get; set; }
/// <<summary>>
/// Setup http client
/// <</summary>>
public HttpExample()
{
Client = new HttpClient();
}
/// Make a dummy request
public async Task MakePostRequest()
{
string url = "https://cex.io/api/currency_profile";
await PostAsync(null, url);
}
/// Performs a POST Request
public async Task PostAsync(undefined content, string url)
{
//Serialize Object
StringContent jsonContent = SerializeObject(content);
//Execute POST request
HttpResponseMessage response = await Client.PostAsync(url, jsonContent);
}
/// Serialize an object to Json
private StringContent SerializeObject(undefined content)
{
//Serialize Object
string jsonObject = JsonConvert.SerializeObject(content);
//Create Json UTF8 String Content
return new StringContent(jsonObject, Encoding.UTF8, "application/json");
}
/// Deserialize object from request response
private async Task DeserializeObject(HttpResponseMessage response)
{
//Read body
string responseBody = await response.Content.ReadAsStringAsync();
//Deserialize Body to object
var result = JsonConvert.DeserializeObject(responseBody);
}
}
URL obj = new URL("https://cex.io/api/currency_profile");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
POST /currency_profile
Returns available symbols and pairs for user according to his/her trading group
Example responses
success
{
"e": "currency_profile",
"ok": "ok",
"data": {
"symbols": [
{
"code": "GHS",
"contract": true,
"commodity": true,
"fiat": false,
"description": "CEX.IO doesn't provide cloud mining services anymore.",
"precision": 8,
"scale": 0,
"minimumCurrencyAmount": "0.00000001",
"minimalWithdrawalAmount": -1
}
],
"pairs": [
{
"symbol1": "BTC",
"symbol2": "USD",
"pricePrecision": 1,
"priceScale": "/1000000",
"minLotSize": 0.00014213,
"minLotSizeS2": 20,
"newLabelEndDate": 1613735901213,
"tags": [
"major"
]
}
]
}
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | success | None |
Definitions
PriceStatsRequest
{
"lastHours": 24,
"maxRespArrSize": 100
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
lastHours | number | false | none | period till the current date in hours |
maxRespArrSize | number | false | none | maximal array size in response |
ConvertRequest
{
"amnt": "2.5"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
amnt | string | false | none | convertible amount. should be a positive number string. |
CurrencyLimit
{
"symbol1": "BTC",
"symbol2": "BTC",
"minLotSize": 0.002,
"minLotSizeS2": 20,
"maxLotSize": 30,
"minPrice": "1500",
"maxPrice": "35000"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
symbol1 | Symbol | false | none | Currency code |
symbol2 | Symbol | false | none | Currency code |
minLotSize | number | false | none | minimal order amount in first currency |
minLotSizeS2 | number | false | none | minimal order amount in second currency |
maxLotSize | number | false | none | maximal order amount in first currency (can be null if order didn't have maximal amount size) |
minPrice | string | false | none | minimal order price |
maxPrice | string | false | none | maximal order price |
Fee
{
"buy": "0.15",
"buyMaker": "0",
"sell": "0.15",
"sellMaker": "0"
}
Fee description
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
buy | string | false | none | percents of fee |
buyMaker | string | false | none | percents of fee |
sell | string | false | none | percents of fee |
sellMaker | string | false | none | percents of fee |
OrderStatus
"c"
Order status (d = done, c = canceled, cd = partially executed)
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
status | string | false | none | Order status (d = done, c = canceled, cd = partially executed) |
Enumerated Values Examples
Property | Value | Description |
---|---|---|
status | d | done |
status | c | canceled |
status | cd | partially executed |
ResponseStatus
"ok"
Response status
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
status | string | false | none | Response status |
Enumerated Values Examples
Property | Value |
---|---|
status | ok |
status | error |
OrderType
"buy"
Type of order transaction (buy
or sell
only)
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
type | string | false | none | Type of order transaction (buy or sell only) |
Enumerated Values Examples
Property | Value |
---|---|
type | buy |
type | sell |
ShortOrder
{
"id": "22348164",
"time": "1460020144872",
"type": "buy",
"price": "564",
"amount": "1.00000000",
"pending": "0.50000000",
"symbol1": "BTC",
"symbol2": "BTC",
"symbol1Amount": "1.00000000",
"symbol2Amount": "1.00000000"
}
Order object (some fields omitted)
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | string | false | none | order id |
time | string | false | none | timestamp |
type | OrderType | false | none | Type of order transaction (buy or sell only) |
price | string | false | none | price |
amount | string | false | none | amount |
pending | string | false | none | pending amount (if partially executed) |
symbol1 | Symbol | false | none | Currency code |
symbol2 | Symbol | false | none | Currency code |
symbol1Amount | string | false | none | !OPTIONAL! amount (if market order) |
symbol2Amount | string | false | none | !OPTIONAL! amount (if market order) |
FullOrder
{
"id": "22348164",
"time": "1460020144872",
"type": "buy",
"price": "564",
"amount": "1.00000000",
"pending": "0.50000000",
"symbol1": "BTC",
"symbol2": "BTC",
"symbol1Amount": "1.00000000",
"symbol2Amount": "1.00000000",
"lastTx": "12345678",
"lastTxTime": "2016-08-04T09:28:24.669Z",
"tradingFeeUserVolumeAmount": "1223.00",
"ta:{symbol2}": "1223.00",
"tta:{symbol2}": "1223.00",
"fa:{symbol2}": "1223.00",
"tfa:{symbol2}": "1223.00",
"a:{symbol1}:cds": "1223.00",
"tradingFeeMaker": "0.0",
"tradingFeeTaker": "0.2",
"tradingFeeStrategy": "Promo000Maker",
"remains": "0.232111",
"orderId": "12232344",
"pos": "null"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | string | false | none | order id |
time | string | false | none | timestamp |
type | OrderType | false | none | Type of order transaction (buy or sell only) |
price | string | false | none | price |
amount | string | false | none | amount |
pending | string | false | none | pending amount (if partially executed) |
symbol1 | Symbol | false | none | Currency code |
symbol2 | Symbol | false | none | Currency code |
symbol1Amount | string | false | none | !OPTIONAL! amount (if market order) |
symbol2Amount | string | false | none | !OPTIONAL! amount (if market order) |
lastTxTime | string | false | none | Time of last transaction (last order) in unix time OR in ISO format |
lastTx | string | false | none | Last transaction id (last order number) |
tradingFeeUserVolumeAmount | string | false | none | none |
ta:{symbol2} | string | false | none | total amount in current currency (Maker) |
tta:{symbol2} | string | false | none | total amount in current currency (Taker) |
fa:{symbol2} | string | false | none | fee amount in current currency (Maker) |
tfa:{symbol2} | string | false | none | fee amount in current currency (Taker) |
a:{symbol1}:cds | string | false | none | credit, debit and saldo merged amount in current currency |
tradingFeeMaker | string | false | none | fee % value of Maker transactions |
tradingFeeTaker | string | false | none | fee % value of Taker transactions |
tradingFeeStrategy | string | false | none | name of trading fee strategy |
remains | string | false | none | amount ramains |
orderId | string | false | none | order number into system |
pos | string | false | none | none |
OrderWithTransactions
{
"data": {
"id": "22348164",
"time": "2016-08-04T09:28:24.669Z",
"type": "buy",
"lastTx": "22347950",
"lastTxTime": "2016-08-04T09:28:24.669Z",
"user": "11111111",
"status": "c",
"symbol1": "BTC",
"symbol2": "BTC",
"amount": "1.00000000",
"price": "564",
"pending": "0.50000000",
"symbol1Amount": "1.00000000",
"symbol2Amount": "1.00000000",
"tradingFeeUserVolumeAmount": "1223.00",
"ta:{symbol2}": "1223.00",
"tta:{symbol2}": "1223.00",
"fa:{symbol2}": "1223.00",
"tfa:{symbol2}": "1223.00",
"a:{symbol1}:cds": "1223.00",
"tradingFeeMaker": "0.0",
"tradingFeeTaker": "0.2",
"tradingFeeStrategy": "Promo000Maker",
"remains": "0.232111",
"orderId": "12232344",
"pos": "null",
"prev": false,
"next": false,
"vtx": [
{
"id": "22348164",
"time": "2016-08-04T09:28:24.669Z",
"type": "buy",
"user": "11111111",
"c": "user:11111111:a:USD",
"d": "order:22347874:a:USD",
"a": "204.28000000",
"balance": "1391212.24000000",
"amount": "1.00000000",
"pending": "0.50000000",
"symbol": "BTC",
"symbol2": "BTC",
"order": "22347874",
"buy": "22347874",
"sell": "22347877",
"pair": "null",
"pos": "null",
"cs": "10.121221",
"ds": "0",
"fee_amount": "0"
}
]
}
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
data | object | false | none | none |
» id | string | false | none | order id |
» time | string | false | none | timestamp |
» type | OrderType | false | none | Type of order transaction (buy or sell only) |
» lastTx | string | false | none | number of last transction |
» lastTxTime | string | false | none | tiome of last transaction (unix time OR in ISO format) |
» user | string | false | none | user ID into system |
» status | OrderStatus | false | none | Order status (d = done, c = canceled, cd = partially executed) |
» symbol1 | Symbol | false | none | Currency code |
» symbol2 | Symbol | false | none | Currency code |
» amount | string | false | none | amount |
» price | string | false | none | price |
» pending | string | false | none | pending amount (if partially executed) |
» symbol1Amount | string | false | none | !OPTIONAL! amount (if market order) |
» symbol2Amount | string | false | none | !OPTIONAL! amount (if market order) |
» tradingFeeUserVolumeAmount | string | false | none | none |
» ta:{symbol2} | string | false | none | total amount in current currency (Maker) |
» tta:{symbol2} | string | false | none | total amount in current currency (Taker) |
» fa:{symbol2} | string | false | none | fee amount in current currency (Maker) |
» tfa:{symbol2} | string | false | none | fee amount in current currency (Taker) |
» a:{symbol1}:cds | string | false | none | credit, debit and saldo merged amount in current currency |
» tradingFeeMaker | string | false | none | fee % value of Maker transactions |
» tradingFeeTaker | string | false | none | fee % value of Taker transactions |
» tradingFeeStrategy | string | false | none | name of trading fee strategy |
» remains | string | false | none | amount ramains |
» orderId | string | false | none | order number into system |
» pos | string | false | none | none |
» prev | boolean | false | none | none |
» next | boolean | false | none | none |
» vtx | [object] | false | none | none |
»» id | string | false | none | order id |
»» time | string | false | none | timestamp |
»» type | OrderType | false | none | Type of order transaction (buy or sell only) |
»» user | string | false | none | user ID into system |
»» c | string | false | none | credit account into system |
»» d | string | false | none | debit account into system |
»» a | string | false | none | amount |
»» balance | string | false | none | balance |
»» amount | string | false | none | amount |
»» pending | string | false | none | pending amount (if partially executed) |
»» symbol | Symbol | false | none | Currency code |
»» symbol2 | Symbol | false | none | Currency code |
»» order | string | false | none | order number |
»» buy | string | false | none | none |
»» sell | string | false | none | none |
»» pair | string | false | none | none |
»» pos | string | false | none | none |
»» cs | string | false | none | none |
»» ds | number | false | none | none |
»» fee_amount | string | false | none | none |
Transaction
{
"id": "string",
"type": "buy",
"time": "string",
"user": "string",
"c": "string",
"d": "string",
"a": "string",
"amount": "string",
"balance": "string",
"symbol": "BTC",
"symbol1": "BTC",
"symbol2": "BTC",
"order": "22348164",
"buy": "22348164",
"sell": "22348164",
"pair": "string",
"pos": "string",
"cs": "string",
"ds": 0,
"fee_amount": 0,
"price": 0
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | string | false | none | none |
type | OrderType | false | none | Type of order transaction (buy or sell only) |
time | string | false | none | none |
user | string | false | none | User id |
c | string | false | none | none |
d | string | false | none | none |
a | string | false | none | none |
amount | string | false | none | none |
balance | string | false | none | none |
symbol | Symbol | false | none | Currency code |
symbol1 | Symbol | false | none | Currency code |
symbol2 | Symbol | false | none | Currency code |
order | ShortOrder/properties/id | false | none | order id |
buy | ShortOrder/properties/id | false | none | order id |
sell | ShortOrder/properties/id | false | none | order id |
pair | string | false | none | none |
pos | string | false | none | none |
cs | string | false | none | none |
ds | number | false | none | none |
fee_amount | number | false | none | none |
price | number | false | none | none |
Symbol
"BTC"
Currency code
Properties
Name | Type | Description |
---|---|---|
symbol | string | Currency code |
Balance
{
"available": "1.00000000",
"orders": "1.00000000"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
available | string | false | none | available balance |
orders | string | false | none | balance in pending orders |
APIkey
"HLixH1aYdOIWOoRyoHkFpHlawrM"
Your own API key. To get an API key
, go to Account -> API Access Tab. Set permissions and click "Generate key".
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
key | string | false | none | Your own API key. To get an API key , go to Account -> API Access Tab. Set permissions and click "Generate key". |
nonce
"1513175715"
The nonce
is a regular integer number. It must be increasing with every request you make. Read more about it here. Example - if you set nonce to 1 in your first request, you must set it to at least 2 in your second request. You are not required to start with 1. A common practice is to use unix time for that parameter.
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
nonce | string | false | none | The nonce is a regular integer number. It must be increasing with every request you make. Read more about it here. Example - if you set nonce to 1 in your first request, you must set it to at least 2 in your second request. You are not required to start with 1. A common practice is to use unix time for that parameter. |
signature
"0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9"
An HMAC-SHA256 encoded message containing - a nonce, user ID and API key. The HMAC-SHA256
code must be generated using a secret key that was generated with your API key. This code must be converted to its hexadecimal representation (64 uppercase characters).
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
signature | string | false | none | An HMAC-SHA256 encoded message containing - a nonce, user ID and API key. The HMAC-SHA256 code must be generated using a secret key that was generated with your API key. This code must be converted to its hexadecimal representation (64 uppercase characters). |
EmptyPrivateRequest
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
key | APIkey | false | none | Your own API key. To get an API key , go to Account -> API Access Tab. Set permissions and click "Generate key". |
signature | signature | false | none | An HMAC-SHA256 encoded message containing - a nonce, user ID and API key. The HMAC-SHA256 code must be generated using a secret key that was generated with your API key. This code must be converted to its hexadecimal representation (64 uppercase characters). |
nonce | nonce | false | none | The nonce is a regular integer number. It must be increasing with every request you make. Read more about it here. Example - if you set nonce to 1 in your first request, you must set it to at least 2 in your second request. You are not required to start with 1. A common practice is to use unix time for that parameter. |
IDRequest
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"id": 89067468
}
Private request that contains some entity's ID
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
key | APIkey | false | none | Your own API key. To get an API key , go to Account -> API Access Tab. Set permissions and click "Generate key". |
signature | signature | false | none | An HMAC-SHA256 encoded message containing - a nonce, user ID and API key. The HMAC-SHA256 code must be generated using a secret key that was generated with your API key. This code must be converted to its hexadecimal representation (64 uppercase characters). |
nonce | nonce | false | none | The nonce is a regular integer number. It must be increasing with every request you make. Read more about it here. Example - if you set nonce to 1 in your first request, you must set it to at least 2 in your second request. You are not required to start with 1. A common practice is to use unix time for that parameter. |
id | number | false | none | none |
ArchivedOrdersRequest
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"limit": 10,
"dateTo": 1506943193,
"dateFrom": 1506943193,
"lastTxDateTo": 1506943193,
"lastTxDateFrom": 1506943193,
"status": "c"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
key | APIkey | false | none | Your own API key. To get an API key , go to Account -> API Access Tab. Set permissions and click "Generate key". |
signature | signature | false | none | An HMAC-SHA256 encoded message containing - a nonce, user ID and API key. The HMAC-SHA256 code must be generated using a secret key that was generated with your API key. This code must be converted to its hexadecimal representation (64 uppercase characters). |
nonce | nonce | false | none | The nonce is a regular integer number. It must be increasing with every request you make. Read more about it here. Example - if you set nonce to 1 in your first request, you must set it to at least 2 in your second request. You are not required to start with 1. A common practice is to use unix time for that parameter. |
limit | number | false | none | limit the number of entries in response (from 1 to 100) |
dateTo | number | false | none | end date for open orders filtering (unix timestamp in seconds, 10 digits), inclusive |
dateFrom | number | false | none | start date for open order filtering (unix timestamp in seconds, 10 digits), inclusive |
lastTxDateTo | number | false | none | end date for last change orders filtering (unix timestamp in seconds, 10 digits), inclusive |
lastTxDateFrom | number | false | none | start date for last change order filtering (unix timestamp in seconds, 10 digits), inclusive |
status | OrderStatus | false | none | Order status (d = done, c = canceled, cd = partially executed) |
ActiveOrdersRequest
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"orders_list": [
"8550492",
"8550495",
"8550497"
]
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
key | APIkey | false | none | Your own API key. To get an API key , go to Account -> API Access Tab. Set permissions and click "Generate key". |
signature | signature | false | none | An HMAC-SHA256 encoded message containing - a nonce, user ID and API key. The HMAC-SHA256 code must be generated using a secret key that was generated with your API key. This code must be converted to its hexadecimal representation (64 uppercase characters). |
nonce | nonce | false | none | The nonce is a regular integer number. It must be increasing with every request you make. Read more about it here. Example - if you set nonce to 1 in your first request, you must set it to at least 2 in your second request. You are not required to start with 1. A common practice is to use unix time for that parameter. |
orders_list | [string] | false | none | list of order IDs to get status of |
PlaceOrderRequest
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"order_type": "market",
"type": "buy",
"amount": 0.2,
"price": 1155.6,
"maker_only": true
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
key | APIkey | false | none | Your own API key. To get an API key , go to Account -> API Access Tab. Set permissions and click "Generate key". |
signature | signature | false | none | An HMAC-SHA256 encoded message containing - a nonce, user ID and API key. The HMAC-SHA256 code must be generated using a secret key that was generated with your API key. This code must be converted to its hexadecimal representation (64 uppercase characters). |
nonce | nonce | false | none | The nonce is a regular integer number. It must be increasing with every request you make. Read more about it here. Example - if you set nonce to 1 in your first request, you must set it to at least 2 in your second request. You are not required to start with 1. A common practice is to use unix time for that parameter. |
order_type | string | false | none | !OPTIONAL! Order market type (market only available), if you want add limit order this field must be blank |
type | OrderType | false | none | Type of order transaction (buy or sell only) |
amount | number | false | none | Amount in first currency for limit order, and amount in first or second currency if type of order is market order (depends from order type - buy or sell) |
price | string | false | none | !OPTIONAL! price (must be blank if market order) |
maker_only | boolean | false | none | !OPTIONAL! Maker only places an order only if offers best sell (<= max) or buy(>= max) price for this pair, if not order placement will be rejected with an error - "Order is not maker" |
Enumerated Values Examples
Property | Value |
---|---|
order_type | market |
OrderRequest
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"id": 1234
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
key | APIkey | false | none | Your own API key. To get an API key , go to Account -> API Access Tab. Set permissions and click "Generate key". |
signature | signature | false | none | An HMAC-SHA256 encoded message containing - a nonce, user ID and API key. The HMAC-SHA256 code must be generated using a secret key that was generated with your API key. This code must be converted to its hexadecimal representation (64 uppercase characters). |
nonce | nonce | false | none | The nonce is a regular integer number. It must be increasing with every request you make. Read more about it here. Example - if you set nonce to 1 in your first request, you must set it to at least 2 in your second request. You are not required to start with 1. A common practice is to use unix time for that parameter. |
id | number | false | none | Order ID |
AddressRequest
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"currency": "BTC"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
key | APIkey | false | none | Your own API key. To get an API key , go to Account -> API Access Tab. Set permissions and click "Generate key". |
signature | signature | false | none | An HMAC-SHA256 encoded message containing - a nonce, user ID and API key. The HMAC-SHA256 code must be generated using a secret key that was generated with your API key. This code must be converted to its hexadecimal representation (64 uppercase characters). |
nonce | nonce | false | none | The nonce is a regular integer number. It must be increasing with every request you make. Read more about it here. Example - if you set nonce to 1 in your first request, you must set it to at least 2 in your second request. You are not required to start with 1. A common practice is to use unix time for that parameter. |
currency | Symbol | false | none | Currency code |
CancelReplaceOrderRequest
{
"key": "HLixH1aYdOIWOoRyoHkFpHlawrM",
"signature": "0BDEDB9339DCE83D46F09A1527663762B52C8B12BCD1910E685BEAFEEABECFF9",
"nonce": "1513175715",
"type": "buy",
"amount": 1000,
"price": 24.15,
"order_id": "22348164"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
key | APIkey | false | none | Your own API key. To get an API key , go to Account -> API Access Tab. Set permissions and click "Generate key". |
signature | signature | false | none | An HMAC-SHA256 encoded message containing - a nonce, user ID and API key. The HMAC-SHA256 code must be generated using a secret key that was generated with your API key. This code must be converted to its hexadecimal representation (64 uppercase characters). |
nonce | nonce | false | none | The nonce is a regular integer number. It must be increasing with every request you make. Read more about it here. Example - if you set nonce to 1 in your first request, you must set it to at least 2 in your second request. You are not required to start with 1. A common practice is to use unix time for that parameter. |
type | OrderType | false | none | Type of order transaction (buy or sell only) |
amount | number | false | none | amount |
price | number | false | none | price |
order_id | ShortOrder/properties/id | false | none | order id |
PairPrice
{
"curr1": "BTC",
"curr2": "BTC",
"lprice": "12345.6"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
curr1 | Symbol | false | none | Currency code |
curr2 | Symbol | false | none | Currency code |
lprice | string | false | none | last price of selling/buying the first currency relative to the second one. If there are no such executed orders, then lprice will equal to 0 . |
Ticker
{
"timestamp": "12345678",
"low": "1234.12",
"high": "1234.12",
"last": "1234.12",
"volume": "0.10000000",
"volume30d": "1234.00000200",
"bid": 1234.12,
"ask": 1234.12,
"priceChange": "-2058.3",
"priceChangePercentage": "-9.18",
"pair": "BTC:USD"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
timestamp | string | false | none | Response timestamp |
low | string | false | none | Current day lowest price |
high | string | false | none | Current day highest price |
last | string | false | none | Last price |
volume | string | false | none | Last 24 hours volume |
volume30d | string | false | none | Last 30 days volume |
bid | number | false | none | Highest buy order price |
ask | number | false | none | Lowest sell order price |
priceChange | string | false | none | Price change |
priceChangePercentage | string | false | none | Price change percent |
pair | string | false | none | Currency pair of ticker |
Tickers
{
"ok": "ok | error",
"e": "tickers",
"data": [
{
"timestamp": "1663149107",
"pair": "BTC:USD",
"low": "19901",
"high": "22779.2",
"last": "20345.3",
"volume": "137.84582894",
"volume30d": "1669.46423487",
"priceChange": "-2059.0",
"priceChangePercentage": "-9.19",
"bid": 20347.7,
"ask": 20349.4
}
]
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
ok | string | false | none | status of request |
e | string | false | none | name of event |
data | [object] | false | none | none |
» timestamp | string | false | none | Timestamp of answer |
» pair | string | false | none | Currency pair of ticker |
» low | string | false | none | Current day lowest price |
» high | string | false | none | Current day highest price |
» last | string | false | none | Last price |
» volume | string | false | none | Last 24 hours volume |
» volume30d | string | false | none | Last 30 days volume |
» priceChange | string | false | none | Price change |
» priceChangePercentage | string | false | none | Price change percent |
» bid | number | false | none | Highest buy order price |
» ask | number | false | none | Lowest sell order price |
APIResponse
{
"e": "ticker|ohlcv|...",
"ok": "ok|success|error",
"error": "first parameter is wrong, or not specified"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
e | string | false | none | Event type |
ok | string | false | none | Response status |
error | string | false | none | Error message |
PairPrices
{
"symbol1": "BTC",
"symbol2": "BTC",
"lprice": "12345.6"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
symbol1 | Symbol | false | none | Currency code |
symbol2 | Symbol | false | none | Currency code |
lprice | string | false | none | last price of selling/buying the first currency relative to the second one. If there are no such executed orders, then lprice will equal to 0 . |
CancelOrder
{
"id": "22348164",
"time": "2016-08-04T09:28:24.669Z",
"type": "buy",
"price": "564",
"amount": "1.00000000",
"pending": "0.50000000",
"complete": "false"
}
Order object (some fields omitted)
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | string | false | none | order id |
time | string | false | none | timestamp |
type | OrderType | false | none | Type of order transaction (buy or sell only) |
price | string | false | none | price |
amount | string | false | none | amount |
pending | string | false | none | pending amount (if partially executed) |
complete | boolean | false | none | status of operations (completed or not) |
LimitsResponse
{
"e": "ticker|ohlcv|...",
"ok": "ok|success|error",
"error": "first parameter is wrong, or not specified",
"data": {
"pairs": [
{
"symbol1": "BTC",
"symbol2": "BTC",
"minLotSize": 0.002,
"minLotSizeS2": 20,
"maxLotSize": 30,
"minPrice": "1500",
"maxPrice": "35000"
}
]
}
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
e | string | false | none | Event type |
ok | string | false | none | Response status |
error | string | false | none | Error message |
data | object | false | none | Operation result |
» pairs | [CurrencyLimit] | false | none | none |