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

cryptocurrency-data

v0.0.3

Published

Web component displaying the rates for various cryptocoins in USD or EUR

Downloads

8

Readme

Cryptocurrency Data

Built With Stencil

About

Cryptocurrency Data is a demo web component built with Stencil. It displays the rates and changes in rates for various cryptocoins such as Bitcoin, Ethereum etc.

This web component is a proof of concept. It retrieves the data from the CoinMarketCap API and has some basic settings, what type of data should be displayed. Moreover, multiple instances of this component communicate and transfer data via events to minimize the number API calls: Only one component performs the API call and submits the retrieved data to all other components.

Installation

  1. Clone this repo:
git clone https://github.com/OnnoGeorg/cryptocurrency-data.git my-app
cd my-app
git remote rm origin
  1. Install all dependencies:
npm install
  1. Compile and run the web component with Stencil:
npm start

This last command also starts a small web server and opens a browser to display a sample web page containing multiple instances of this web component.

Usage

Use the web component as folllows:

<cryptocurrency-data coin="BTC" show="USD"></cryptocurrency-data>

This results e.g. in the following output:

4181.98 USD
  • coin (string) is the kind of cryptocoin. It can be any coin in the Top 10 of CoinMarketCap (in terms of market capitalization). Valid values are in the moment: BTC, ETH, XRP, BCH, LTC, DASH, XEM, MIOTA, NEO and XMR.

  • If show (string) equals USD or EUR, the component shows the rate of the coin in US-Dollar or Euro, respectively.

  • If show equals to 1h, 24h or 7d, the component shows the change of the rate within the last hour, the last 24 hours or the last seven days, respectively.

You can put as many of this web component in an app or on a web page, e.g. to show different types of coin data. See index.html, which displays a good old HTML table containing the rates of five coins in USD and EUR.

How does it work?

The web component calls the JSON API of CoinMarketCap to retrieve data of the 10 coins with the highest market capitalization (= most popular). This data is stored as an associative array in a @State() property within the web component.

To avoid unnecessary (multiple) calls to the external API, only one (the first visible) web component performs this call. Just before the API call, this first component emits an event to all other web components. This event prevents these other components from performing an API call for their own.

After the data is retrieved from the API, the first component emits a second event containing this data to all other components.