General REST API Information
- The base URL: https://api-adapter.dzengi.com
- The base URL, demo account: https://demo-api-adapter.dzengi.com
- All endpoints return either a JSON object or array.
- Data is returned in ascending order. Oldest first, newest last.
- All time and timestamp related fields are in milliseconds.
- All the tokenised assets except companies tokens, tokenized bonds and tokenised assets from Hong Kong markets are available in the first version (v1) of our API. In the second API version (v2) Hong Kong markets became also available.
- The list of assets available for leverage trading within API can be found here.
- When setting market, limit or stop orders and mentioning a bigger amount of precision numbers than required for a specific token a round_down logic is true. The allowed precision can be found in the exchangeInfo request response, quotePrecision parameter.
- When mentioning a bigger amount of precision numbers for the price parameter a round_up logic is used. The allowed precision can be found in the exchangeInfo request response, quotePrecision parameter.
Please, refer to the REST API part within the Swagger in order to get the information needed.
Troubleshooting
HTTP Return Codes
- HTTP 4XX return codes are used for malformed requests; the issue is on the sender's side.
- HTTP 403 return code is used when the WAF Limit (Web Application Firewall) has been violated.
- HTTP 429 return code is used when breaking a request rate limit.
- HTTP 418 return code is used when an IP has been auto-banned for continuing to send requests after receiving 429 codes.
- HTTP 5XX return codes are used for internal errors; the issue is on Dzengi.com side. It is important to NOT treat this as a failure operation; the execution status is UNKNOWN and could have been a success.
Error Codes
- Any endpoint can return an ERROR.
Sample Payload below:
- Specific error codes and messages are defined in Error Codes.
General Information on Endpoints
- For
GET
endpoints, parameters must be sent as aquery string
. - For
POST
,PUT
, andDELETE
endpoints, the parameters may be sent as a query string or in the request body with content type application/x-www-form-urlencoded. You may mix parameters between both the query string and request body if you wish to do so. Parameters may be sent in any order. - Parameters may be sent in any order.
- If a parameter sent in both the query string and request body, the query string parameter will be used.
Endpoint security type
- Each endpoint has a security type that determines the how you will interact with it. This is stated next to the NAME of the endpoint.
- If no security type is stated, assume the security type is NONE.
- API-keys are passed into the REST API via the X-MBX-APIKEY header.
- API-keys and secret-keys are case sensitive.
- API-keys can be configured to only access certain types of secure endpoints. For example, one API-key could be used for TRADE only, while another API-key can access everything except for TRADE routes.
- By default, API-keys can access all secure routes.
Security type | Description |
---|---|
NONE | Endpoint can be accessed freely |
TRADE | Endpoint requires sending a valid API-Key and signature |
USER_DATA | Endpoint requires sending a valid API-Key and signature |
USER_STREAM | Endpoint requires sending a valid API-Key |
MARKET_DATA | Endpoint requires sending a valid API-Key |
TRADE
andUSER_DATA
endpoints areSIGNED
endpoints.
SIGNED (TRADE, USER_DATA, AND MARGIN) Endpoint security
SIGNED
endpoints require an additional parameter, signature, to be sent in thequery string
or request body.- Endpoints use
HMAC SHA256
signatures. TheHMAC SHA256
signature is a keyedHMAC SHA256
operation. Use yoursecretKey
as the key andtotalParams
as the value for the HMAC operation. - The
signature
is not case sensitive. totalParams
is defined as thequery string
concatenated with therequest body
.
Timing security
- A
SIGNED
endpoint also requires a parameter,timestamp
, to be sent which should be the millisecond timestamp of when the request was created and sent. - An additional parameter,
recvWindow
, may be sent to specify the number of milliseconds aftertimestamp
the request is valid for. IfrecvWindow §
is not sent, it defaults to 5000.
The logic is as follows:
Serious trading is about timing. Networks can be unstable and unreliable, which can lead to requests taking varying amounts of time to reach the servers. With recvWindow
, you can specify that the request must be processed within a certain number of milliseconds or be rejected by the server.
It is recommended to use a small recvWindow of 5000 or less! The max cannot go beyond 60,000!
SIGNED Endpoint Examples for POST /api/v1/order
Here is a step-by-step example of how to send a valid signed payload from the Linux command line using echo, openssl, and curl.
Key | Value |
---|---|
apiKey | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A |
secretKey | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j |
Parameter | Value |
---|---|
symbol | LTC/BTC |
side | BUY |
type | LIMIT |
timeInforce | GTC |
quantity | 1 |
price | 0,1 |
recvWindow | 5000 |
timestamp | 1499827319559 |
Please note that some symbols like '/' should be url encoded and transformed into the following combination '%2F'.
SIGNED Endpoint Examples for POST /api/v1/order (leverage trading mode)
Here is a step-by-step example of how to send a valid signed payload from the Linux command line using echo, openssl, and curl.
Key | Value |
---|---|
apiKey | vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A |
secretKey | NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j |
Parameter | Value |
---|---|
symbol | BTC/USD_LEVERAGE |
side | BUY |
type | MARKET |
timeInforce | GTC |
quantity | 0.01 |
quantity | 2 |
accountId | 2376109060084932 |
takeProfit | 8000 |
stopLoss | 6000 |
recvWindow | 60000 |
timestamp | 1586942164000 |
Please note that some symbols like '/' should be url encoded and transformed into the following combination '%2F'.
Terminology
base asset
refers to the asset that is thequantity
of a symbol.quote asset
refers to the asset that is theprice
of a symbol.
Order status (status):
- NEW
- FILLED
- CANCELED
- REJECTED
Order types (orderTypes, type):
- LIMIT
- MARKET
- STOP
Order side (side):
- BUY
- SELL
Time in force (timeInForce):
- GTC
- IOC
- FOK
Kline/Candlestick chart intervals:
m -> minutes; h -> hours; d -> days; w -> weeks
- 1m
- 5m
- 15m
- 30m
- 1h
- 4h
- 1d
- 1w
/klines 'type' parameter:
- heiken-ashi