1.0.9 • Published 28 days ago

polyprice v1.0.9

Weekly downloads
-
License
MIT
Repository
-
Last release
28 days ago

Polyprice ⌚ : Real-time Crypto Price Tracker

Polyprice is a lightweight JavaScript library that tracks real-time prices of cryptocurrency pairs from centralized exchanges (CEX).

It allows users to add a list of cryptocurrency pairs and fetch their prices regularly from CEXs smartly and independently.

You don't have to worry about if your pairs are available on all the CEXes or even if they have the right format. (example : "USDT-BTC" will be handled correctly)

Why this library?

I hate API keys and I hate to reach the maximum requests allowed by a server in a timeframe. But, I want to be consistently provided with the latest price data for a given pair. (In an elegant way and for free).

Installation

yarn add polyprice

or

npm install polyprice

Usage:

import { Polyprice } from 'polyprice'

import LocalStorage from 'acey-node-store' //whatever local storage, could be the global "localStorage" in the browser

const poly = new PolyPrice({
    local_storage: new LocalStorage(DB_PATH), //to store the price history.
    interval_pair_price_request_ms: 60 * 1000 // 1 minute
})

//start the background process that refreshes the added pairs in the background.
poly.run()

//adding a pair
poly.addPair('BTC', 'USDT')
poly.addPair('ETH', 'USDT')
poly.addPair('LTC', 'USDT')

//remove a pair
poly.removePair('BTC', 'USDT')

//get pair last price
const pair = poly.findPair('BTC', 'USDT')
pair.lastPrice() // {cex:'binance', time: 1711864049, price: 70340.33}
1.0.2

29 days ago

1.0.9

28 days ago

1.0.8

28 days ago

1.0.7

28 days ago

1.0.6

28 days ago

1.0.5

29 days ago

1.0.4

29 days ago

1.0.3

29 days ago

1.0.1

1 month ago

1.0.0

1 month ago