Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ccex-api

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ccex-api

Crypto currencies exchanges api implementation using typescript and rxjs

  • 0.0.17
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
decreased by-68.29%
Maintainers
1
Weekly downloads
 
Created
Source

CircleCI Build Status

ccex-api

Cryptocurrency exchanges client api wrapper.

Features

These features are supported with all major exchanges

  • Public realtime api.
  • Public rest api.
  • Support for both Nodejs and Browser (Webpack, React, Angular...see samples below) environments.
  • Modular structure make sure you include minimum code as you need (especially for client side application).
  • Option to bypass cors request problem in browser with proxy.
  • More to come: Tradingview realtime datafeed, private rest api with api/secret key...

Prequisite

  • Using crypto to sign private request requrie node 10.
  • This library is built on top of Typescript and Rxjs (v6). All async functions will return an observable stream so familiar with Rxjs would be an advantage but basically using stream .subscribe((data) => {/**/}) method should be sufficient. You can also easily turn an one-time-complete observable (rest API request) into promise using .toPromise() to be used with async await.

Sample

Supported Exchanges

Binance, Bitbank, Bitfinex, Coinbase

id/docshomepageversionorigincountry
BinancebinanceBinance*APIChina
BitbankbitbankBitbank*APIJapan
BitfinexbitfinexBitfinex2APIBritish Virgin Islands
CoinbasecoinbaseCoinbase*APIUS

Roadmap (TODO)

TaskDateStatus
Binance Private User Data Stream2018/09:white_check_mark:
Binance Private Api2018/12
Bitbank, Bitifnex, Coinbase private stream2019/Q1
Huobi, Okex2019/Q1
More exchanges2019/Q2
Python and Go version2019/Q3, Q4

Usage

This library is designed to be usable in both nodejs and browser (with frontend framework like Angular, React, Vue..., with bundle tools like Webpack or Rollup having typescript configured, the umd javascript file coming later) environments.

When used in browser environment, the browser must support for native

Installation

npm i --save ccex-api

Simple use

import { BinanceApi } from 'ccex-api/exchanges/binance;

const binanceApi = new BinanceApi();

binanceApi.fetchTicker$('btc_usdt').subscribe(ticker => console.log(ticker));
binanceApi.ticker$('btc_usdt').subscribe(ticker => console.log(ticker));
setTimeout(() => { binanceApi.stopTicker('btc_usdt') }, 5000);

Or you can include only the part that you need

import { BitbankCandlestick } from 'ccex-api/exchanges/bitbank/candlestick;

const bitbankCandlestick = new BitbankCandlestick();
bitbankCandlestick.getApproximateHistoryPrice('btc_jpy', 1526917534904, 1).subscribe(price => console.log(price));

Api

Basically all exchanges have these following unified, generalized api implemented.

apiparamsreturn valuedesctiption
exchangeInfoExchangeInfo
marketsstring[]All supported markets (pair)
representativeMarketsstring[]Major supported markets (used for test purpose)
supportFeaturesSupportFeatures
fetchTicker$pair: stringObservable<Ticker>api request for ticker
ticker$pair: stringObservable<Ticker>realtime ticker stream
stopTickerpair: stringstop realtime ticker stream
fetchTrades$pair: stringObservable<Trade>api request for trade
trade$pair: stringObservable<Trade>realtime trade stream
stopTradepair: stringstop realtime trade stream
fetchOrderbook$pair: stringObservable<Orderbook>api request for orderbook
orderbook$pair: stringObservable<Orderbook>realtime orderbook stream
stopOrderbookpair: stringstop realtime orderbook stream
fetchCandleStickRange$pair: string
minutesFoot: number
start: number
end: number
Observable<CandleStick[]>api request for candlestick
lastCandle$pair: string
minutesFoot: number
lastCandle: CandleStick
Observable<CandleStick>Realtime candlestick stream, calculated from an initial lastCandle and realtime trade stream.
This function is useful in implementing Tradingview datafeed

Besides, an exchange may have more specific functions, it depends on exchange provided features and implementation. In that case, specific guide for that exchange will be located at exchanges/{exchange}/README.md (TODO)

Contribution guide

In order to add a new exchange, simply clone folder src/exchanges/sample, rename, implement functions and include appropiate tests for sub-modules (ticker, orderbook...) and some internal functions.

Finally make sure the exchange sample pass predefined test by running

npm run test sample

If you find a bug or anything should be added to fit your need, please create issue. This is still in very early stage so any feedback would be much appreciated.

Test

We can test all or 1 specific exchange. Note that a realtime test can fail by timeout according to server data stream coming late.

Test all

npm run test

Test specific exchanage

npm run test binance
npm run test bitbank

Dependencies

Keywords

FAQs

Package last updated on 17 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc