Code Monkey home page Code Monkey logo

ccex-api's Introduction

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 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 datafeed, private rest api with api/secret key...

Sample

  • Angular sample
  • Webpack typescript (future)
  • Rollup typescript (future)

Supported Exchanges

Binance, Bitbank, Bitfinex, Coinbase (Gdax)

id name ver doc countries
Binance binance Binance * API Japan
Bitbank bitbank Bitbank 1 API Japan
Bitfinex bitfinex Bitfinex v2 2 API British Virgin Islands
Coinbase coinbase Coinbase * API US

Modular structure

When you include a module you also include all of its dependencies

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

Terminology

  • Pair (market/symbol): must have the following format btc_usd (lowercase with underscore between 2 asset)

Api

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

api params return value desctiption
exchangeInfo ExchangeInfo
markets string[] All supported markets (pair)
representativeMarkets string[] Major supported markets (used for test purpose)
supportFeatures SupportFeatures
fetchTicker$ pair: string Observable<Ticker> api request for ticker
ticker$ pair: string Observable<Ticker> realtime ticker stream
stopTicker stop realtime ticker stream
fetchTrades$ pair: string Observable<Trade> api request for trade
trade$ pair: string Observable<Trade> realtime trade stream
stopTrade stop realtime trade stream
fetchOrderbook$ pair: string Observable<Orderbook> api request for orderbook
orderbook$ pair: string Observable<Orderbook> realtime orderbook stream
stopOrderbook stop 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 (future)

Contributor 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 (future)

Finally make sure the exchange sample pass predefined test by running (future)

npm run main-test --exchange 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 (future)

main test: test for main module which implement the above interface directly

npm run main-test

sub test: test for sub-modules used inside main module and its internal functions

npm run sub-test

Dependencies

This library is built strongly on top of Rxjs (v6 or above)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.