Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
btc-value
Advanced tools
Readme
Get the current Bitcoin value
npm install btc-value
import btcValue, {
setProvider,
setApiKey,
getPercentageChangeLastDay,
getSupportedCurrencies
} from 'btc-value';
// Set the value provider
setProvider('coingecko');
// Set the API key
setApiKey('example-cmc-API-key');
// Print the current value of Bitcoin in USD
console.log(`$${await btcValue()}`);
// => e.g. $11048
// Print the current value of Bitcoin in NOK (Norwegian krone)
console.log(`kr ${await btcValue('NOK')}`);
// => e.g. kr 86664
// Print the current value of 2.2 BTC in USD
console.log(`$${await btcValue({quantity: 2.2})}`);
// => e.g. $24305.82
// Print the percentage change in BTC value the last day
console.log(`${await getPercentageChangeLastDay()} %`);
// => e.g. 5%
// Print all supported currencies for selected value provider
console.log(await getSupportedCurrencies());
// => cmc: [ ..., { name: 'Norwegian Krone', code: 'NOK', symbol: 'kr' }, ... ]
// => coingecko: [ ..., 'nok', ... ]
The Bitcoin value can be retrieved from CoinMarketCap or CoinGecko. See the API used for CoinMarketCap here and for CoinGecko here. If using the CoinMarketCap API to retrieve Bitcoin values, it is required to obtain and use an API key. This can be done here. Before using the functions for retrieving the Bitcoin value, one must then call btcValue.setApiKey(<KEY_HERE>)
with your key. If using CoinGecko, this is not needed.
Returns the current Bitcoin value in USD ($).
Type: string
Default: USD
Returns 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.
Sets the selected provider to retrieve Bitcoin values from. Supported providers are: cmc
(CoinMarketCap) and coingecko
.
Type: string
Sets 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.
Type: string
Returns the percentage change of BTC the last hour.
Returns the percentage change of BTC the last day.
Returns the percentage change of BTC the last week.
Returns an array with all the supported currencies for the selected value provider. Example of the format for a single currency in the list using CoinMarketCap:
{
"name": "Norwegian Krone",
"code": "NOK",
"symbol": "kr"
}
Example of a returned array using CoinGecko:
['btc', 'eth']
FAQs
Get the current Bitcoin value
The npm package btc-value receives a total of 32 weekly downloads. As such, btc-value popularity was classified as not popular.
We found that btc-value demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.