brh55 / fitbit-crypto

A library for Fitbit OS to fetch, display, and sync cryptocurrency prices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fitbit-crypto

Travis branch Coveralls branch npm badge

Still in progress for documentation and testing, but working.

Getting Started

  1. Import library in your app directory
import Crypto from 'fitbit-crypto/app';
  1. Import listen() method and activate it within your companion file
import { listen } from 'fitbit-crypto/companion';

listen()
  1. Create a Text element within your views with an Id
  2. Initiate Crypto library to create a instance to fetch, display, prices
import Crypto from 'fitbit-crypto/app';

const crypto = new Crypto('elementId', { fromSymbol: 'USD', toSymbol: 'BTC' });

const load = async () => {
  const btcPrice = await crypto.getPrice();
  console.log('BTC Price', btcPrice);
  
  // Display to the target element
  crypto.setPrice();
  
  // Get price to update the target element every second
  setInterval(async () => {
    await crypto.getPrice();
    crypto.setPrice
  }, 1000);
};

load();

Advance Usage

Use the library to create multiple listener for different crytocurrencies and attach a refresh button to it

import Crypto from 'fitbit-crypto/app';

const btc = new Crypto('btcId', { fromSymbol: 'USD', toSymbol: 'BTC', tapTargetId: 'btcRefreshBtn' });
const doge = new Crypto('dogeId', { fromSymbol: 'USD', toSymbol: 'DOGE', tapTargetId: 'dogeRefreshBtn' });
const eth = new Crypto('ethId', { fromSymbol: 'USD', toSymbol: 'ETH', tapTargetId: 'ethRefreshBtn' });

// Set Initial Prices
btc.getPrice().then(() => btc.setPrice());
eth.getPrice().then(() => eth.setPrice());
doge.getPrice().then(() => doge.setPrice());

fitbit-crypto/app

fitfont, fromSymbol = 'BTC', toSymbol = 'USD', onPriceChange, tapTargetId, defaultErrorMessage, quickError = true

fitbit-crypto/companion

Used in The Wild

This module is being used for the following watchfaces:

  • Dogee (4.8 ⭐s) - A free dogecoin watchface by Pixels on Ridge

Pixels on Ridge

License

MIT © Brandon Him

About

A library for Fitbit OS to fetch, display, and sync cryptocurrency prices


Languages

Language:JavaScript 100.0%