2.1.17 β€’ Published 1 month ago

@coinsamba/js-exchanges-connector v2.1.17

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

js-exchanges-connector

An open source JavaScript library for fetching cryptocurrency exchanges

Instalation

yarn add @coinsamba/js-exchanges-connector

or

npm i @coinsamba/js-exchanges-connector

Usage

Before using the library you need to create a class to fetch the data, you can use the code below as an example

import {
  FetcherHandler,
} from "@coinsamba/js-exchanges-connector";
import {
  FetcherArgs,
  FetcherRequisitionMethods,
  ICustomFetcher,
} from "@coinsamba/js-exchanges-connector/types";
import Axios, { AxiosError } from "axios";

export class MyFetcher implements ICustomFetcher {
  private parseAxiosError(e: AxiosError) {
    let message = `E - ${e.code}`;
    if (e.response) {
      message += ` - ${e.response.status} - ${e.config!.url} ${
        typeof e.response.data === "object"
          ? `- ${JSON.stringify(e.response.data)}`
          : ""
      }`;
    } else {
      message += ` - ${e.config!.url}`;
    }
    return new Error(message);
  }

  // fetch must handle with get and post methods
  // must be able to receive string paramter and handle as GET method
  async fetch<ResponseType>(args: FetcherArgs): Promise<ResponseType> {
    try {
      if (typeof args == "string") {
        const { data } = await Axios.get<ResponseType>(args);
        return data;
      } else {
        const { data } = await Axios.request<ResponseType>({
          headers: args.headers,
          url: args.url,
          method: args.method,
          [args.method === FetcherRequisitionMethods.GET ? "params" : "data"]:
            args.data,
        });
        return data;
      }
    } catch (error: any) {
      throw this.parseAxiosError(error as unknown as AxiosError);
    }
  }
}


FetcherHandler.setFetcher(new MyFetcher());

Import your favorite exchange connector

import { bitpreco } from '@coinsamba/js-exchanges-connector';

Getters: all connectors have this same getters used to verify if the connector have an implementation of desired method.

/**
 * will return true if this exchange has the method that return all tickers with all available quote
 */
console.log(bitpreco.hasAllTickers);

/**
 * will return true if this exchange has the method that return all tickers with specific quote as argument
 */
console.log(bitpreco.hasAllTickersByQuote);
import { pagcripto, binance } from '@coinsamba/js-exchanges-connector';

pagcripto.getTicker('BTC', 'BRL').then(ticker => console.log(ticker));
// will return the ticker in the specified market
// {
//     exchangeId: "pagcripto",
//     base: "BTC",
//     quote: "BRL",
//     last: 100000,
//     ask: 100000,
//     bid: 100000,
//     vol: 16,
// }

pagcripto.getBook('BTC', 'BRL').then(book => console.log(book));
// will return orderbook of specified market
// {
//     asks: [{price: 1000, amount: 1}],
//     bids: [{price: 1000, amount: 1}],
// }


pagcripto.getAllTickersByQuote('BRL').then(tickers => console.log(tickers));
// will return all tickers in the specified market
// [
//     {
//         exchangeId: "pagcripto",
//         base: "BTC",
//         quote: "BRL",
//         last: 100000,
//         ask: 100000,
//         bid: 100000,
//         vol: 16,
//     },
//     {
//         exchangeId: "pagcripto",
//         base: "ETH",
//         quote: "BRL",
//         last: 100000,
//         ask: 100000,
//         bid: 100000,
//         vol: 16,
//     }
// ]


binance.getAllTickers().then(tickers => console.log(tickers));
// will return all tickers in all markets
// [
//     {
//         exchangeId: "binance",
//         base: "BTC",
//         quote: "BRL",
//         last: 100000,
//         ask: 100000,
//         bid: 100000,
//         vol: 16,
//     },
//     {
//         exchangeId: "binance",
//         base: "ETH",
//         quote: "BTC",
//         last: 100000,
//         ask: 100000,
//         bid: 100000,
//         vol: 16,
//     }
// ]

Who is using?

  • Coinsamba

Implementations

idgetTickergetAllTickersgetAllTickersByQuotegetBook
alterbank πŸ‡§πŸ‡·11
binance_us πŸ‡ΊπŸ‡Έ111
binance 🌐111
bisq 🌐11
bitbay11
bitblue πŸ‡§πŸ‡·11
bitcointoyou πŸ‡§πŸ‡·11
bitcointrade πŸ‡§πŸ‡·11
bitget 🌐11
bitmonedero πŸ‡¦πŸ‡·11
bitnuvem πŸ‡§πŸ‡·11
bitpreco πŸ‡§πŸ‡·111
bitrecife πŸ‡§πŸ‡·111
bitso πŸ‡²πŸ‡½11
bitstamp11
bittrex 🌐111
bleutrade πŸ‡§πŸ‡·111
blocktane πŸ‡§πŸ‡·1
brasilbitcoin πŸ‡§πŸ‡·11
buda πŸ‡¨πŸ‡΄πŸ‡΅πŸ‡ͺπŸ‡¦πŸ‡·πŸ‡¨πŸ‡±11
bullgain πŸ‡§πŸ‡·111
cexio 🌐111
citcoin πŸ‡§πŸ‡·11
coinbase_pro11
coinbene 🌐11
coinext πŸ‡§πŸ‡·111
coinsbank 🌐11
comprarbitcoin πŸ‡§πŸ‡·111
cryptomarket πŸ‡¦πŸ‡·11
decrypto πŸ‡¦πŸ‡·1
exmo 🌐111
flowbtc πŸ‡§πŸ‡·111
foxbit πŸ‡§πŸ‡·111
ftx 🌐11
gateio 🌐111
isbit πŸ‡²πŸ‡½11
isistrade πŸ‡§πŸ‡·11
kraken 🌐11
kucoin 🌐111
liqi πŸ‡§πŸ‡·111
luno πŸ‡ΏπŸ‡¦11
mercadobitcoin πŸ‡§πŸ‡·111
novadax πŸ‡§πŸ‡·111
noxbitcoin πŸ‡§πŸ‡·1
pagcripto_otc πŸ‡§πŸ‡·11
pagcripto πŸ‡§πŸ‡·111
paxos 🌐11
poloniex 🌐111
quidax πŸ‡³πŸ‡¬11
satoshitango πŸ‡¦πŸ‡·11
stonoex πŸ‡§πŸ‡·111
upcambio πŸ‡§πŸ‡·11

Known Whitelabel Platforms

  • alphapoint
  • bnb
  • bws
  • kfex
  • peatio
  • upex
2.1.17

1 month ago

2.1.16

2 months ago

2.1.15

2 months ago

2.0.3

9 months ago

2.0.2

9 months ago

2.0.5

9 months ago

2.0.7

9 months ago

2.0.6

9 months ago

2.0.9

9 months ago

2.0.8

9 months ago

2.0.1

9 months ago

2.0.0

10 months ago

2.1.9

8 months ago

2.1.14

6 months ago

2.1.12

6 months ago

2.1.13

6 months ago

2.1.10

6 months ago

2.1.11

6 months ago

2.1.2

9 months ago

2.1.1

9 months ago

2.1.4

9 months ago

2.1.3

9 months ago

2.1.6

9 months ago

2.1.5

9 months ago

2.1.8

9 months ago

2.1.7

9 months ago

2.1.0

9 months ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.2.8

2 years ago

1.1.9

2 years ago

1.2.7

2 years ago

1.1.8

2 years ago

1.2.6

2 years ago

1.1.7

2 years ago

1.2.5

2 years ago

1.1.6

2 years ago

1.2.4

2 years ago

1.1.5

2 years ago

1.2.3

2 years ago

1.1.4

2 years ago

1.3.1

2 years ago

1.2.2

2 years ago

1.1.3

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

1.2.9

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.0

2 years ago