Class CoinGeckoClient

The wrap client to access all api on coin gecko

Hierarchy

  • CoinGeckoClient

Constructors

Properties

apiKey?: string
baseURL: string
options: Options = ...
API_V3_URL: "https://api.coingecko.com/api/v3" = "https://api.coingecko.com/api/v3"
PRO_API_V3_URL: "https://pro-api.coingecko.com/api/v3" = "https://pro-api.coingecko.com/api/v3"

Coin Methods

  • 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)

    Returns

    Parameters

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

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

      • Optional developer_data?: boolean

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

      • id: string

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

      • Optional localization?: boolean

        Include all localized languages in response (true/false)

      • Optional market_data?: boolean

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

      • Optional sparkline?: boolean

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

      • Optional tickers?: 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

    Returns

    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

      • Optional localization?: 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.

    Returns

    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

      • Optional interval?: 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.

    Returns

    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

    See

    https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__ohlc

    Returns

    Sample output

    [
    [
    1618113600000,
    79296.36,
    79296.36,
    79279.94,
    79279.94
    ]
    . ... ... . .. . .. . . . . .
    ]

    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[][]>

  • 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)

    Returns

    Parameters

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

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

      • Optional exchange_ids?: string

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

      • id: string

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

      • Optional include_exchange_logo?: boolean

        flag to show exchange_logo

      • Optional order?: "volume_desc" | "trust_score_desc" | "trust_score_asc"

        valid values: trust_score_desc (default), trust_score_asc and volume_desc

      • Optional page?: 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

    Returns

    Parameters

    • input: {
          include_platform?: boolean;
      }
      • Optional include_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

    Returns

    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;
      }
      • Optional category?: "decentralized_finance_defi" | "stablecoins"

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

      • Optional 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

      • Optional order?: "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

      • Optional page?: number

        Page through results

      • Optional per_page?: number

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

      • Optional price_change_percentage?: string
      • Optional sparkline?: 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 Methods

  • Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto) from a contract address

    See

    https://www.coingecko.com/api/documentations/v3#/contract/get_coins__id__contract__contract_address__market_chart_range

    Returns

    current data for a coin

    Returns

    Get historical market data include price, market cap, and 24h volume

    Parameters

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

        Token’s contract address

      • Optional from?: number

        From date in UNIX Timestamp (eg. 1392577232)

      • id: PLATFORMS

        Asset platform (only ethereum is supported at this moment)

      • to: number

        From date in UNIX Timestamp (eg. 1618716149)

      • vs_currency: string

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

    Returns Promise<CoinMarketChartResponse>

Derivatives Methods

  • 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;
      }
      • Optional order?: "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

      • Optional page?: number

        Page through results

      • Optional per_page?: number

        Total results per page

    Returns Promise<DerivativeExchange[]>

Exchange Methods

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

    See

    https://www.coingecko.com/api/documentations/v3#/exchanges_(beta)/get_exchanges__id_

    Returns

    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)

    Returns

    Get exchange volume in BTC and top 100 tickers only

    Parameters

    • id: string

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

    Returns Promise<ExchangeId>

  • Get exchange tickers (paginated, 100 tickers per page)

    See

    https://www.coingecko.com/api/documentations/v3#/exchanges_(beta)/get_exchanges__id__tickers

    Returns

    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)

    Returns

    Get exchange volume in BTC and top 100 tickers only

    Parameters

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

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

      • Optional depth?: 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

      • Optional include_exchange_logo?: boolean

        flag to show exchange_logo

      • Optional order?: "volume_desc" | "trust_score_desc" | "trust_score_asc"
      • Optional page?: number

        Page through results

    Returns Promise<ExchangeIdTickerResponse>

  • Get status updates for a given exchange (beta)

    See

    https://www.coingecko.com/api/documentations/v3#/exchanges_(beta)/get_exchanges__id__volume_chart

    Returns

    Get status updates for a given exchange

    Returns

    Get status updates for a given exchange

    Parameters

    • input: {
          days: number;
          id: string;
      }
      • days: number

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

      • id: string

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

    Returns Promise<number[][]>

Exchange Rates Methods

Finance Methods

Global Methods

Indexes Methods

  • Parameters

    • Optional input: {
          id?: number;
          market_id?: number;
          path_id?: number;
      }
      • Optional id?: number

        pass the index id (can be obtained from /indexes/list)

      • Optional market_id?: number

        pass the market id (can be obtained from /exchanges/list)

      • Optional path_id?: number

        pass the index id (can be obtained from /indexes/list)

    Returns Promise<IndexItem[]>

Other Methods

  • Make HTTP request to the given endpoint

    Returns

    json content

    Type Parameters

    • T

    Parameters

    • url: string

      the full https URL

    Returns Promise<HttpResponse<any>>

  • Generic function to make request use in internal function

    Returns

    Type Parameters

    • T

    Parameters

    • action: API_ROUTES
    • params: {
          [key: string]: any;
      } = {}
      • [key: string]: any

    Returns Promise<T>

  • Search for coins, categories and markets listed on CoinGecko ordered by largest Market Cap first.

    Returns

    Parameters

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

        your search query.

    Returns Promise<SearchResponse>

  • Parameters

    • path: string
    • replacements: {
          [x: string]: string;
      } = {}
      • [x: string]: string

    Returns string

Simple Methods

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

    Default

    false

    Returns

    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

      • Optional include_24hr_change?: boolean
      • Optional include_24hr_vol?: boolean
      • Optional include_last_updated_at?: boolean
      • Optional include_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>

  • Get list of supported_vs_currencies.

    Returns

    list of supported_vs_currencies

    Returns Promise<string[]>

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

    Returns

    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
    }
    }

    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)

      • Optional include_24hr_change?: boolean
      • Optional include_24hr_vol?: boolean
      • Optional include_last_updated_at?: boolean
      • Optional include_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>

Generated using TypeDoc