Class CoinGeckoClient

The wrap client to access all api on coin gecko

Category

  • Get all the coins categories with market data (market cap, volume, etc.) on CoinGecko

    Parameters

    • input: {
          order?:
              | "market_cap_desc"
              | "market_cap_asc"
              | "name_asc"
              | "name_desc"
              | "market_cap_change_24h_asc"
              | "market_cap_change_24h_desc";
      } = {}
      • Optionalorder?:
            | "market_cap_desc"
            | "market_cap_asc"
            | "name_asc"
            | "name_desc"
            | "market_cap_change_24h_asc"
            | "market_cap_change_24h_desc"

        sort results by field, default: market_cap_desc

    Returns Promise<CategoryWithMarketData[]>

    List of all categories with market data

Coin

  • Get current data (name, price, market, ... including exchange tickers) for a coin IMPORTANT: Ticker object is limited to 100 items, to get more tickers, use /coins/{id}/tickers Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while. Ticker is_anomaly is true if ticker’s price is outliered by our system. You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide)

    Parameters

    • input: {
          community_data?: boolean;
          developer_data?: boolean;
          id: string;
          localization?: boolean;
          market_data?: boolean;
          sparkline?: boolean;
          tickers?: boolean;
      }
      • Optionalcommunity_data?: boolean

        Include community_data data (true/false) [default: true]

      • Optionaldeveloper_data?: boolean

        Include developer_data data (true/false) [default: true]

      • id: string

        pass the coin id (can be obtained from /coins) eg. bitcoin

      • Optionallocalization?: boolean

        Include all localized languages in response (true/false)

      • Optionalmarket_data?: boolean

        Include market_data (true/false) [default: true]

      • Optionalsparkline?: boolean

        Include sparkline 7 days data (eg. true, false)

      • Optionaltickers?: boolean

        nclude tickers data (true/false) [default: true]

    Returns Promise<CoinFullInfo>

  • Get historical data (name, price, market, stats) at a given date for a coin

    Parameters

    • input: {
          date: string;
          id: string;
          localization?: boolean;
      }
      • date: string

        The date of data snapshot in dd-mm-yyyy eg. 30-12-2017

      • id: string

        pass the coin id (can be obtained from /coins) eg. bitcoin

      • Optionallocalization?: boolean

        Set to false to exclude localized languages in response

    Returns Promise<CoinHistoryResponse>

  • Get historical market data include price, market cap, and 24h volume (granularity auto) Minutely data will be used for duration within 1 day, Hourly data will be used for duration between 1 day and 90 days, Daily data will be used for duration above 90 days.

    Parameters

    • input: {
          days: number | "max";
          id: string;
          interval?: string;
          vs_currency: string;
      }
      • days: number | "max"

        Data up to number of days ago (eg. 1,14,30,max)

      • id: string

        pass the coin id (can be obtained from /coins) eg. bitcoin

      • Optionalinterval?: string

        Data interval. Possible value: daily

      • vs_currency: string

        The target currency of market data (usd, eur, jpy, etc.)

    Returns Promise<CoinMarketChartResponse>

  • Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto) Minutely data will be used for duration within 1 day, Hourly data will be used for duration between 1 day and 90 days, Daily data will be used for duration above 90 days.

    Parameters

    • input: {
          from: number;
          id: string;
          to: number;
          vs_currency: string;
      }
      • from: number

        From date in UNIX Timestamp (eg. 1392577232)

      • id: string

        pass the coin id (can be obtained from /coins) eg. bitcoin

      • to: number

        To date in UNIX Timestamp (eg. 1618716149)

      • vs_currency: string

        The target currency of market data (usd, eur, jpy, etc.)

    Returns Promise<CoinMarketChartResponse>

  • Get coin's OHLC (Beta)

    Candles body:
    1 - 2 days: 30 minutes
    3 - 30 days: 4 hours
    31 and before: 4 days

    Parameters

    • input: {
          days: number | "max";
          id: string;
          vs_currency: string;
      }
      • days: number | "max"

        Data up to number of days ago (1/7/14/30/90/180/365/max)

      • id: string

        pass the coin id (can be obtained from /coins) eg. bitcoin

      • vs_currency: string

        The target currency of market data (usd, eur, jpy, etc.)

    Returns Promise<number[][]>

    Sample output

    [
    [
    1618113600000,
    79296.36,
    79296.36,
    79279.94,
    79279.94
    ]
    . ... ... . .. . .. . . . . .
    ]
  • Get coin tickers (paginated to 100 items)

    IMPORTANT: Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while. Ticker is_anomaly is true if ticker’s price is outliered by our system. You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide)

    Parameters

    • input: {
          depth?: boolean;
          exchange_ids?: string;
          id: string;
          include_exchange_logo?: boolean;
          order?: "volume_desc" | "trust_score_desc" | "trust_score_asc";
          page?: number;
      }
      • Optionaldepth?: boolean

        flag to show 2% orderbook depth. valid values: true, false

      • Optionalexchange_ids?: string

        filter results by exchange_ids (ref: v3/exchanges/list)

      • id: string

        pass the coin id (can be obtained from /coins) eg. bitcoin

      • Optionalinclude_exchange_logo?: boolean

        flag to show exchange_logo

      • Optionalorder?: "volume_desc" | "trust_score_desc" | "trust_score_asc"

        valid values: trust_score_desc (default), trust_score_asc and volume_desc

      • Optionalpage?: number

        Page through results

    Returns Promise<CoinTickerResponse>

  • List all supported coins id, name and symbol (no pagination required) Use this to obtain all the coins’ id in order to make API calls

    Parameters

    • input: {
          include_platform?: boolean;
      }
      • Optionalinclude_platform?: boolean

        flag to include platform contract addresses (eg. 0x… for Ethereum based tokens). valid values: true, false

    Returns Promise<CoinListResponseItem[]>

  • List all supported coins price, market cap, volume, and market related data

    Parameters

    • input: {
          category?: "decentralized_finance_defi" | "stablecoins";
          ids?: string;
          order?:
              | "market_cap_desc"
              | "gecko_desc"
              | "gecko_asc"
              | "market_cap_asc"
              | "volume_asc"
              | "volume_desc"
              | "id_asc"
              | "id_desc";
          page?: number;
          per_page?: number;
          price_change_percentage?: string;
          sparkline?: boolean;
          vs_currency: string;
      }
      • Optionalcategory?: "decentralized_finance_defi" | "stablecoins"

        filter by coin category, only decentralized_finance_defi and stablecoins are supported at the moment

      • Optionalids?: string

        The ids of the coin, comma separated crytocurrency symbols (base). refers to /coins/list. When left empty, returns numbers the coins observing the params limit and start

      • Optionalorder?:
            | "market_cap_desc"
            | "gecko_desc"
            | "gecko_asc"
            | "market_cap_asc"
            | "volume_asc"
            | "volume_desc"
            | "id_asc"
            | "id_desc"

        valid values: market_cap_desc, gecko_desc, gecko_asc, market_cap_asc, market_cap_desc, volume_asc, volume_desc, id_asc, id_desc

      • Optionalpage?: number

        Page through results

      • Optionalper_page?: number

        Total results per page (valid values: 1…250)

      • Optionalprice_change_percentage?: string
      • Optionalsparkline?: boolean

        Include sparkline 7 days data (eg. true, false)

      • vs_currency: string

        The target currency of market data (usd, eur, jpy, etc.)

    Returns Promise<CoinMarket[]>

Contract

Derivatives

  • List all derivative tickers

    Parameters

    • input: {
          order?:
              | "name_asc"
              | "name_desc"
              | "open_interest_btc_asc"
              | "open_interest_btc_desc"
              | "trade_volume_24h_btc_asc"
              | "trade_volume_24h_btc_desc";
          page?: number;
          per_page?: number;
      }
      • Optionalorder?:
            | "name_asc"
            | "name_desc"
            | "open_interest_btc_asc"
            | "open_interest_btc_desc"
            | "trade_volume_24h_btc_asc"
            | "trade_volume_24h_btc_desc"

        order results using following params name_asc,name_desc,open_interest_btc_asc,open_interest_btc_desc,trade_volume_24h_btc_asc,trade_volume_24h_btc_desc

      • Optionalpage?: number

        Page through results

      • Optionalper_page?: number

        Total results per page

    Returns Promise<DerivativeExchange[]>

Exchange

  • List all supported markets id and name (no pagination required)

    Parameters

    • id: string

      the exchange id (can be obtained from /exchanges/list) eg. binance

    Returns Promise<ExchangeId>

    Use this to obtain all the markets’ id in order to make API calls

    IMPORTANT:
    Ticker object is limited to 100 items, to get more tickers, use /exchanges/{id}/tickers
    Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while.
    Ticker is_anomaly is true if tickers price is outliered by our system.
    You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide)
  • Get exchange tickers (paginated, 100 tickers per page)

    Parameters

    • input: {
          coin_ids?: string;
          depth?: string;
          id: string;
          include_exchange_logo?: boolean;
          order?: "volume_desc" | "trust_score_desc" | "trust_score_asc";
          page?: number;
      }
      • Optionalcoin_ids?: string

        filter tickers by coin_ids (ref: v3/coins/list)

      • Optionaldepth?: string

        flag to show 2% orderbook depth i.e., cost_to_move_up_usd and cost_to_move_down_usd

      • id: string

        pass the exchange id (can be obtained from /exchanges/list) eg. binance

      • Optionalinclude_exchange_logo?: boolean

        flag to show exchange_logo

      • Optionalorder?: "volume_desc" | "trust_score_desc" | "trust_score_asc"
      • Optionalpage?: number

        Page through results

    Returns Promise<ExchangeIdTickerResponse>

    Use this to obtain all the markets’ id in order to make API calls

    IMPORTANT:
    Ticker object is limited to 100 items, to get more tickers, use /exchanges/{id}/tickers
    Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while.
    Ticker is_anomaly is true if tickers price is outliered by our system.
    You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide)

Exchange Rates

Finance

Global

Indexes

Other

apiKey?: string
baseURL: string
options: Options = ...
  • Search for coins, categories and markets listed on CoinGecko ordered by largest Market Cap first.

    Parameters

    • input: {
          query?: string;
      }
      • Optionalquery?: string

        your search query.

    Returns Promise<SearchResponse>

Simple

  • Get the current price of any cryptocurrencies in any other supported currencies that you need.

    Parameters

    • input: {
          ids: string;
          include_24hr_change?: boolean;
          include_24hr_vol?: boolean;
          include_last_updated_at?: boolean;
          include_market_cap?: boolean;
          vs_currencies: string;
      }
      • ids: string

        The ids of the coin, comma separated crytocurrency symbols (base). refers to /coins/list. When left empty, returns numbers the coins observing the params limit and start

      • Optionalinclude_24hr_change?: boolean
      • Optionalinclude_24hr_vol?: boolean
      • Optionalinclude_last_updated_at?: boolean
      • Optionalinclude_market_cap?: boolean
      • vs_currencies: string

        vs_currency of coins, comma-separated if querying more than 1 vs_currency. *refers to simple/supported_vs_currencies

    Returns Promise<SimplePriceResponse>

    false
    
  • Get list of supported_vs_currencies.

    Returns Promise<string[]>

    list of supported_vs_currencies

  • Get current price of tokens (using contract addresses) for a given platform in any other currency that you need.

    Parameters

    • input: {
          contract_addresses: string;
          id: "ethereum";
          include_24hr_change?: boolean;
          include_24hr_vol?: boolean;
          include_last_updated_at?: boolean;
          include_market_cap?: boolean;
          vs_currencies: string;
      }
      • contract_addresses: string

        The contract address of tokens, comma separated

      • id: "ethereum"

        The id of the platform issuing tokens (Only ethereum is supported for now)

      • Optionalinclude_24hr_change?: boolean
      • Optionalinclude_24hr_vol?: boolean
      • Optionalinclude_last_updated_at?: boolean
      • Optionalinclude_market_cap?: boolean
      • vs_currencies: string

        vs_currency of coins, comma-separated if querying more than 1 vs_currency. *refers to simple/supported_vs_currencies

    Returns Promise<TokenPriceResponse>

    The dictionary of price pair with details

    • Example output
    {
    "0x8207c1ffc5b6804f6024322ccf34f29c3541ae26": {
    "btc": 0.00003754,
    "btc_market_cap": 7914.297728099776,
    "btc_24h_vol": 2397.477480037078,
    "btc_24h_change": 3.7958858800037834,
    "eth": 0.0009474,
    "eth_market_cap": 199730.22336519035,
    "eth_24h_vol": 60504.258122696505,
    "eth_24h_change": 2.8068351977135007,
    "last_updated_at": 1618664199
    }
    }