CHAINEX API
OVERVIEW
ChainEX API offers a simple and more standardized REST API to make full use of our site functionality. The standard API responses are JSON encoded arrays and we support GET, POST and DELETE requests. Please be aware that calls to the API are rate limited to 10 requests per second, any requests exceeding this rate will be met with a HTTP 503 response.
API REFERENCE
MarketWallet- Wallet Balances
- Wallet Deposits
- Wallet Deposit Address
- Wallet New Deposit Address
- Wallet Withdrawals
- Wallet Single Withdrawal
- Wallet Request Withdrawal
- Wallet Cancel Withdrawal
- Trading Orders
- Trading Single Order
- Trading Add Order
- Trading Cancel Order
- Trading Trades
- Trading Single Trade
AUTHENTICATION
All requests to the Wallet and Trading methods require authentication via a public and private API key pair. An authenticated API request must contain the following three items.
| Parameter | Description |
|---|---|
| key | Your public API Key. |
| time | Current unix timestamp (your requesting device MUST keep accurate time). |
| hash | HMAC-SHA-256 hash of the full URL and request data, including the public key and timestamp. |
IMPORTANT: The unix timestamp included in the API calls must be accurate to within 5 seconds, any requests received with a timestamp outside of this window will be rejected to aid in the prevention of replay attacks. You can call the following method https://api.chainex.io/timestamp to get our current server time.
GEThttps://api.chainex.io/wallet/balances/?key=1239[...]55ac8&time=1396560131&hash=b5c45e[...]f5375c
The hash value is a HMAC-SHA-256 hash of the full url e.g. https://api.chainex.io/wallet/balances/?key=1239[...]55ac8&time=1396560131. The same method applies for POST requests.
Response
{
"status":"success",
"count":42,
"data":[{
"code":"LTC",
"name":"Litecoin",
"balance_available":"2.00000000",
"balance_pending_deposit":"0.00000000",
"balance_pending_withdraw":"0.00000000",
"balance_held":"6.50000000"
},
...
]
}API RESPONSE
The response from the API is standard with a status field that shows if the request was successful or not. Based on this, there will be a data field that holds the data as an array if successful, a count field if fetching more than one item and/or a message field that holds the success/error message.
Example successful response:
{
"status":"success",
"count":42,
"data":[{...}]
}Example error response:
{
"status":"error",
"message":"The coin code does not exist."
}MARKET METHODS
All markets methods are public and do not require authentication.
Market Summary
GEThttps://api.chainex.io/market/summary/
Provides an overview of all our markets. Data refreshes every minute.
GEThttps://api.chainex.io/market/summary/{EXCHANGE}
Provides an overview of only BTC or LTC markets. Data refreshes every minute.
Example: https://api.chainex.io/market/summary/BTC
Response
{
"status":"success",
"count":42,
"data":[{
"code":"LTC",
"exchange":"BTC",
"last_price":"0.04600001",
"yesterday_price":"0.04300000",
"change":"+6.98",
"24hhigh":"0.04980000",
"24hlow":"0.04000050",
"24hvol":"21.737"
"top_bid":"0.04590000"
"top_ask":"0.04600005"
},
...
]
}NOTE: Yesterday price refers to what the price was midnight UTC.
Market Stats
GEThttps://api.chainex.io/market/stats/{COIN}/{EXCHANGE}
Provides the statistics for a single market. Data refreshes every minute.
Example: https://api.chainex.io/market/stats/LTC/BTC
Response
{
"status":"success",
"data":{
"code":"LTC",
"exchange":"BTC",
"last_price":"0.04600001",
"yesterday_price":"0.04300000",
"change":"+6.98",
"24hhigh":"0.04980000",
"24hlow":"0.04000050",
"24hvol":"21.737"
"top_bid":"0.04590000"
"top_ask":"0.04600005"
}
}NOTE: Yesterday price refers to what the price was midnight UTC.
Market Trades
GEThttps://api.chainex.io/market/trades/{COIN}/{EXCHANGE}
Fetches the last 100 trades for a given market.
Example: https://api.chainex.io/market/trades/LTC/BTC
GEThttps://api.chainex.io/market/trades/{COIN}/{EXCHANGE}/{LIMIT}
Fetches the specified number of trades for a given market, maximum limit is 200.
Example: https://api.chainex.io/market/trades/LTC/BTC/150
Response
{
"status":"success",
"count":100,
"data":[{
"type":"SELL",
"price":"0.00000023",
"amount":"412128.80177019",
"total":"0.09478962",
"time":"1394498289.2727"
},
...
]
}NOTE: Time is specified as a unix timestamp with microseconds.
Market Orders
Single Type
GEThttps://api.chainex.io/market/orders/{COIN}/{EXCHANGE}/{TYPE}
Fetches the 50 best priced orders of a given type for a given market, where {TYPE} can be either BUY or SELL.
Example: https://api.chainex.io/market/orders/LTC/BTC/BUY
GEThttps://api.chainex.io/market/orders/{COIN}/{EXCHANGE}/{TYPE}/{LIMIT}
Fetches the specified number of best priced orders of a given type for a given market, where {TYPE} can be either BUY or SELL, maximum limit is 200.
Example: https://api.chainex.io/market/orders/LTC/BTC/BUY/150
Response
{
"status":"success",
"count":23,
"data":[{
"price":"0.00000023",
"amount":"22446985.14519785",
"total":"5.16280655"
},
...
]
}Combined
GEThttps://api.chainex.io/market/orders/{COIN}/{EXCHANGE}/ALL
Fetches the 50 best priced buy and sell orders together for a given market.
Example: https://api.chainex.io/market/orders/LTC/BTC/ALL
GEThttps://api.chainex.io/market/orders/{COIN}/{EXCHANGE}/ALL/{LIMIT}
Fetches the specified number of best priced buy and sell orders together for a given market, maximum limit is 200 for each type.
Example: https://api.chainex.io/market/orders/LTC/BTC/ALL/150
Response
{
"status":"success",
"data":[{
"type":"buy",
"count":23,
"orders":[{
"price":"0.00000023",
"amount":"22446985.14519785",
"total":"5.16280655"
},
...
]},{
"type":"sell",
"count":150,
"orders":[{
"price":"0.00000024",
"amount":"1000000.00000000",
"total":"0.24000000"
},
...
]}
}]
}GEThttps://api.chainex.io/market/chartdata/{COIN}/{EXCHANGE}/{PERIOD}
Fetches the chart data that we use for our candlestick graphs for a market for a given time period. The period is an optional parameter and can be either '6hh' (6 hours), '1DD' (24 hours), '3DD' (3 days), '7DD' (1 week) or 'MAX'. If no period is defined, it will default to 6 hours.
Example: https://api.chainex.io/market/chartdata/LTC/BTC/1DD
Response
{
"status":"success",
"count":144,
"data":[{
"date":"2017-02-09 14:20",
"open":"0.00000006",
"close":"0.00000006",
"high":"0.00000006",
"low":"0.00000003",
"exchange_volume":"0.00002145",
"coin_volume":"608.50000000"
},
...
]
}WALLET METHODS
All wallet methods require authentication.
GEThttps://api.chainex.io/wallet/balances/
Fetches all the balances in your account, split down into available balance, pending deposits, pending withdrawals and held for orders.
GEThttps://api.chainex.io/wallet/balances/{COIN}
Fetches the balance for a specific coin, split down into available balance, pending deposits, pending withdrawals and held for orders.
Example: https://api.chainex.io/wallet/balances/BTC
Response
{
"status":"success",
"count":42,
"data":[{
"code":"LTC",
"name":"Litecoin",
"balance_available":"2.00000000",
"balance_pending_deposit":"0.00000000",
"balance_pending_withdraw":"0.00000000",
"balance_held":"6.50000000"
},
...
]
}GEThttps://api.chainex.io/wallet/deposits/
Fetches the deposits made in to your account, including pending and confirmed deposits, ordered by most recent first and limited to 25 results.
GEThttps://api.chainex.io/wallet/deposits/{COIN}
Fetches the deposits made in to your account for a specific coin, including pending and confirmed deposits, ordered by most recent first and limited to 25 results.
Example: https://api.chainex.io/wallet/deposits/BTC
GEThttps://api.chainex.io/wallet/deposits/{COIN}/{START}/{LIMIT}
By default, the method will fetch 25 results. Use the start and limit parameters to fetch more results. Use ALL for the coin if you want to fetch more results for all coins. The maximum limit is 200 entries.
Example: https://api.chainex.io/wallet/deposits/ALL/25/50 fetches the 26th to 75th items.
Response
{
"status":"success",
"count":25,
"data":[{
"code":"ETH",
"address":"0x81d792DF9966daFf0dcE2c7fB98680801eB0f971",
"coin_network": null,
"network_name": "Ethereum Goerli",
"amount": "1.00000000",
"time": "1739274681",
"email_confirm": "0",
"time_formatted": "2025-02-11 11:51:21",
"status": "UNCONFIRMED",
"reason": "Please confirm the withdrawal by email."
},
...
]
}GEThttps://api.chainex.io/wallet/depositaddress/{COIN}
Fetches the deposit address for the specified coin.
Response
{
"status":"success",
"data":"1234567890AbCdEfGhIjKlMnOpQrStUvWxYz"
}GEThttps://api.chainex.io/wallet/newdepositaddress/{COIN}
Fetches a new deposit address for the specified coin.
Response
{
"status":"success",
"data":"1234567890AbCdEfGhIjKlMnOpQrStUvWxYz"
}GEThttps://api.chainex.io/wallet/withdrawals/
Fetches the withdrawals made from your account, including pending and completed withdrawals, ordered by most recent first and limited to 25 results.
GEThttps://api.chainex.io/wallet/withdrawals/{COIN}
Fetches the withdrawals made from your account for a specific coin, including pending and completed withdrawals, ordered by most recent first and limited to 25 results.
Example: https://api.chainex.io/wallet/withdrawals/BTC
GEThttps://api.chainex.io/wallet/withdrawals/{COIN}/{START}/{LIMIT}
By default, the method will fetch 25 results. Use the start and limit parameters to fetch more results. Use ALL for the coin if you want to fetch more results for all coins. The maximum limit is 200 entries.
Example: https://api.chainex.io/wallet/withdrawals/ALL/25/50 fetches the 26th to 75th items.
Response
{
"status":"success",
"count":25,
"data":[{
"code":"ETH",
"address":"0x81d792DF9966daFf0dcE2c7fB98680801eB0f971",
"coin_network": null,
"network_name": "Ethereum Goerli",
"amount": "1.00000000",
"time": "1739274681",
"email_confirm": "0",
"time_formatted": "2025-02-11 11:51:21",
"status": "UNCONFIRMED",
"reason": "Please confirm the withdrawal by email."
},
...
]
}GEThttps://api.chainex.io/wallet/withdrawal/{ID}
Fetches the details of a single withdrawal identified by the withdrawal ID.
Response
{
"status":"success",
"count":25,
"data":[{
"code":"ETH",
"address":"0x81d792DF9966daFf0dcE2c7fB98680801eB0f971",
"coin_network": null,
"network_name": "Ethereum Goerli",
"amount": "1.00000000",
"time": "1739274681",
"email_confirm": "0",
"time_formatted": "2025-02-11 11:51:21",
"status": "UNCONFIRMED",
"reason": "Please confirm the withdrawal by email."
},
...
]
}POSThttps://api.chainex.io/wallet/withdraw/{COIN}
Submits a withdrawal request, requires email confirmation to process.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| address | String | Yes | The address you wish to withdraw to. |
| amount | Decimal | Yes | The amount you wish to withdraw, up to 8 decimals. Remember that a withdrawal fee will be applied to this amount. |
| beneficiary | String | Yes | The full name of the person or entity receiving the funds. Required if using a new address or an address that does not have an existing beneficiary. |
| destination | String | Yes | The name of the platform or wallet where the funds will be sent (e.g., "OKX", "Binance"). If the destination is a personal wallet, use "private" — it will be internally recorded as "Self Custody Wallet". Required if using a new address or an address that does not have an existing destination. |
| payment_id | String | No | An optional Payment ID to include with your withdrawal. This is only used for coins based on the CryptoNote protocol such as Monero. |
Response
{
"status":"success",
"message":"Your withdrawal request has now been added, please confirm by email and we will then process it.",
"data":{
"code":"BTC",
"address":"1234567890AbCdEfGhIjKlMnOpQrStUvWxYz",
"amount":"0.06600000",
"fee":"0.00020000",
"txid":"2c6f31555b5309293f0f83a38703ef7fa74c163155642d3fe53c9cc488bf35eg",
"time":"1393776944",
"pending":"0",
"time_formatted":"2017-03-20 19:50:39"
"status":"UNCONFIRMED",
"reason":"Please confirm the withdrawal by email."
}
}DELETEhttps://api.chainex.io/wallet/withdraw/{ID}
Cancels a withdrawal request identified by the withdrawal ID, can only cancel unconfirmed and unsuccessful withdrawals.
Response
{
"status":"success",
"message":"The pending withdrawal has successfully been cancelled and the balance made available again."
}TRADING METHODS
All trading methods require authentication.
GEThttps://api.chainex.io/trading/orders/
Fetches the current open orders in your account, ordered by most recent first and limited to 25 results.
GEThttps://api.chainex.io/trading/orders/{COIN}
Fetches the current open orders in your account for a specified coin, ordered by most recent first and limited to 25 results.
Example: https://api.chainex.io/trading/orders/BTC
GEThttps://api.chainex.io/trading/orders/{COIN}/{START}/{LIMIT}
By default, the method will fetch 25 results. Use the start and limit parameters to fetch more results. Use ALL for the coin if you want to fetch more results for all coins/markets. The maximum limit is 200 entries.
Example: https://api.chainex.io/trading/orders/ALL/25/50 fetches the 26th to 75th items.
Response
{
"status":"success",
"count":25,
"data":[{
"order_id":"YFHG-12345678",
"market":"LTC\/BTC",
"type":"BUY",
"price":"0.00000015",
"amount":"500.00000000",
"total":"0.00007500",
"fee":"0.00000011",
"net_total":"0.00007511",
"time":"1393776944.1234",
"time_formatted":"2017-03-20 19:50:39"
},
...
]
}GEThttps://api.chainex.io/trading/order/{ID}
Fetches the order identified by the order ID.
Response
{
"status":"success",
"data":{
"order_id":"YFHG-12345678",
"market":"LTC\/BTC",
"type":"BUY",
"price":"0.00000015",
"amount":"500.00000000",
"total":"0.00007500",
"fee":"0.00000011",
"net_total":"0.00007511",
"time":"1393776944.1234",
"time_formatted":"2017-03-20 19:50:39"
}
}POSThttps://api.chainex.io/trading/order/
Submits a new order to market.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| coin | String | Yes | The first half of the market, e.g. if want to add order to LTC/BTC, enter LTC. |
| exchange | String | Yes | The second half of the market, e.g. if want to add order to LTC/BTC, enter BTC. |
| price | Decimal | Yes | The price of the order, up to 8 decimals. |
| amount | Decimal | Yes | The amount of coins you wish to purchase or sell, up to 8 decimals. |
| type | Integer | Yes | If the order is a BUY (0) or a SELL (1). |
| post_only | boolean | No | An order will only be placed if it does not match against an existing order in the order book, i.e. it will only be placed as a Maker Order |
Response
{
"status":"success",
"message":"The order has successfully gone to market.",
"data":{
"order_id":"YFHG-12345678",
"market":"LTC/BTC",
"type":"BUY",
"price":"0.00000015",
"amount":"500.00000000",
"total":"0.00007500",
"fee":"0.00000011",
"net_total":"0.00007511",
"time":"1393776944.1234",
"time_formatted":"2017-03-20 19:50:39"
}
}DELETEhttps://api.chainex.io/trading/order/{ID}
Cancels an open order identified by the order ID. Warning: order cancellations are processed FIFO (First In First Out) alongside new orders, so it may be matched before the cancellation can be processed.
Response
{
"status":"success",
"message":"The pending withdrawal has successfully been cancelled and the balance made available again."
}GEThttps://api.chainex.io/trading/trades/
Fetches the trades made in your account, ordered by most recent first and limited to 25 results.
GEThttps://api.chainex.io/trading/trades/{COIN}
Fetches the trades made in your account for a specific coin, including BTC and LTC markets where applicable, ordered by most recent first and limited to 25 results.
Example: https://api.chainex.io/trading/trades/BTC
GEThttps://api.chainex.io/trading/trades/{COIN}/{START}/{LIMIT}
By default, the method will fetch 25 results. Use the start and limit parameters to fetch more results. Use ALL for the coin if you want to fetch more results for all coins/markets. The maximum limit is 200 entries.
Example: https://api.chainex.io/trading/trades/ALL/25/50 fetches the 26th to 75th items.
Response
{
"status":"success",
"count":25,
"data":[{
"trade_id":"YFHG-12345678",
"market":"LTC\/BTC",
"type":"BUY",
"time":"1393776944.1234",
"price":"0.00000015",
"amount":"500.00000000",
"total":"0.00007500",
"fee":"0.00000011",
"net_total":"0.00007511",
"order_id":"ONYC-12345678",
"time_formatted":"2017-03-20 19:50:39"
},
...
]
}GEThttps://api.chainex.io/trading/trade/{ID}
Fetches the trade identified by the trade ID.
Response
{
"status":"success",
"data":[{
"trade_id":"YFHG-12345678",
"market":"LTC\/BTC",
"type":"BUY",
"time":"1393776944.1234",
"price":"0.00000015",
"amount":"500.00000000",
"total":"0.00007500",
"fee":"0.00000011",
"net_total":"0.00007511",
"order_id":"ONYC-12345678",
"time_formatted":"2017-03-20 19:50:39"
}
}SAMPLE CODE
You are free to use and modify all of the below API sample code.
<?php
// Get balances
$response = _doAPICall('wallet/balances');
// Test a withdraw
//$response = _doAPICall('wallet/withdraw/BTC', array('address' => "123456789", 'amount' => '10'), 'POST');
// Delete an order
//$response = _doAPICall('trading/order/KMTA-12345678', array(), 'DELETE');
// Interfaces with the ChainEX API via cURL. Function handles, GET, POST & DELETE
//
// @param string $apiCall The API function that we want to use
// @param array $data The data for the API function parameters
// @param string $method If we're using GET, POST or DELETE, uses GET by default
// @return array
function _doAPICall($apiCall, $data = array(), $method = 'GET')
{
// Setup public & private keys
$apiPublicKey = "123931eeb6baadd53cbdbc755ac81cfd";
$apiPrivateKey = "6546d5e0692d7d5dfd84c1a25ea9d7";
// Setup URL
$apiUrl = "https://api.chainex.io/";
// Set time to variable so it's definitely constant
$time = time();
// Start cURL
$c = curl_init();
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
// Check what type of API call we are making
if ($method == 'GET') {
// Start building the URL
$apiCall = $apiUrl . $apiCall . "?time=" . $time . "&key=" . $apiPublicKey;
// Add the array of data to the URL
if (count($data)) {
$apiCall .= "&".http_build_query($data);
}
// Hash the data
$hash = hash_hmac("sha256", $apiCall, $apiPrivateKey);
// Append the hash
$apiCall .= "&hash=" . $hash;
// Setup the remainder of the cURL request
curl_setopt($c, CURLOPT_URL, $apiCall);
} else if ($method == 'DELETE') {
// DELETE requests use POSTFIELDS, so add the time and hash
$data['time'] = $time;
$data['key'] = $apiPublicKey;
// Hash the data
$data['hash'] = hash_hmac("sha256", $apiUrl . $apiCall . "?" . http_build_query($data), $apiPrivateKey);
// Setup the remainder of the cURL request
curl_setopt($c, CURLOPT_URL, $apiUrl . $apiCall);
curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($c, CURLOPT_HTTPHEADER, array('X-HTTP-Method-Override: ' . $method));
} else {
// It's a POST request, so add in some additional data
$data['time'] = $time;
$data['key'] = $apiPublicKey;
// Hash the data
$data['hash'] = hash_hmac("sha256", $apiUrl . $apiCall . "?" . http_build_query($data), $apiPrivateKey);
// Setup the remainder of the cURL request
curl_setopt($c, CURLOPT_URL, $apiUrl . $apiCall);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($data));
}
// Execute the API call and return the response
$result = curl_exec($c);
curl_close($c);
// Return the results of the API call
return json_decode($result);
}
?>