{"id":22173122,"url":"https://github.com/knutkirkhorn/btc-value","last_synced_at":"2025-07-26T15:31:13.191Z","repository":{"id":45954570,"uuid":"113592781","full_name":"knutkirkhorn/btc-value","owner":"knutkirkhorn","description":"💸 Get the current Bitcoin value","archived":false,"fork":false,"pushed_at":"2023-03-09T21:32:48.000Z","size":357,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-29T04:12:00.249Z","etag":null,"topics":["bitcoin","btc","cryptocurrency","nodejs","value"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knutkirkhorn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-08T16:09:05.000Z","updated_at":"2021-11-24T20:48:55.000Z","dependencies_parsed_at":"2024-06-20T23:37:52.004Z","dependency_job_id":null,"html_url":"https://github.com/knutkirkhorn/btc-value","commit_stats":{"total_commits":135,"total_committers":4,"mean_commits":33.75,"dds":"0.051851851851851816","last_synced_commit":"8b31905387b0bf1f78e363bcd8405ccc1f1b429d"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutkirkhorn%2Fbtc-value","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutkirkhorn%2Fbtc-value/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutkirkhorn%2Fbtc-value/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knutkirkhorn%2Fbtc-value/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knutkirkhorn","download_url":"https://codeload.github.com/knutkirkhorn/btc-value/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227689947,"owners_count":17804814,"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":["bitcoin","btc","cryptocurrency","nodejs","value"],"created_at":"2024-12-02T07:30:33.167Z","updated_at":"2024-12-02T07:31:16.468Z","avatar_url":"https://github.com/knutkirkhorn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n\t\u003cbr\u003e\n\t\u003cbr\u003e\n\t\u003cimg width=\"360\" src=\"https://raw.githubusercontent.com/knutkirkhorn/btc-value/main/media/logo.svg\" alt=\"btc-value\"\u003e\n\t\u003cbr\u003e\n\t\u003cbr\u003e\n\t\u003cbr\u003e\n\u003c/h1\u003e\n\n\u003e Get the current Bitcoin value\n\n[![Downloads](https://img.shields.io/npm/dm/btc-value.svg)](https://www.npmjs.com/package/btc-value) [![Coverage Status](https://codecov.io/gh/knutkirkhorn/btc-value/branch/main/graph/badge.svg)](https://codecov.io/gh/knutkirkhorn/btc-value)\n\n## Installation\n\n```\nnpm install btc-value\n```\n\n## Usage\n\n```js\nimport btcValue, {\n\tsetProvider,\n\tsetApiKey,\n\tgetPercentageChangeLastDay,\n\tgetSupportedCurrencies\n} from 'btc-value';\n\n// Set the value provider\nsetProvider('coingecko');\n\n// Set the API key\nsetApiKey('example-cmc-API-key');\n\n// Print the current value of Bitcoin in USD\nconsole.log(`$${await btcValue()}`);\n// =\u003e e.g. $11048\n\n// Print the current value of Bitcoin in NOK (Norwegian krone)\nconsole.log(`kr ${await btcValue('NOK')}`);\n// =\u003e e.g. kr 86664\n\n// Print the current value of 2.2 BTC in USD\nconsole.log(`$${await btcValue({quantity: 2.2})}`);\n// =\u003e e.g. $24305.82\n\n// Print the percentage change in BTC value the last day\nconsole.log(`${await getPercentageChangeLastDay()} %`);\n// =\u003e e.g. 5%\n\n// Print all supported currencies for selected value provider\nconsole.log(await getSupportedCurrencies());\n// =\u003e cmc: [ ..., { name: 'Norwegian Krone', code: 'NOK', symbol: 'kr' }, ... ]\n// =\u003e coingecko: [ ..., 'nok', ... ]\n```\n\n## API\n\nThe Bitcoin value can be retrieved from [CoinMarketCap](https://coinmarketcap.com/) or [CoinGecko](https://www.coingecko.com). See the API used for CoinMarketCap [here](https://coinmarketcap.com/api/) and for CoinGecko [here](https://www.coingecko.com/en/api). If using the CoinMarketCap API to retrieve Bitcoin values, it is required to obtain and use an API key. This can be done [here](https://coinmarketcap.com/api/). Before using the functions for retrieving the Bitcoin value, one must then call `btcValue.setApiKey(\u003cKEY_HERE\u003e)` with your key. If using CoinGecko, this is not needed.\n\n### btcValue(currencyCode?)\n\nReturns the current Bitcoin value in USD ($).\n\n#### currencyCode\n\nType: `string`\u003cbr\u003e\nDefault: `USD`\n\nReturns the current Bitcoin value in a different currency than `USD`. All valid currency codes can be retrieved for the selected value provider using the `getSupportedCurrencies` function.\n\n### setProvider(provider)\n\nSets the selected provider to retrieve Bitcoin values from. Supported providers are: `cmc` (CoinMarketCap) and `coingecko`.\n\n#### provider\n\nType: `string`\u003cbr\u003e\n\n### setApiKey(apiKey)\n\nSets the API key for the selected value provider. Currently only CoinMarketCap supports using an API key. This is required to call the functions with the [CoinMarketCap API](https://coinmarketcap.com/api/).\n\n#### apiKey\n\nType: `string`\u003cbr\u003e\n\n### getPercentageChangeLastHour()\n\nReturns the percentage change of BTC the last hour.\n\n### getPercentageChangeLastDay()\n\nReturns the percentage change of BTC the last day.\n\n### getPercentageChangeLastWeek()\n\nReturns the percentage change of BTC the last week.\n\n### getSupportedCurrencies()\n\nReturns an array with all the supported currencies for the selected value provider.\nExample of the format for a single currency in the list using CoinMarketCap:\n\n```json\n{\n    \"name\": \"Norwegian Krone\",\n    \"code\": \"NOK\",\n    \"symbol\": \"kr\"\n}\n\n```\n\nExample of a returned array using CoinGecko:\n\n```js\n['btc', 'eth']\n```\n\n## Related\n\n- [btc-value-cli](https://github.com/knutkirkhorn/btc-value-cli) - CLI for this module\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknutkirkhorn%2Fbtc-value","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknutkirkhorn%2Fbtc-value","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknutkirkhorn%2Fbtc-value/lists"}