Welcome to the ELITEX API developer documentation.
This document provides an introduction to the use of related APIs such as account management, market inquiry, and transaction functions of the Spot business. The Quotes API provides the market's open market data interface. The Account and Transaction APIs require authentication, providing the ability to place orders, cancel orders, and query orders and account information.
REST, short for Representational State Transfer, is a popular Internet transport architecture. It has a clear structure, standards, easy to understand, and easy to expand, and is being used by more and more websites. The advantages are as follows:
- In a RESTful architecture, each URL represents a resource;
- A layer of presentation of such resources between the client and the server;
- The client operates on the server-side resources through four HTTP commands to implement "presentation level state conversion".
Developers are advised to use the REST API for currency transactions or asset withdrawals.
Before signing any request, you must create an API key via the ELITEX website [User Center] --> [API]. After creating the key, you will get 2 pieces of information that you must remember:
- API Key
- Secret Key
The API Key and Secret Key will be randomly generated by the exchange system.
All REST requests must contain the following data in the HTTP header:
- ACCESS-KEY API KEY as a string.
- ACCESS-SIGN uses base64 encoding signatures (see Signing Messages).
- ACCESS-TIMESTAMP as the timestamp of your request.
All requests should contain application/json type content and be valid JSON.
The request header of ACCESS-SIGN is obtained by encoding the timestamp + method + requestPath + "?" + queryString + body string (+ indicates a string concatenation) using the HMAC SHA256 method, which is encoded by BASE64 encoding. Among them, the value of timestamp is the same as the ACCESS-TIMESTAMP request header.
-
method is the request method (POST/GET/PUT/DELETE), and the letters are all uppercase.
-
requestPath is the request interface path.
-
queryString Query string in the GET request
-
body is the string of the request body, and the body can be omitted if the request has no body (usually a GET request).
-
For example: Sign the following request parameters
Url "https://api.elitex.io/api/v1/orders?limit=100"
- Get order book information, taking ETH-BTC currency pair as an example
Timestamp = 1540286290170
Method = "GET"
requestPath = "/api/v1/public/products/ETH-BTC/orderbook"
queryString= "?size=100"
- Generate a string to be signed
Message = '1540286290170GET/api/v1/public/products/ETH-BTC/orderbook?size=100'
- Place an order with ETH-BTC pair as an example
Timestamp = 1540286476248
Method = "POST"
requestPath = "/api/v1/orders"
Body = {"code":"ETH_BTC","side":"buy","type":"limit","size":"1","price":"1.001"}
- Generate a string to be signed
Message = '1540286476248POST/api/v1/orders{"code":"LTC-BTC","side":"buy","type":"limit","size":"1","price":" 1.001"}'
Then, add the private key parameter to the string to be signed to generate the final string to be signed.
For example:
Signature = hmac(secretkey, Message, SHA256)
Base64 encoding for Signature is required before use
Signature = base64.encode(Signature.digest())
Root URL for REST access: https://api.elitex.io
All requests are based on the Https protocol, and the Content-Type in the request header information needs to be uniformly set to: 'application/json'.
- Request parameters: Parameter encapsulation according to interface request parameters.
- Submit request parameters: Submit the encapsulated request parameters to the server through POST/GET/DELETE.
- Server response: The server first performs parameter security verification on the user request data, and returns the response data to the user in JSON format according to the business logic after verification.
- Data Processing: Process the server response data.
The HTTP status code 200 indicates a successful response and may contain content. If the response contains content, it will be displayed in the corresponding return content.
- 400 Bad Request – The request could not be understood by the server due to malformed syntax
- 401 Unauthorized – The request requires user authentication
- 403 Forbidden – The server understood the request, but is refusing to fulfill it.
- 404 Not Found -- The server has not found anything matching the Request-URI.
- 429 Too Many Requests -- requests are too frequent so rejected by the system
- 500 Internal Server Error – The server encountered an unexpected condition which prevented it from fulfilling the request.
If it fails, the response body has an error description
REST requests for partial return datasets support the use of cursor paging. Cursor paging allows results to be obtained before and after the current page of results, and is well suited for real-time data. Based on the current return result, subsequent requests can specify the direction of the requested data on this basis, and can request data before and after this. The before and after cursors can be used by the response headers CB_BEFORE and CB_AFTER.
example
GET /orders?before=2&limit=30
All timestamps in the API are returned in milliseconds unless otherwise specified.
The unit of ACCESS-TIMESTAMP in the request signature is milliseconds, allowing decimals to represent more precise time. The diff between requested timestamp and the API service server side timestamp must be within 30 seconds, otherwise the request will be considered expired and rejected. If there is a large deviation between the client local time and the API server time, then we recommend that you sync the timestamp in the http header by querying the specific API for server timestamp.
1524801032573
In order to maintain the integrity of the accuracy across platforms, decimal numbers are returned as strings. It is recommended that you also convert numbers to strings when invoking a request to avoid truncation and precision errors.
Integers (such as transaction numbers and order) are not quoted.
If the request is too frequent, the system will automatically limit the request and return 429 (too many requests) status code in the http header.
- Public interface: We restrict the call of the public interface by IP: up to 6 requests every 2 seconds.
- Private interface: We restrict the call of the private interface by user ID: up to 6 requests every 2 seconds.
- Some special restrictions on the interface are indicated on the specific interface
# Request
GET /api/v1/public/products
# Response
{
"code": 200,
"data": [
{
"baseCurrency": "ETH",
"baseMaxSize": 10,
"baseMinSize": 1,
"code": "ETH_BTC",
"counterCurrency": "BTC",
"counterIncrement": 1e-8,
"counterPrecision": 8,
"volumeIncrement": 8
},
...
],
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, the specific data type is as follows |
| Msg | return information |
| Return field | field description |
|---|---|
| Code | coin pair code |
| baseCurrency | base currency |
| baseMinSize | minimum number of delegates |
| baseMaxSize | maximum number of delegates |
| counterCurrency | counting currency |
| counterIncrement | minimum quote unit |
| counterPrecision | Quote accuracy |
| volumeIncrement | trust change unit |
# Request
GET /api/v1/public/<code>/orderbook
# Response
{
"code": 200,
"data": {
"ask": [
{
"amount": 628.8642,
"price": 0.1
},
...
],
"bid": [
{
"amount": 103.632,
"price": 0.0353
},
...
]
},
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, the specific data type is as follows |
| Msg | return information |
| Return field | field description |
|---|---|
| Asks | seller depth, array queue |
| Bid | buyer depth, array queue |
| Price | Buy price |
| Amount | corresponding quantity |
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| Code | String | is | currency pairs, such as ETH_BTC |
# Request
GET /api/v1/public/<code>/ticker
# Response
{
"code": 200,
"data": {
"c": 0,
"change": "0",
"code": "ETH_BTC",
"h": 0,
"l": 0,
"o": 0,
"t": 1555819258573,
"v": 0
},
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, the specific data type is as follows |
| Msg | return information |
| Return field | field description |
|---|---|
| Code | coin pair code |
| t | timestamp |
| h | 24 hour maximum price |
| l | 24 hour minimum price |
| o | 24 hour opening price |
| c | 24 hour closing price |
| v | 24 hours trading volume |
| Change | 24 hour price change range, positive number is price increase, negative number is price drop |
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| Code | String | is | currency pairs, such as ETH_BTC |
- support paging query
# Request
GET /api/v1/public/<code>/trade
# Response
{
"code": 200,
"data": [
{
"amount": 10,
"id": 32340,
"price": 0.1,
"side": "sell",
"time": 1554758222000
},
...
],
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, the specific data type is as follows |
| Msg | return information |
| Return field | field description |
|---|---|
| Price | transaction price |
| Amount | volume |
| Side | Maker transaction direction |
| Time | transaction timestamp |
| Id | transaction number |
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| Code | String | is | currency pair, such as ETH_BTC |
| Limit | Integer | No | Request to return the amount of data, the default maximum value of 100 |
- Trading direction side means that each order is in the direction of the order, and maker is the trading user who hangs the order on the order depth list, that is, the passive party.
- buy represents the market down, because maker is paying, maker's buy order is sold, so the price falls; on the contrary, sell represents the market, because the maker is the sell order, the sell order is sold, indicating the rise.
# Request
GET /api/v1/public/<code>/candles?type=1min&start=start_time&end=end_time
# Response
{
"code": 200,
"data": [
{
"c": 0.0354,
"h": 0.0354,
"l": 0.0354,
"o": 0.0354,
"t": 1554084960000,
"v": 28.24858757
},
...
],
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, the specific data type is as follows |
| Msg | return information |
| Return field | field description |
|---|---|
| t | K line start timestamp |
| l | lowest price |
| h | highest price |
| o | Opening price (first transaction) |
| c | closing price (last transaction) |
| v | trading volume |
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| Code | String | 是 | coin pairs such as ETH_BTC |
| Type | String | is | K line period type such as 1m/1h/1d/1w |
| Start | String | Yes | Start time based on ISO 8601 standard |
| End | String | Yes | End time based on ISO 8601 standard |
# Request
GET /api/v1/public/time
# Reponse
{
"code": 200,
"data": {
"epoch": 1555906478384,
"iso": "2019-04-22T12:14:38.384Z"
},
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, the specific data type is as follows |
| Msg | return information |
| Return field | field description |
|---|---|
| Iso | server time for iso 8061 standard time string expression |
| Epoch | timestamp form of server time |
# Request
GET /api/v1/account
# Response
{
"code": 200,
"data": [
{
"available": 15791.879833478282,
"balance": 15806.267923091284,
"coin": "BTC",
"freezed": 14.388089613
},
...
],
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, the specific data type is as follows |
| Msg | return information |
| Return field | field description |
|---|---|
| Available | available funds |
| Balance | Number of currencies |
| Coin | currency code |
| Freezed | freeze funds |
ELITEX offers both limit and market order types.
# Request
POST /api/v1/order
{
"amount": 1,
"code": "ETH_BTC",
"funds": 0,
"price": 1,
"side": 0,
"type": "limit"
}
# Response
{
"code": 200,
"data": 31479,
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, order id |
| Msg | return information |
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| Code | String | Yes | trading pairs such as ETH_BTC |
| Side | Integer | Yes | Buy is 1, Sell is 0 |
| Type | String | Yes | Limit order is limit, Market order is market |
| Amount | String | No | Place a limit order and a market price to sell the order, representing the number of coins |
| Price | String | No | Transfer when the limit order is issued, representing the price of the currency |
| Funds | String | No | Transfer when the market price is purchased, representing the number of coins |
# Request
DELETE /api/v1/orders/cancelAll/{code}?limit=50
# Response
{
"code": 200,
"data": {
"failNum": 5,
"failOrderId": [
666,
...
],
"successNum": 10
},
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, the specific data type is as follows |
| Msg | return information |
| Return field | field description |
|---|---|
| failNum | Number of cancelled orders |
| successNum | Number of successful orders withdrawn |
| failOrderId | Withdrawal failed order id array |
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| Code | String | No | Currency pairs, such as ETH_BTC |
| Limit | Integer | No | The number of withdrawals, default 50, maximum 1000 |
# Request
DELETE /api/v1/orders/cancel/{orderId}
# Response
{
"code": 200,
"data": {
"failNum": 1,
"failOrderId": [
666,
...
],
"successNum": 0
},
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, the specific data type is as follows |
| Msg | return information |
| Return field | field description |
|---|---|
| failNum | Number of cancelled orders |
| successNum | Number of successful orders withdrawn |
| failOrderId | Withdrawal failed order id array |
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| orderId | Integer | is | the id of the unfilled delegate that needs to be revoked |
- support paging query
# Request
GET /api/v1/orders/getAll/{code}?pageNum=1&pageSize=20
# Response
{
"code": 200,
"data": [
{
"amount": 1,
"code": "ETH_BTC",
"funds": 0,
"id": 31479,
"last": 1,
"price": 1,
"side": "sell",
"state": 4,
"time": 1555884317000,
"type": "limit"
}
],
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, the specific data type is as follows |
| Msg | return information |
| Return field | field description |
|---|---|
| Id | order id |
| Code | coin pair code, such as ETH_BTC |
| Price | order price |
| Amount | order quantity |
| Funds | order funds |
| Last | remaining number of amount |
| Side | |
| Type | order type, limit order is limit, market order is market |
| State | order status |
| Time | order creation time |
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| Code | String | No | Currency pairs such as ETH_BTC |
| pageNum | Integer | No | Pages, default 1 |
| pageSize | Integer | No | Requests the amount of data returned per page, default value 20, maximum value 1000 |
# Request
GET /api/v1/orders/ 9887828?code=chp_eth
# Response
{
"code": 200,
"data": {
"amount": 1,
"code": "ETH_BTC",
"funds": 0,
"id": 31479,
"last": 1,
"price": 1,
"side": "sell",
"state": 4,
"time": 1555884317000,
"type": "limit"
},
"msg": "success"
}
| Return field | field description |
|---|---|
| Code | state code, 200-successful no exception |
| Data | Data returns, no data is empty, the specific data type is as follows |
| Msg | return information |
| Return field | field description |
|---|---|
| Id | order id |
| Code | coin pair code, such as ETH_BTC |
| Price | order price |
| Amount | order quantity |
| Funds | order funds |
| Last | remaining number of amount |
| Side | |
| Type | order type, limit order is limit, market order is market |
| State | order status |
| Time | order creation time |
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| Code | String | Yes | currency pairs, such as ETH_BTC |
| orderId | String | Yes | OrderId |