get crypto currency data from coinmarketcap
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
.travis.yml
LICENSE
README.md
package-lock.json
package.json
tsconfig.json
tslint.json
yarn.lock

README.md

Get Crypto FIAT Values

Build Status Coverage Status Average time to resolve an issue Percentage of issues still open

For a crypto currency or several, get its/their FIAT value (in USD).

install

yarn add get-crypto-fiat-values

use

get a single crypto usd value

import { getCryptoUSDValue } from 'get-crypto-fiat-values'

let aPortfolioAllocation: string[] = ['bitcoin', 'ethereum', 'litecoin', 'dogecoin']

aPortfolioAllocation.forEach(async sCurrency => {
    const value = await getCryptoUSDValue(sCurrency)
    console.log(`Got value: ${value}, for ${sCurrency}`)
})

prints:

Got value: 248.464, for litecoin
Got value: 11519.5, for bitcoin
Got value: 944.51, for ethereum
Got value: 0.00707836, for dogecoin

get multiple crypto usd values

import { getMultipleCryptoUSDValue } from 'get-crypto-fiat-values'

const oResult: any = await getMultipleCryptoUSDValue(['ethereum', 'dogecoin', 'litecoin', 'ripple'])

const sETHKey = 'ethereum'
const sDOGEKey = 'dogecoin'
console.log('ethereum value is: ', oResult[sETHKey].usdValue)
console.log('dogecoin value is: ', oResult[sDOGEKey].usdValue)

prints:

ethereum value is:  749.677
dogecoin value is:  0.00421033

get all crypto values

Returns an array of 'CMCCurrencySnapshot' types representing all currencies listed on coinmarketcap.com.

import { getAllCryptoValues, CMCCurrencySnapshot } from 'get-crypto-fiat-values'

main async () {
    const aResult: CMCCurrencySnapshot[] | null = await getAllCryptoValues()
}

main()