Skip to content

elitex-io/official-api-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

ELITEX Exchange Official API Documentation

1.Introduction

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.

2.About REST

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.

3.API Encryption And Verification

3.1.Generate API Key

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.

3.2.Initiating A Request

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.

3.3.Signature

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())

3.4.Request Interaction

Root URL for REST access: https://api.elitex.io

3.4.1.Request

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'.

3.4.2.Request Interaction Description

  1. Request parameters: Parameter encapsulation according to interface request parameters.
  2. Submit request parameters: Submit the encapsulated request parameters to the server through POST/GET/DELETE.
  3. 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.
  4. Data Processing: Process the server response data.

3.4.3.Success

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.

3.4.4.Common Error Codes

  • 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

3.5.Pagination

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

4.Standard Specification

4.1.Timestamp

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.

4.2.Examples

1524801032573

4.3.Numbers

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.

4.4.Limiting

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.

4.5.REST API

  • 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

5.Spot Trade

5.1.Coin Quotes

5.1.1. Get a list of all trading pairs

HTTP request
    # 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 Value Description
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
Data Value Description
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

5.1.2. Order book

HTTP request
    # 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 description
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
Data Value Description
Return field field description
Asks seller depth, array queue
Bid buyer depth, array queue
Price Buy price
Amount corresponding quantity
Request Parameters
Parameter Name Parameter Type Required Description
Code String is currency pairs, such as ETH_BTC

5.1.3. Get the Trading pair Ticker

HTTP request
    # 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 Description
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
Data Value Description
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
Request Parameters
Parameter Name Parameter Type Required Description
Code String is currency pairs, such as ETH_BTC

5.1.4. Query Historical orders

  • support paging query
HTTP request
    # 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 Value Description
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
Data Value Description
Return field field description
Price transaction price
Amount volume
Side Maker transaction direction
Time transaction timestamp
Id transaction number
Request Parameters
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
Explain
  • 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.

5.1.5. Get K line data

HTTP request
    # 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 Value Description
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
Data Value Description
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
Request Parameters
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

5.1.6. Get Server Timestamp

HTTP request
    # Request
    GET /api/v1/public/time
    # Reponse
    {
        "code": 200,
        "data": {
            "epoch": 1555906478384,
            "iso": "2019-04-22T12:14:38.384Z"
        },
        "msg": "success"
    }
Return Value Description
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
Data Value Description
Return field field description
Iso server time for iso 8061 standard time string expression
Epoch timestamp form of server time

5.2.Coin Account API

5.2.1. Get account information

HTTP request
    # Request
    GET /api/v1/account

    # Response
    {
        "code": 200,
        "data": [
            {
            "available": 15791.879833478282,
            "balance": 15806.267923091284,
            "coin": "BTC",
            "freezed": 14.388089613
            },
        ...
        ],
        "msg": "success"
    }
Return Value Description
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
Data value Description
Return field field description
Available available funds
Balance Number of currencies
Coin currency code
Freezed freeze funds

5.2.2. Place Order

ELITEX offers both limit and market order types.

HTTP request
    # 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 value description
Return field field description
Code state code, 200-successful no exception
Data Data returns, no data is empty, order id
Msg return information
Request Parameters
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

5.2.3. Cancel All Pending Order

HTTP request
    # Request
    DELETE /api/v1/orders/cancelAll/{code}?limit=50
    # Response
        {
        "code": 200,
        "data": {
            "failNum": 5,
            "failOrderId": [
                666,
                ...
            ],
            "successNum": 10
        },
        "msg": "success"
    }
Return value description
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
data value description
Return field field description
failNum Number of cancelled orders
successNum Number of successful orders withdrawn
failOrderId Withdrawal failed order id array
Request Parameters
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

5.2.4. Cancel Pending Order By ID

HTTP Request
    # Request
    DELETE /api/v1/orders/cancel/{orderId}
    # Response
        {
        "code": 200,
        "data": {
            "failNum": 1,
            "failOrderId": [
                666,
                ...
            ],
            "successNum": 0
        },
        "msg": "success"
    }
Return Value Description
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
Data Value Description
Return field field description
failNum Number of cancelled orders
successNum Number of successful orders withdrawn
failOrderId Withdrawal failed order id array
Request Parameters
Parameter Name Parameter Type Required Description
orderId Integer is the id of the unfilled delegate that needs to be revoked

5.2.5. Query All Orders

  • support paging query
HTTP request
    # 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 value description
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
Data value description
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

Request Parameters

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

5.2.6. Query orders by id

HTTP request
    # 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 value description
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
Data value description
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
Request Parameters
Parameter Name Parameter Type Required Description
Code String Yes currency pairs, such as ETH_BTC
orderId String Yes OrderId

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •