class CoinMarketPro::Endpoint::Cryptocurrency

@see pro.coinmarketcap.com/api/v1#tag/cryptocurrency

Constants

ENDPOINT

Public Instance Methods

info(**args) click to toggle source

Returns all static metadata for one or more cryptocurrencies

including name, symbol, logo, and its various registered URLs.

@param [Hash] args @option args [Array<Integer>] :id One or more CoinMarketCap cryptocurrency IDs. @option args [Array<String>] :symbol Alternatively pass one or more cryptocurrency symbols. @return [CoinMarketPro::Result] @note At least one “id” or “symbol” is required.

@see pro.coinmarketcap.com/api/v1#operation/getV1CryptocurrencyInfo

# File lib/coin_market_pro/endpoint/cryptocurrency.rb, line 20
def info(**args)
  valid_params?(args)
  params = convert_params(args)
  client.get("#{ENDPOINT}/info", options: params.compact).tap do |resp|
    resp.body = begin
                  resp.body.map { |_k, data| data }
                rescue StandardError
                  []
                end
  end
end
Also aliased as: metadata
listings(**args) click to toggle source

Get a paginated list of all cryptocurrencies with latest market data.

@option timestamp [String] Timestamp (Unix or ISO 8601) to return historical cryptocurrency listings for. @option start [Integer] Optionally offset the start (1-based index) of the paginated list of items to return. @option limit [Integer] Optionally specify the number of results to return. Use this parameter

and the "start" parameter to determine your own pagination size.

@option convert [String] Optionally calculate market quotes in up to 32 currencies at once by passing a

comma-separated list of cryptocurrency or fiat currency symbols. Each additional convert option beyond the
first requires an additional call credit. A list of supported fiat options can be found here. Each conversion
is returned in its own "quote" object.

@option sort [String] What field to sort the list of cryptocurrencies by. @option sort_dir [String] The direction in which to order cryptocurrencies against the specified sort. @option cryptocurrency_type [String] The type of cryptocurrency to include. @return [CoinMarketPro::Result]

@see pro.coinmarketcap.com/api/v1#operation/getV1CryptocurrencyListingsLatest

# File lib/coin_market_pro/endpoint/cryptocurrency.rb, line 75
def listings(**args)
  params = convert_params(args)
  client.get("#{ENDPOINT}/listings/latest", options: params.compact)
end
Also aliased as: listings_latest
listings_historical(**args) click to toggle source

@note This endpoint is not yet available. It is slated for release in early Q4 2018. Returns paginated list of all cryptocurrencies with market data for a given historical time.

@param [Hash] args @option args [String] :timestamp Timestamp (Unix or ISO 8601) to return historical cryptocurrency listings for. @option args [Integer] :start Optionally offset the start (1-based index) of the paginated list of items to return. @option args [Integer] :limit Optionally specify the number of results to return. Use this parameter

and the "start" parameter to determine your own pagination size.

@option args [String] :convert Optionally calculate market quotes in up to 32 currencies at once by passing a

comma-separated list of cryptocurrency or fiat currency symbols. Each additional convert option beyond the
first requires an additional call credit. A list of supported fiat options can be found here. Each conversion
is returned in its own "quote" object.

@option args [String] :sort What field to sort the list of cryptocurrencies by. @option args [String] :sort_dir The direction in which to order cryptocurrencies against the specified sort. @option args [String] :cryptocurrency_type The type of cryptocurrency to include. @return [CoinMarketPro::Result]

@see pro.coinmarketcap.com/api/v1#operation/getV1CryptocurrencyListingsHistorical

# File lib/coin_market_pro/endpoint/cryptocurrency.rb, line 53
def listings_historical(**args)
  params = convert_params(args)
  client.get("#{ENDPOINT}/listings/historical", options: params.compact)
end
listings_latest(**args)
Alias for: listings
map(**args) click to toggle source

Returns a paginated list of all cryptocurrencies by CoinMarketCap ID.

@param [Hash] args @option args [String] :listing_status Only active coins are returned by default.

Pass 'inactive' to get a list of coins that are no longer active.

@option args [Integer] :start Optionally offset the start (1-based index) of the paginated list of items to return. @option args [Integer] :limit Optionally specify the number of results to return.

Use this parameter and the "start" parameter to determine your own pagination size.

@option args [Array] :symbol Optionally pass a list of cryptocurrency symbols to return

CoinMarketCap IDs for. If this option is passed, other options will be ignored.

@return [CoinMarketPro::Result]

@see pro.coinmarketcap.com/api/v1#operation/getV1CryptocurrencyMap

# File lib/coin_market_pro/endpoint/cryptocurrency.rb, line 96
def map(**args)
  params = convert_params(args)
  client.get("#{ENDPOINT}/map", options: params.compact)
end
market_pairs(**args) click to toggle source

Lists all market pairs for the specified cryptocurrency with associated stats.

@option id [String] A cryptocurrency by CoinMarketCap ID. Example: “1” @option symbol [String] Alternatively pass a cryptocurrency by symbol. Example: “BTC”.

A single cryptocurrency "id" or "symbol" is required.

@option start [Integer] Optionally offset the start (1-based index) of the paginated list of items to return. @option limit [Integer] Optionally specify the number of results to return.

Use this parameter and the "start" parameter to determine your own pagination size.

@option convert [String] Optionally calculate market quotes in up to 32 currencies at once by passing a

comma-separated list of cryptocurrency or fiat currency symbols.
Each additional convert option beyond the first requires an additional call credit.
A list of supported fiat options can be found here. Each conversion is returned in its own "quote" object.

@return [CoinMarketPro::Result]

@see pro.coinmarketcap.com/api/v1#operation/getV1CryptocurrencyMarketpairsLatest

# File lib/coin_market_pro/endpoint/cryptocurrency.rb, line 117
def market_pairs(**args)
  valid_params?(args)
  params = convert_params(args)
  client.get("#{ENDPOINT}/market-pairs/latest", options: params.compact).tap do |resp|
    resp.body = [resp.body]
  end
end
market_quotes(**args)
Alias for: quotes
market_quotes_historical(**args)
Alias for: quotes_historical
metadata(**args)
Alias for: info
ohlcv(**args) click to toggle source

Return the latest OHLCV (Open, High, Low, Close, Volume) market values for one or

more cryptocurrencies in the currently UTC day.

@option id [String] A cryptocurrency by CoinMarketCap ID. Example: “1” @option symbol [String] Alternatively pass a cryptocurrency by symbol. Example: “BTC”.

A single cryptocurrency "id" or "symbol" is required.

@option convert [String] Optionally calculate market quotes in up to 32 currencies at once by passing a

comma-separated list of cryptocurrency or fiat currency symbols.
Each additional convert option beyond the first requires an additional call credit.
A list of supported fiat options can be found here. Each conversion is returned in its own "quote" object.

@return [CoinMarketPro::Result]

@see pro.coinmarketcap.com/api/v1#operation/getV1CryptocurrencyOhlcvLatest

# File lib/coin_market_pro/endpoint/cryptocurrency.rb, line 172
def ohlcv(**args)
  valid_params?(args)
  params = convert_params(args)
  client.get("#{ENDPOINT}/ohlcv/latest", options: params.compact).tap do |resp|
    resp.body = begin
                  resp.body.map { |_k, data| data }
                rescue StandardError
                  []
                end
  end
end
Also aliased as: ohlcv_latest
ohlcv_historical(**args) click to toggle source

Return an interval of historic OHLCV (Open, High, Low, Close, Volume) market quotes for a cryptocurrency.

@option id [String] A cryptocurrency by CoinMarketCap ID. Example: “1” @option symbol [String] Alternatively pass a cryptocurrency by symbol. Example: “BTC”.

A single cryptocurrency "id" or "symbol" is required.

@option time_period [String] Time period to return OHLCV data for. The default is “daily”.

Additional options will be available in the future. See the main endpoint description for details.

@option time_start [String] Timestamp (Unix or ISO 8601) to start returning OHLCV time periods for.

Only the date portion of the timestamp is used for daily OHLCV so it's recommended to send an ISO date
format like "2018-09-19" without time.

@option time_end [String] Timestamp (Unix or ISO 8601) to stop returning OHLCV time periods for (inclusive).

Optional, if not passed we'll default to the current time. Only the date portion of the timestamp is used for
daily OHLCV so it's recommended to send an ISO date format like "2018-09-19" without time.

@option count [Number] Optionally limit the number of time periods to return results for.

The default is 10 items. The current query limit is 10000 items.

@option interval [String] Optionally adjust the interval that “time_period” is sampled.

See main endpoint description for available options.
Valid Values: "daily" "weekly" "monthly" "yearly" "1d" "2d" "3d" "7d" "14d" "15d" "30d" "60d" "90d" "365d"

@option convert [String] Optionally calculate market quotes in up to 32 currencies at once by passing a

comma-separated list of cryptocurrency or fiat currency symbols.
Each additional convert option beyond the first requires an additional call credit.
A list of supported fiat options can be found here. Each conversion is returned in its own "quote" object.

@return [CoinMarketPro::Result]

@see pro.coinmarketcap.com/api/v1#operation/getV1CryptocurrencyOhlcvHistorical

# File lib/coin_market_pro/endpoint/cryptocurrency.rb, line 151
def ohlcv_historical(**args)
  valid_params?(args)
  params = convert_params(args)
  client.get("#{ENDPOINT}/ohlcv/historical", options: params.compact).tap do |resp|
    resp.body = [resp.body]
  end
end
ohlcv_latest(**args)
Alias for: ohlcv
quotes(**args) click to toggle source

@option id [Array<String>] One or more comma-separated cryptocurrency CoinMarketCap IDs. Example: 1,2 @option symbol [String] Alternatively pass a cryptocurrency by symbol. Example: “BTC,ETH”.

A single cryptocurrency "id" or "symbol" is required.

@option convert [String] Optionally calculate market quotes in up to 32 currencies at once by passing a

comma-separated list of cryptocurrency or fiat currency symbols.
Each additional convert option beyond the first requires an additional call credit.
A list of supported fiat options can be found here. Each conversion is returned in its own "quote" object.

@return [CoinMarketPro::Result]

@see pro.coinmarketcap.com/api/v1#operation/getV1CryptocurrencyQuotesLatest

# File lib/coin_market_pro/endpoint/cryptocurrency.rb, line 231
def quotes(**args)
  valid_params?(args)
  params = convert_params(args)
  client.get("#{ENDPOINT}/quotes/latest", options: params.compact).tap do |resp|
    resp.body = begin
                  resp.body.map { |_k, data| data }
                rescue StandardError
                  []
                end
  end
end
Also aliased as: market_quotes, quotes_latest
quotes_historical(**args) click to toggle source

Returns an interval of historic market quotes for any cryptocurrency based on time and interval parameters.

@option id [String] A cryptocurrency by CoinMarketCap ID. Example: “1” @option symbol [String] Alternatively pass a cryptocurrency by symbol. Example: “BTC”.

A single cryptocurrency "id" or "symbol" is required.

@option time_period [String] Time period to return OHLCV data for. The default is “daily”.

Additional options will be available in the future. See the main endpoint description for details.

@option time_start [String] Timestamp (Unix or ISO 8601) to start returning OHLCV time periods for.

Only the date portion of the timestamp is used for daily OHLCV so it's recommended to send an ISO date
format like "2018-09-19" without time.

@option time_end [String] Timestamp (Unix or ISO 8601) to stop returning OHLCV time periods for (inclusive).

Optional, if not passed we'll default to the current time. Only the date portion of the timestamp is used for
daily OHLCV so it's recommended to send an ISO date format like "2018-09-19" without time.

@option count [Number] Optionally limit the number of time periods to return results for.

The default is 10 items. The current query limit is 10000 items.

@option interval [String] Optionally adjust the interval that “time_period” is sampled.

See main endpoint description for available options.
Valid Values: "daily" "weekly" "monthly" "yearly" "1d" "2d" "3d" "7d" "14d" "15d" "30d" "60d" "90d" "365d"

@option convert [String] Optionally calculate market quotes in up to 32 currencies at once by passing a

comma-separated list of cryptocurrency or fiat currency symbols.
Each additional convert option beyond the first requires an additional call credit.
A list of supported fiat options can be found here. Each conversion is returned in its own "quote" object.

@return [CoinMarketPro::Result]

@see pro.coinmarketcap.com/api/v1#operation/getV1CryptocurrencyQuotesHistorical

# File lib/coin_market_pro/endpoint/cryptocurrency.rb, line 211
def quotes_historical(**args)
  valid_params?(args)
  params = convert_params(args)
  client.get("#{ENDPOINT}/quotes/historical", options: params.compact).tap do |resp|
    resp.body = [resp.body]
  end
end
Also aliased as: market_quotes_historical
quotes_latest(**args)
Alias for: quotes