Get the current and historical Bitcoin price in different currencies, using Coindesk.
Check out the dist
directory to download the needed files and include them on your page.
If you're using this module in a CommonJS environment, you can install it using npm
or yarn
and require
it:
# Using npm
npm install --save coindesk.js
# Using yarn
yarn add coindesk.js
const BitcoinValue = require("coindesk.js")
BitcoinValue.historical().then(data => {
console.log(data)
// =>
// { bpi:
// { '2017-07-08': 2579.9338,
// ...
// '2017-08-06': 3255.0025,
// '2017-08-07': 3431.9688 },
// disclaimer: 'This data was produced from the CoinDesk Bitcoin Price Index. BPI value data returned as USD.',
// time:
// { updated: 'Aug 8, 2017 00:03:00 UTC',
// updatedISO: '2017-08-08T00:03:00+00:00' } }
}).catch(err => {
console.log(err)
})
BitcoinValue.current("RON", (err, data) => {
console.log(err || data)
// =>
// { time:
// {...},
// disclaimer: '...',
// bpi:
// { USD:
// {...},
// RON:
// { code: 'RON',
// rate: '13,370.4374',
// description: 'Romanian Leu',
// rate_float: 13370.4374 } } }
})
BitcoinValue.historical({
start: new Date(2011, 0, 1)
, end: new Date(2011, 0, 31)
, currency: "EUR"
}).then(data => {
console.log(data)
// =>
// { bpi:
// { '2011-01-01': 0.2243,
// ...
// '2011-01-30': 0.3513,
// '2011-01-31': 0.3796 },
// disclaimer: '...',
// time:
// {...} }
}).catch(err => {
console.error(err)
})
There are few ways to get help:
- Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
- For bug reports and feature requests, open issues. π
- For direct and quick help, you can use Codementor. π
Fetches the current price.
- String
currency
: The currency. If not provided, the Bitcoin price will be fetched in different currencies. - Function
cb
: The callback function.
- Promise The request object with a promise.
Fetches the Bitcoin prices from the past.
- Object
opts
: An object containing the following fields:index
(String):[USD/CNY]
The index to return data for. Defaults to USD.currency
(String): The currency to return the data in, specified in ISO 4217 format. Defaults to USD.start
(Date) andend
(Date): Allows data to be returned for a specific date range. Must be listed as a pair of start and end parameters.for
(String): Ifyesterday
, will return a single value for the previous day. Overrides the start/end parameter.
- Function
cb
: The callback function.
- Promise The request object with a promise.
Have an idea? Found a bug? See how to contribute.
I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).
However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:
-
Starring and sharing the projects you like π
-
βI love books! I will remember you after years if you buy me one. π π
-
βYou can make one-time donations via PayPal. I'll probably buy a
coffeetea. π΅ -
βSet up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
-
BitcoinβYou can send me bitcoins at this address (or scanning the code below):
1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6
Thanks! β€οΈ