{"id":21961868,"url":"https://github.com/trapcodeio/cryptocurrency-price-kit","last_synced_at":"2025-10-16T17:08:51.129Z","repository":{"id":57210829,"uuid":"457975843","full_name":"trapcodeio/cryptocurrency-price-kit","owner":"trapcodeio","description":"The best price kit you need when working with crypto currencies with realtime and multiple providers support.","archived":false,"fork":false,"pushed_at":"2023-05-06T06:22:01.000Z","size":51,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-17T13:08:45.455Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trapcodeio.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-10T23:03:27.000Z","updated_at":"2024-07-09T18:12:33.000Z","dependencies_parsed_at":"2022-08-31T05:02:41.425Z","dependency_job_id":null,"html_url":"https://github.com/trapcodeio/cryptocurrency-price-kit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fcryptocurrency-price-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fcryptocurrency-price-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fcryptocurrency-price-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fcryptocurrency-price-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trapcodeio","download_url":"https://codeload.github.com/trapcodeio/cryptocurrency-price-kit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250506586,"owners_count":21441803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T10:19:25.629Z","updated_at":"2025-10-16T17:08:51.036Z","avatar_url":"https://github.com/trapcodeio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cryptocurrency Price Kit \n###### STAGE: `RFC`\nThe best Nodejs price kit you need when working with cryptocurrencies with multiple providers support.\n\n## Goal\n - To provide a simple and easy to use API for working with cryptocurrency prices.\n - To provide a simple API to support multiple data providers\n - To provide cache support, so you only send request to the provider once per minute.\n - To support as many providers as possible.\n\n## Installation\n```shell\nnpm install cryptocurrency-price-kit\n# OR\nyarn add cryptocurrency-price-kit\n```\n\n## Easy As\n\n```js\nconst {Cpk} = require('cryptocurrency-price-kit');\nconst BlockchainInfo = require(\"cryptocurrency-price-kit/providers/blockchain.info\");\nconst CoinGecko = require(\"cryptocurrency-price-kit/providers/coingecko.com\");\nconst LiveCoinWatch = require(\"cryptocurrency-price-kit/providers/livecoinwatch.com\");\n\n// Add Providers\nCpk.useProviders([\n    BlockchainInfo, // supports bitcoin only\n    CoinGecko, // supports almost all coins\n    LiveCoinWatch({apiKey: \"your-api-key\"}), // supports almost all coins\n])\n\n\nasync function Run(){\n  // Initialize\n  const blockchain = new Cpk('blockchain.info');\n  const coingecko = new Cpk('coingecko.com');\n  const livecoinwatch = new Cpk('livecoinwatch.com');\n  \n  // Get bitcoin Price and cache for 60 secs by default\n  const price = await blockchain.get('BTC');\n  // or with custom cache time\n  const price2 = await blockchain.get('BTC/EUR', 120); // seconds\n  \n  console.log(\"Blockchain - BTC/USD:\", price); // The current price of bitcoin in USD\n  console.log(\"Blockchain - BTC/EUR:\", price2); // The current price of bitcoin in USD\n  \n  // OR\n  // GET Many Prices and cache for 60 secs\n  const prices = await livecoinwatch.getMany(['BTC/USD', 'ETH/USD', \"BNB/USD\"], 60);\n  console.log('LiveCoinWatch - Many:', prices) // {BTC/USD: price, ETH/USD: price, BNB/USD: price}\n  \n  // Also supports using the symbol your provider supports\n  // e.g coingecko supports using code instead of symbol\n  // i.e `bitcoin` instead of `BTC`\n  const prices2 = await coingecko.getMany([\"BITCOIN/EUR\", \"ETHEREUM\", \"KADENA\"], 60);\n  console.log(\"CoinGecko: Many:\", prices2); // {BITCOIN/EUR: price, ETHEREUM/USD: price, KADENA/USD: price}\n}\n\nRun().catch(console.error);\n\n```\n\n### What you should know.\n- Default currency is `USD`\n- `cache` is enabled by default (tll: 60 seconds)\n- If currency is not defined, it will be `USD`\n- Error is thrown if request is not successful, so you should catch all requests.\n- We prefer `cache` over interval because it is more reliable. with `interval pulling` you may make unnecessary requests when not needed.\n\n### Supported providers\n\n- [livecoinwatch.com](https://livecoinwatch.com)\n- [blockchain.info](https://blockchain.info)\n- [coingecko.com](https://coingecko.com)\n- [coinmarketcap.com](https://coinmarketcap.com)\n\n#### Adding custom provider\nThis can be achieved in two ways.\n\n- Create an issue on GitHub requesting a certain provider, and we will try to add it. (`Try` if the provider documentation is clear enough.)\n- OR See how to create it yourself: [How to create a custom provider](#how-to-create-a-custom-provider)\n\n### What may come in the future.\n- Fallback to other providers if the first one fails.\n- Command line support: E.g. `npx cpk update-supported-data` should update the providers supported coins and currency array. \n      This is considered important because the majority of the providers have an endpoint where your can get the coins and currency they support.\n      \u003cbr\u003e if supported coins and currency are updated frequently, it will reduce the amount of error requests that may cost you depending on your provider.\n\n\n\n### How to create a custom provider\nCreating a custom provider is as easy as.\n\n```js\nconst {defineCpkProvider} = require(\"cryptocurrency-price-kit/src/provider\");\n\n// Define a provider\n// `config` is an object that contains the configuration passed for the provider.\nconst CustomProvider = defineCpkProvider((config) =\u003e {\n    return {\n       name: 'provider-domain.com',\n       coinsSupported: ['BTC', 'ETH'] || \"any\", // if any no validation is done\n       currenciesSupported: ['USD', 'EUR'] || \"any\", // if any no validation is done\n       \n       // This is the function that will be called to get the price\n       // It will be called with the coin and currency as arguments\n       // The async function should return the price\n       async getPrice(coin, currency) {\n           // return the price\n           return 0;\n       },\n       \n       // This is the function that will be called to get multiple prices\n       // It will be called with array of coins and currency as arguments\n       // The async function should return the prices as object\n       // The object should have the coin/key and the price as value\n       // E.g. {\"BTC/USD\": 0, \"ETH/EUR\": 0}\n       async getPrices(pairs) {\n           // return the prices\n           for (const pair of pairs) {\n               // pair.coin, pair.currency\n           }\n           return {};\n       }\n   }\n})\n\nmodule.exports = CustomProvider;\n```\nThat's all 😁, all cache function is handled by the package, so you don't need to worry about it.\nOnly return the values, and we will handle the rest.\n\n\n### Sponsor/support\nIf you like this project, you can support it. Any amount can keep the coffee going. 😁\n\n| Coin          | Address                                      |\n|---------------|----------------------------------------------|\n| BTC           | bc1q4el6ukfe0762rng62gw9augvq49evj3rxh6w09   |\n| ETH           | 0xb39bD9cF75BF29888cB80Cf374ee0822714E31a5   |\n| Solana        | BxcHDVsrk1Y9sX5vqskcMJDhHDT8HkqgYQdZGFMuZKPd |\n| Polygon Matic | 0x14033a7232232cf3c6a0671f00ad015df6a6c220   |\n\nIf you want to be listed as sponsor after sending a donation, please contact [hello@trapcode.io](mailto:hello@trapcode.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fcryptocurrency-price-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrapcodeio%2Fcryptocurrency-price-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fcryptocurrency-price-kit/lists"}