You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🔷 Full TypeScript - Complete type definitions included
🔄 Backwards Compatible - Both class-based and function exports
Installation
npm install @nirholas/crypto-market-data
# or
yarn add @nirholas/crypto-market-data
# or
pnpm add @nirholas/crypto-market-data
Quick Start
import{MarketDataClient}from'@nirholas/crypto-market-data';constclient=newMarketDataClient();// Get market overviewconstoverview=awaitclient.getMarketOverview();console.log(`BTC: $${overview.btcPrice}`);console.log(`ETH: $${overview.ethPrice}`);console.log(`Fear & Greed: ${overview.fearGreed?.value} (${overview.fearGreed?.value_classification})`);// Get top coinsconstcoins=awaitclient.getTopCoins(10);coins.forEach(coin=>{console.log(`${coin.name}: $${coin.current_price} (${coin.price_change_percentage_24h}%)`);});
API Reference
Initialization
import{MarketDataClient,typeMarketDataConfig}from'@nirholas/crypto-market-data';constconfig: MarketDataConfig={rateLimitWindow: 60000,// Rate limit window in ms (default: 60000)maxRequestsPerWindow: 25,// Max requests per window (default: 25)timeout: 10000,// Request timeout in ms (default: 10000)userAgent: 'MyApp/1.0',// Custom User-Agent};constclient=newMarketDataClient(config);
constoverview=awaitclient.getMarketOverview();console.log('Market Overview:');console.log(` Total Market Cap: $${formatNumber(overview.global.total_market_cap.usd)}`);console.log(` 24h Volume: $${formatNumber(overview.global.total_volume.usd)}`);console.log(` BTC Dominance: ${overview.global.market_cap_percentage.btc?.toFixed(1)}%`);console.log(` Fear & Greed: ${overview.fearGreed?.value} (${overview.fearGreed?.value_classification})`);
Get Historical Price Chart Data
// Get 7 days of hourly dataconsthistorical=awaitclient.getHistoricalPrices('bitcoin',7,'hourly');historical.prices.forEach(([timestamp,price])=>{constdate=newDate(timestamp);console.log(`${date.toLocaleDateString()}: $${price.toFixed(2)}`);});