NCX provides a complete RESTful API for developers which allows full access to all the functionalities on the exchange.
These endpoints are categorized into public and private. Public endpoints allow you to access public information such as price ticker, orderbook etc while private endpoints require authentication and allow you to get your balance, active orders as well as placing orders.
Authentication
NCX uses HMAC-SHA256 authentication for private user access to the API. HMAC-SHA256 takes a string and secret key (your api-secret) and outputs an encoded signature (your api-signature). The string being encoded should follow the format ${METHOD}${PATH}${api-expires}, where METHOD is the HTTP method of the request, PATH is the path of the request, and api-expires is a unix timestamp indicating when the request expires. If the request includes a body, the JSON body object should be appended to the string being encoded e.g. ${METHOD}${PATH}${api-expires}${JSON_BODY}. You can use an online HMAC generator to generate the signature.
POST request to https://ncx.mn/api/v2/order that expires at 1575516146 with body {"symbol":"btc-usdt","side":"buy","size":0.001,"type":"market"} POST/v2/order1583284849{"symbol":"btc-usdt","side":"buy","size":0.001,"type":"market"}
You can register for a new NCX api-key and api-secret in the security section of ncx.mn. NCX expects api-key, api-signature, and api-expires to be included in all Private API requests to the server in the request header with the following format:
You must replace API_KEY, API_SIGNATURE, and API_EXPIRES with your own values
To authorize, use this code:
# With shell, you can just pass the correct header with each request curl -X POST -H "api-key: $API_KEY" -H "api-signature: $API_SIGNATURE" -H "api-expires: $API_EXPIRES" "api_endpoint_here"
Make sure to replace $API_KEY, $API_SIGNATURE, and $API_EXPIRES with your own key, signature, and expires values.
List of http request errors you might get from ncx.mn
The NCX API uses the following error codes:
Error Code
Meaning
400
Bad Request -- Your request is invalid.
403
Unauthorized/Forbidden -- Your api token is not valid.
404
Not Found -- The specified request could not be found.
405
Method Not Allowed -- You tried to access a request with an invalid method.
410
Gone -- The request has been removed from our servers.
429
Too Many Requests -- You're requesting too many requests! Slow down!
500
Internal Server Error -- We had a problem with our server. Try again later.
503
Service Unavailable -- We're temporarily offline for maintenance. Please try again later.
Using Nodejs Library
Connect with ncx.mn using Hollaex kit Nodejs Library
Requirements
Knowledge of basic usage of nodejs and npm
Nodejs version >= 12
Request structure
// Initialize Client using above example...
client.getTicker('xht-usdt').then((res)=>{console.log('The volume is: ',res.volume);}).catch((err)=>{console.log(err);});client.getTrade({symbol:'xht-usdt'}).then((res)=>{console.log('Public trades: ',res);}).catch((err)=>{console.log(err);});
Example
// Initialize Client using above example...
constsocket1=client.connect('trades:xht-usdt');socket1.on('trades',(data)=>{console.log(data);});constsocket2=client.connect('all');socket2.on('orderbook',(data)=>{console.log(data);});// You have to use a token to use these otherwise the socket disconnects
socket2.on('userInfo',(data)=>{console.log(data);});setTimeout(()=>{socket2.disconnect();},5);
Available methods
Command
Parameters
Description
getKit
Get exchange information e.g. name, valid languages, description, etc.
getConstants
Tick size, min price, max price, min size and max size of each symbol pair and coin
getTicker
symbol
Last, high, low, open and close price and volume within the last 24 hours
getTickers
Last, high, low, open and close price and volume within the last 24 hours for all symbols
getOrderbook
symbol
Orderbook containing list of bids and asks
getOrderbooks
Orderbook containing list of bids and asks for all symbols
Create a new withdrawal request. Disable Two-Factor Authentication to be able to use this function. Must confirm within 5 minutes via email to complete withdrawal
getUserTrades
symbol (optional), limit (optional, default=50, max=100), page (optional, default=1), orderBy (optional, default=id), order (optional, default=desc, asc or desc), startDate (optional, default=0, format=ISO8601), endDate (optional, default=NOW, format=ISO8601)