@coinsamba/js-exchanges-connector v2.1.17
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
id | getTicker | getAllTickers | getAllTickersByQuote | getBook |
---|---|---|---|---|
alterbank π§π· | 1 | 1 | ||
binance_us πΊπΈ | 1 | 1 | 1 | |
binance π | 1 | 1 | 1 | |
bisq π | 1 | 1 | ||
bitbay | 1 | 1 | ||
bitblue π§π· | 1 | 1 | ||
bitcointoyou π§π· | 1 | 1 | ||
bitcointrade π§π· | 1 | 1 | ||
bitget π | 1 | 1 | ||
bitmonedero π¦π· | 1 | 1 | ||
bitnuvem π§π· | 1 | 1 | ||
bitpreco π§π· | 1 | 1 | 1 | |
bitrecife π§π· | 1 | 1 | 1 | |
bitso π²π½ | 1 | 1 | ||
bitstamp | 1 | 1 | ||
bittrex π | 1 | 1 | 1 | |
bleutrade π§π· | 1 | 1 | 1 | |
blocktane π§π· | 1 | |||
brasilbitcoin π§π· | 1 | 1 | ||
buda π¨π΄π΅πͺπ¦π·π¨π± | 1 | 1 | ||
bullgain π§π· | 1 | 1 | 1 | |
cexio π | 1 | 1 | 1 | |
citcoin π§π· | 1 | 1 | ||
coinbase_pro | 1 | 1 | ||
coinbene π | 1 | 1 | ||
coinext π§π· | 1 | 1 | 1 | |
coinsbank π | 1 | 1 | ||
comprarbitcoin π§π· | 1 | 1 | 1 | |
cryptomarket π¦π· | 1 | 1 | ||
decrypto π¦π· | 1 | |||
exmo π | 1 | 1 | 1 | |
flowbtc π§π· | 1 | 1 | 1 | |
foxbit π§π· | 1 | 1 | 1 | |
ftx π | 1 | 1 | ||
gateio π | 1 | 1 | 1 | |
isbit π²π½ | 1 | 1 | ||
isistrade π§π· | 1 | 1 | ||
kraken π | 1 | 1 | ||
kucoin π | 1 | 1 | 1 | |
liqi π§π· | 1 | 1 | 1 | |
luno πΏπ¦ | 1 | 1 | ||
mercadobitcoin π§π· | 1 | 1 | 1 | |
novadax π§π· | 1 | 1 | 1 | |
noxbitcoin π§π· | 1 | |||
pagcripto_otc π§π· | 1 | 1 | ||
pagcripto π§π· | 1 | 1 | 1 | |
paxos π | 1 | 1 | ||
poloniex π | 1 | 1 | 1 | |
quidax π³π¬ | 1 | 1 | ||
satoshitango π¦π· | 1 | 1 | ||
stonoex π§π· | 1 | 1 | 1 | |
upcambio π§π· | 1 | 1 |
Known Whitelabel Platforms
- alphapoint
- bnb
- bws
- kfex
- peatio
- upex
1 month ago
2 months ago
2 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
8 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago