{"_id":"@atharvapatill/sol-price","_rev":"2-ccd741f2012a6bb7210a7c037a970cae","name":"@atharvapatill/sol-price","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@atharvapatill/sol-price","version":"1.0.0","keywords":["solana","sol","inr","price","crypto","currency"],"license":"MIT","_id":"@atharvapatill/sol-price@1.0.0","maintainers":[{"name":"atharvapatill","email":"atharvaspatil2005@gmail.com"}],"dist":{"shasum":"c46b3015a672ad75f77ef779fd6aeaf5ea445156","tarball":"https://registry.npmjs.org/@atharvapatill/sol-price/-/sol-price-1.0.0.tgz","fileCount":6,"integrity":"sha512-XQO5HWmaLtmGkhyOpKyCGWlhYrqbso96IkvPaOxi2nR/bWNhkPizyixcFwoZlIGSBonT+/z9XQ7SelKHTk/zyA==","signatures":[{"sig":"MEQCIB/qyV3qJ2D86R8/b76FtZn5GoQLczpA3w6K/zTjJ2fcAiBxUyt9bHLxzw6YfisTxIroF3BKYTHVzelbdJB+xb8+NA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9610},"main":"dist/index.cjs.js","type":"module","module":"dist/index.esm.js","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"}},"gitHead":"0b7654a3b9b1e7b82fdf763a7f6ca22780e120ca","scripts":{"test":"vitest","build":"vite build","prepublishOnly":"npm run test && npm run build"},"_npmUser":{"name":"atharvapatill","email":"atharvaspatil2005@gmail.com"},"_npmVersion":"11.5.1","description":"Fetch real-time Solana (SOL) price in Indian Rupees (INR) from CoinGecko","directories":{},"_nodeVersion":"24.7.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^8.0.3","vitest":"^4.1.2"},"_npmOperationalInternal":{"tmp":"tmp/sol-price_1.0.0_1775137535046_0.766164384831711","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@atharvapatill/sol-price","version":"1.0.4","description":"A lightweight utility for fetching live Solana (SOL) prices, INR conversion, 24h change, and smart fallback caching.","main":"dist/index.cjs.js","module":"dist/index.esm.js","type":"module","exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.cjs.js"}},"repository":{"type":"git","url":"git+https://github.com/Atharvapatil2005/solana_wallet.git"},"homepage":"https://github.com/Atharvapatil2005/solana_wallet#readme","scripts":{"build":"vite build","test":"vitest run","prepublishOnly":"npm run test && npm run build"},"keywords":["solana","sol-price","crypto-price","coingecko","price-feed","inr","currency-formatter","web3","defi","npm-package"],"license":"MIT","devDependencies":{"vite":"^8.0.3","vitest":"^4.1.2"},"_id":"@atharvapatill/sol-price@1.0.4","gitHead":"848fb57d755a3119034fff1222ccf35b73970154","bugs":{"url":"https://github.com/Atharvapatil2005/solana_wallet/issues"},"_nodeVersion":"24.7.0","_npmVersion":"11.5.1","dist":{"integrity":"sha512-kM318KcffBdf3/ipF/uc2PG+WdUZHXvjrCCJzJDhuXEOVX2eP0C0sRn/TpxtSyn9eBues2/wbCq6NO2HuzkTeA==","shasum":"d34242c230872f155d25ecf7aa1c6321690b5b4d","tarball":"https://registry.npmjs.org/@atharvapatill/sol-price/-/sol-price-1.0.4.tgz","fileCount":6,"unpackedSize":10264,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIH6T+tglNVXsVIPH2nE4pNb/P2nxfAfUuP40wM+B12pbAiB0D6jx3BYw5oZ/L2gzUyQJdMdw6zuo+3hTA5BeZnP/fg=="}]},"_npmUser":{"name":"atharvapatill","email":"atharvaspatil2005@gmail.com"},"directories":{},"maintainers":[{"name":"atharvapatill","email":"atharvaspatil2005@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sol-price_1.0.4_1775186061692_0.9580509595975499"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-02T13:45:34.984Z","modified":"2026-04-03T03:14:21.930Z","1.0.0":"2026-04-02T13:45:35.200Z","1.0.4":"2026-04-03T03:14:21.824Z"},"license":"MIT","keywords":["solana","sol-price","crypto-price","coingecko","price-feed","inr","currency-formatter","web3","defi","npm-package"],"description":"A lightweight utility for fetching live Solana (SOL) prices, INR conversion, 24h change, and smart fallback caching.","maintainers":[{"name":"atharvapatill","email":"atharvaspatil2005@gmail.com"}],"readme":"[![npm version](https://img.shields.io/npm/v/@atharvapatill/sol-price)](https://www.npmjs.com/package/@atharvapatill/sol-price)\n[![npm downloads](https://img.shields.io/npm/dm/@atharvapatill/sol-price)](https://www.npmjs.com/package/@atharvapatill/sol-price)\n[![license](https://img.shields.io/npm/l/@atharvapatill/sol-price)](LICENSE)\n# @atharvapatill/sol-price\n\n> Fetch real-time Solana (SOL) price in Indian Rupees (INR) from CoinGecko\n\n## Features\n\n- **Real-time price** from CoinGecko API\n- **24h price change** optional\n- **30-second caching** to avoid rate limits\n- **Retry logic** with exponential backoff (3 attempts)\n- **Fallback price** (₹20,000) on API failure\n- **INR formatting** with proper Indian number notation\n\n## Installation\n\n```bash\nnpm install @atharvapatill/sol-price\n```\n\n## Usage\n\n### ESM / TypeScript\n\n```javascript\nimport { getSolPrice, formatInr } from '@atharvapatill/sol-price';\n```\n\n### CJS\n\n```javascript\nconst { getSolPrice, formatInr } = require('@atharvapatill/sol-price');\n```\n\n## API\n\n### `getSolPrice(options, config)`\n\nFetches the current SOL price in INR from CoinGecko.\n\n**Parameters:**\n\n| Parameter | Type | Default | Description |\n|-----------|------|---------|-------------|\n| `options.includeChange` | `boolean` | `false` | Include 24h price change |\n| `config.forceRefresh` | `boolean` | `false` | Bypass cache and fetch fresh |\n\n**Returns:**\n\n```typescript\n// Basic\n{ price: number }\n\n// With includeChange: true\n{ price: number, change24h: number }\n```\n\n**Example:**\n\n```javascript\n// Basic usage\nconst { price } = await getSolPrice();\n// price = 168542.50\n\n// With 24h change\nconst { price, change24h } = await getSolPrice({ includeChange: true });\n// price = 168542.50\n// change24h = 2.34\n\n// Force fresh fetch (bypass cache)\nconst { price } = await getSolPrice({}, { forceRefresh: true });\n```\n\n---\n\n### `formatInr(value)`\n\nFormats a number as Indian Rupee currency string.\n\n**Parameters:**\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| `value` | `number \\| null \\| undefined` | Number to format |\n\n**Returns:** `string`\n\n**Example:**\n\n```javascript\nformatInr(168542.5);   // \"₹1,68,542.50\"\nformatInr(1000);       // \"₹1,000.00\"\nformatInr(0);          // \"₹0.00\"\nformatInr(null);      // \"—\"\nformatInr(undefined);  // \"—\"\n```\n\n---\n\n### `clearCache()`\n\nClears the internal price cache. Useful for testing.\n\n```javascript\nimport { clearCache } from '@atharvapatill/sol-price';\nclearCache();\n```\n\n## Caching\n\nThe 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.\n\nTo force a fresh fetch, use:\n\n```javascript\nawait getSolPrice({}, { forceRefresh: true });\n```\n\n## Error Handling\n\nIf CoinGecko API fails after 3 retries, the package returns a **fallback price of ₹20,000** so your app doesn't break.\n\n```javascript\nconst { price } = await getSolPrice();\n// Returns 20000 if API is down\n```\n\n## Rate Limits\n\nCoinGecko'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:\n\n- Using the cache (default behavior)\n- Implementing your own debounce/throttle layer\n- Upgrading to a paid CoinGecko plan\n\n## License\n\nMIT\n","readmeFilename":"README.md","homepage":"https://github.com/Atharvapatil2005/solana_wallet#readme","repository":{"type":"git","url":"git+https://github.com/Atharvapatil2005/solana_wallet.git"},"bugs":{"url":"https://github.com/Atharvapatil2005/solana_wallet/issues"}}