This module fully implements tha Coinex API. The full documentation for the API is available on the API Wiki Page.
It is written in Coffescript V2 using native Promises and its only dependencies are bent and md5.js. You do not need Coffeescript to use the library; it is pre-compiled to Javascript ES6.
npm install coinex.com
Get your API key and secret key from here.
Coinex = require('coinex.com');
const API_KEY = 'F42F1492623D47EE861B7150E335AA89';
const SECRET = '8B678410AF2D46ABB70910D08E4DEAE114F014971E3A4759'
const coinex = new Coinex(API_KEY, SECRET);
coinex.balance()
.then(response => console.log(response));
.catch(err => console.error(err.code, err.message);
const coinex = new Coinex(API_KEY, SECRET);
All the following methods return native Promises which are resolved
on a valid response or rejected on error. Each method returns a
single result object to the .then()
.
For each method, please see the API documentation. Below
I have simply documented the call; the response will generally
be the data
part of the response as documented by Coinex.
If internally Coinex returns an error code of greater than zero,
the promise will be rejected with a CoinexError.
The returned result will have floating point numbers for values
rather than the string number values returned by the API. Where a
pair
is refered to below, it is the market, for example BTCBCH
.
Returns a list of the available pairs.
coinex.list()
Get the ticker information for a single pair.
coinex.ticker(pair)
Get the ticker information for all pairs.
coinex.tickerAll()
Get the buy / sell statistics. This will return up to 100 lines and the decimal places can be set between zero and eight.
coinex.depth(pair, [limit], [decimal-places]);
If not passed, limit
is set to 100 and decimal-places is set to
eight.
Get the latest transaction data. This will return up to 1,000 lines of data.
coinex.transactions(pair, [lastID]);
Get the k-line data for a specific period, including the last 1,000 data points.
coinex.kline(pair, [type]);
Type can be one of 1min
, 3min
, 5min
, 15min
, 30min
,
1hour
, 2hour
, 4hour
,6hour
,12hour
, 1day
, 3day
, 1week
.
Type defaults to 1hour
if not passed.
Returns the balance of each currency currently on the account.
coinex.balance()
Places a new order.
coinex.placeLimitOrder(pair, type, amount, price, [sourceID]);
Type must be buy
or sell
. SourceID is uptional and will be returned
in the response, if provided.
Places a new market order.
coinex.placeMarketOrder(pair, type, amount);
Cancels an existing order
coinex.cancelOrder(pair, id);
This will return a list of orders that have not been filled nor cancelled.
coinex.pending(pair, [page], [limit]);
Page defaults to one and limit defaults to 100. Using the result, it is possibe to page through many transactions.
This will return a list of closed orders. Note that fully cancelled orders will not appear here.
coinex.completed(pair, [page], [limit]);
This returns the status of a single order.
coinex.orderStatus(pair, id);
This returns the history of the user's deals for the given pair.
coinex.history(pair, [page], [limit]);
API errors are returned as a code and a description. In this library
they are returned as a class CoinexError
. These will work like
normal nodejs errors but should usually be caught with a .catch(err)
statement. For example:
coinex.cancelOrder('BTCBCH', 3242404);
.then(data => console.log(data));
.catch(err => console.error(err.code, err.message);
- v1.0.8 First fully working version
- v1.1.2 Dropped request (deprecated) in favor of bent
- v1.2.1 Using a custom version of bent to follow redirects
Please report any bugs or make any suggestions at the Github Issue page.