CoinGecko API

Hooks

useCoingeckoPrice

Given base token name and the supported currencies to get token price from CoinGecko.

Parameters

Returns

  • string | undefined - token price

Example

import { useCoingeckoPrice } from '@usedapp/coingecko'

const etherPrice = useCoingeckoPrice('ethereum', 'usd')

return etherPrice && (<p>$ {etherPrice}</p>)

useCoingeckoTokenPrice

Given token contract and the supported currencies to get token price from CoinGecko.

Parameters

Returns

  • string | undefined - token price

Example

import { useCoingeckoTokenPrice } from '@usedapp/coingecko'

const WETH_CONTRACT = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
const wethPrice = useCoingeckoTokenPrice(WETH_CONTRACT, 'usd')

return wethPrice && (<p>$ {wethPrice}</p>)