Class CoinGeckoFeed

java.lang.Object
com.codename1.crypto.market.CoinGeckoFeed
All Implemented Interfaces:
PriceFeed

public class CoinGeckoFeed extends Object implements PriceFeed

Prices from CoinGecko's simple/price API. Tickers map to CoinGecko's coin ids; the common ones are built in and mapTicker(String, String) 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.

  • 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
      Description copied from interface: PriceFeed

      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
      Specified by:
      getQuote in interface PriceFeed
      Throws:
      IOException