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

@atharvapatill/sol-price

v1.0.4

Published

A lightweight utility for fetching live Solana (SOL) prices, INR conversion, 24h change, and smart fallback caching.

Downloads

255

Readme

npm version npm downloads license

@atharvapatill/sol-price

Fetch real-time Solana (SOL) price in Indian Rupees (INR) from CoinGecko

Features

  • Real-time price from CoinGecko API
  • 24h price change optional
  • 30-second caching to avoid rate limits
  • Retry logic with exponential backoff (3 attempts)
  • Fallback price (₹20,000) on API failure
  • INR formatting with proper Indian number notation

Installation

npm install @atharvapatill/sol-price

Usage

ESM / TypeScript

import { getSolPrice, formatInr } from '@atharvapatill/sol-price';

CJS

const { getSolPrice, formatInr } = require('@atharvapatill/sol-price');

API

getSolPrice(options, config)

Fetches the current SOL price in INR from CoinGecko.

Parameters:

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | options.includeChange | boolean | false | Include 24h price change | | config.forceRefresh | boolean | false | Bypass cache and fetch fresh |

Returns:

// Basic
{ price: number }

// With includeChange: true
{ price: number, change24h: number }

Example:

// Basic usage
const { price } = await getSolPrice();
// price = 168542.50

// With 24h change
const { price, change24h } = await getSolPrice({ includeChange: true });
// price = 168542.50
// change24h = 2.34

// Force fresh fetch (bypass cache)
const { price } = await getSolPrice({}, { forceRefresh: true });

formatInr(value)

Formats a number as Indian Rupee currency string.

Parameters:

| Parameter | Type | Description | |-----------|------|-------------| | value | number \| null \| undefined | Number to format |

Returns: string

Example:

formatInr(168542.5);   // "₹1,68,542.50"
formatInr(1000);       // "₹1,000.00"
formatInr(0);          // "₹0.00"
formatInr(null);      // "—"
formatInr(undefined);  // "—"

clearCache()

Clears the internal price cache. Useful for testing.

import { clearCache } from '@atharvapatill/sol-price';
clearCache();

Caching

The package caches the last fetched price for 30 seconds to avoid hitting CoinGecko's rate limit. Subsequent calls within this window return the cached value.

To force a fresh fetch, use:

await getSolPrice({}, { forceRefresh: true });

Error Handling

If CoinGecko API fails after 3 retries, the package returns a fallback price of ₹20,000 so your app doesn't break.

const { price } = await getSolPrice();
// Returns 20000 if API is down

Rate Limits

CoinGecko's free API has rate limits (~10-30 calls/minute). The built-in 30-second cache helps stay within limits, but for high-frequency use consider:

  • Using the cache (default behavior)
  • Implementing your own debounce/throttle layer
  • Upgrading to a paid CoinGecko plan

License

MIT