npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

crypto-price-fetcher-v2

v1.0.5

Published

Fetch real-time cryptocurrency prices from DEX pools via public RPCs

Downloads

604

Readme

crypto-price-fetcher-v2

npm version npm downloads License: MIT

Fetch real-time cryptocurrency prices directly from DEX pools via public RPCs. No API keys required.

Features

  • 🔗 On-chain prices - Fetches directly from Uniswap V3, PancakeSwap V3, and DexScreener
  • Fast & lightweight - Single dependency (viem)
  • 🔒 No API keys - Uses public RPCs
  • 📦 TypeScript first - Full type definitions included

Supported Chains

| Chain | Token | Source | |-------|-------|--------| | Ethereum | ETH | Uniswap V3 Quoter | | BSC | BNB | PancakeSwap V3 Quoter | | Base | ETH | Uniswap V3 Quoter | | Solana | SOL | DexScreener API |

Installation

npm install crypto-price-fetcher-v2
# or
yarn add crypto-price-fetcher-v2
# or
bun add crypto-price-fetcher-v2

Quick Start

import { getETHPrice, getBNBPrice, getSOLPrice, getAllPrices } from 'crypto-price-fetcher-v2';

// Get individual prices
const ethPrice = await getETHPrice();
console.log(`ETH: $${ethPrice}`);

const bnbPrice = await getBNBPrice();
console.log(`BNB: $${bnbPrice}`);

const solPrice = await getSOLPrice();
console.log(`SOL: $${solPrice}`);

// Get all prices at once
const prices = await getAllPrices();
console.log(prices);

API Reference

Functions

| Function | Returns | Description | |----------|---------|-------------| | getETHPrice(options?) | Promise<number> | ETH price in USD (Ethereum) | | getBNBPrice(options?) | Promise<number> | BNB price in USD (BSC) | | getSOLPrice() | Promise<number> | SOL price in USD (Solana) | | getBaseETHPrice(options?) | Promise<number> | ETH price in USD (Base) | | getPrice(chain, options?) | Promise<PriceResult> | Price for specific chain | | getAllPrices(options?) | Promise<Record<ChainId, PriceResult>> | All chain prices |

Custom RPC URLs

import { getETHPrice, getAllPrices } from 'crypto-price-fetcher-v2';

// Use your own RPC for better reliability
const ethPrice = await getETHPrice({
    rpcUrls: {
        ethereum: 'https://your-ethereum-rpc.com',
    }
});

// Custom RPCs for all chains
const prices = await getAllPrices({
    rpcUrls: {
        ethereum: 'https://your-eth-rpc.com',
        bsc: 'https://your-bsc-rpc.com',
        base: 'https://your-base-rpc.com',
    }
});

Types

type ChainId = 'ethereum' | 'bsc' | 'base' | 'solana';

interface PriceResult {
    chain: ChainId;
    symbol: string;
    price: number;
    timestamp: number;
}

interface FetchOptions {
    rpcUrls?: Partial<Record<ChainId, string>>;
    chainConfigs?: Partial<Record<ChainId, Partial<ChainConfig>>>;
}

How It Works

  • EVM Chains: Uses on-chain Quoter V2 contracts (Uniswap/PancakeSwap) to simulate swaps and get real-time prices
  • Solana: Uses DexScreener's aggregated API which sources data from on-chain DEXes

Changelog

v1.0.5

  • Fixed exports mapping in package.json to correctly resolve imports

v1.0.4

  • Improved dependency management
  • Updated documentation

v1.0.3

  • Updated repository URLs to match new repo name
  • Improved documentation

v1.0.2

  • Moved viem to direct dependencies (no manual install required)
  • Updated documentation

v1.0.1

  • Added repository info for GitHub linking
  • Improved documentation

v1.0.0

  • Initial release
  • Support for Ethereum, BSC, Base, and Solana
  • Custom RPC URL support
  • TypeScript definitions

Contributing

Contributions are welcome! Please open an issue or submit a PR on GitHub.

License

MIT © 2024