Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public class CoinGeckoFeed

  1. Object
  2. CoinGeckoFeed

ImplementsPriceFeed

Prices from CoinGecko’s simple/price API. Tickers map to CoinGecko’s coin ids; the common ones are built in and mapTicker adds others. The quote currency is any CoinGecko vs_currency (usd, eur, btc, …).

The public API works without a key at a low rate limit. Pass a demo key, or a Pro key with pro set, for production; the backend should hold that key, not the application.

Constructors

public CoinGeckoFeed(RpcTransport transport)A feed on the keyless public API.
public CoinGeckoFeed(RpcTransport transport, String apiKey, boolean pro)A feed with an API key; pro selects the Pro endpoint and header, otherwise the key is a demo key.

Methods

public CoinGeckoFeed mapTicker(String ticker, String coinGeckoId)Maps a ticker to a CoinGecko coin id, replacing a built-in one.
public Quote getQuote(String base, String quote) throws IOExceptionThe price of base in quote, by ticker (BTC, ETH, USD, EUR); case does not matter.

Inherited methods

Constructor details

CoinGeckoFeed

public CoinGeckoFeed(RpcTransport transport)
A feed on the keyless public API.

CoinGeckoFeed

public CoinGeckoFeed(RpcTransport transport, String apiKey, boolean pro)
A feed with an API key; pro selects the Pro endpoint and header, otherwise the key is a demo key.

Method details

mapTicker

public CoinGeckoFeed mapTicker(String ticker, String coinGeckoId)
Maps a ticker to a CoinGecko coin id, replacing a built-in one.

getQuote

public Quote getQuote(String base, String quote) throws IOException
The price of base in quote, by ticker (BTC, ETH, USD, EUR); case does not matter.

Throws

IOException
when the source cannot be reached or does not know the pair