Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
/ coinex.com Public archive

API Interface for coinex.com Bitcoin Cash exchange.

License

Notifications You must be signed in to change notification settings

CliffS/coinex.com

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

coinex.com

API Interface for coinex.com Bitcoin Cash exchange.

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.

Install

npm install coinex.com

Get your API key and secret key from here.

Example

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

Constructor

const coinex = new Coinex(API_KEY, SECRET);

Methods

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.

Market API

List Pairs

Returns a list of the available pairs.

coinex.list()

Get Market Data

Get the ticker information for a single pair.

coinex.ticker(pair)

Get All Ticker Data

Get the ticker information for all pairs.

coinex.tickerAll()

Get Market Depth

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.

Transaction Data

Get the latest transaction data. This will return up to 1,000 lines of data.

coinex.transactions(pair, [lastID]);

K-Line Data

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.

Account API

Get account balance

Returns the balance of each currency currently on the account.

coinex.balance()

Trading API

Place Limit Order

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.

Place Market Order

Places a new market order.

coinex.placeMarketOrder(pair, type, amount);

Cancel Order

Cancels an existing order

coinex.cancelOrder(pair, id);

List Pending Orders

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.

List Completed Orders

This will return a list of closed orders. Note that fully cancelled orders will not appear here.

coinex.completed(pair, [page], [limit]);

Order Status

This returns the status of a single order.

coinex.orderStatus(pair, id);

Deal History

This returns the history of the user's deals for the given pair.

coinex.history(pair, [page], [limit]);

Error Messages

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

Changes

  • 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

Issues

Please report any bugs or make any suggestions at the Github Issue page.

About

API Interface for coinex.com Bitcoin Cash exchange.

Resources

License

Stars

Watchers

Forks

Packages

No packages published