











Get the current Bitcoin value

Installation

$ npm install btc-value

Usage

const btcValue = require ( ' btc-value ' ) ; btcValue . setApiKey ( ' example-API-key ' ) ; btcValue ( ) . then ( value => { console . log ( ' $ ' + value ) ; } ) ; btcValue ( { isDecimal : true } ) . then ( value => { console . log ( ' $ ' + value ) ; } ) ; btcValue ( { currencyCode : ' NOK ' } ) . then ( value => { console . log ( ' kr ' + value ) ; } ) ; btcValue ( { quantity : 2 . 2 } ) . then ( value => { console . log ( ' $ ' + value ) ; } ) ; btcValue . getPercentageChangeLastDay ( ) . then ( percentage => { console . log ( percentage + ' % ' ) ; } ) ; console . log ( btcValue . currencies ) ;

API

The Bitcoin value is from Cryptocurrency Market Capitalizations. See API here. To use the module for 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.

Returns the current Bitcoin value in USD ($) as an integer .

options (optional)

Type: object

isDecimal

Type: boolean

Default: false

Returns the current Bitcoin value as a decimal number if isDecimal is true .

quantity

Type: number

Returns the current Bitcoin value of a specified quantity .

currencyCode

Type: string

Default: USD

Returns the current Bitcoin value in a different currency than USD . All valid currency codes are stored in the currencies.json file.

Sets the API key for the Cryptocurrency Market Capitalizations API used in the requests. This is required to call the other functions.

apiKey

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 specified in currencies.json. Example of the format for a single currency in the list:

{ " name " : " Norwegian Krone " , " code " : " NOK " , " symbol " : " kr " }

Related

btc-value-cli - CLI for this module

License

MIT © Knut Kirkhorn