npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

coindesk.js

v1.0.2

Published

Get the current and historical Bitcoin price in different currencies, using Coindesk.

Downloads

15

Readme

coindesk.js

Support me on Patreon Buy me a book PayPal Ask me anything Version Downloads Get help on Codementor

Get the current and historical Bitcoin price in different currencies, using Coindesk.

:cloud: Installation

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

:clipboard: Example

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)
})

:question: Get Help

There are few ways to get help:

  1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
  2. For bug reports and feature requests, open issues. :bug:
  3. For direct and quick help, you can use Codementor. :rocket:

:memo: Documentation

current(currency, cb)

Fetches the current price.

Params

  • String currency: The currency. If not provided, the Bitcoin price will be fetched in different currencies.
  • Function cb: The callback function.

Return

  • Promise The request object with a promise.

historical(opts, cb)

Fetches the Bitcoin prices from the past.

Params

  • 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) and end (Date): Allows data to be returned for a specific date range. Must be listed as a pair of start and end parameters.
    • for (String): If yesterday, will return a single value for the previous day. Overrides the start/end parameter.
  • Function cb: The callback function.

Return

  • Promise The request object with a promise.

:yum: How to contribute

Have an idea? Found a bug? See how to contribute.

:sparkling_heart: Support my projects

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 :rocket:

  • Buy me a book—I love books! I will remember you after years if you buy me one. :grin: :book:

  • PayPal—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:

  • Support me on Patreon—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! :heart:

:scroll: License

MIT © Ionică Bizău