Base¶
This is the core definition for all v2+ Coinmetrics APIs, both Community and Pro. This object includes the primary query device, all *_checker functions and the necessary discovery methods to enable the them.
Primary Methods¶
-
class
coinmetrics.base.
Base
(api_key='')¶ Coin Metrics API Base Object
-
__init__
(api_key='')¶ Initialize API to use the Base API endpoints by default. An optional
api_key
can be supplied.- Parameters
api_key (str, optional) – API key to be used for the Pro API.
-
_api_query
(endpoint, options=None)¶ Execute the raw API query and return the raw JSON output.
- Parameters
endpoint (string) – URL Path the query will be sent to. This includes any URL based parameters.
options (dict, optional) – Query parameters, including asset(s), metric(s), exchanges(s), and time range.
- Returns
Raw JSON response as dict.
- Return type
dict
-
get_assets
()¶ Fetch list of available assets.
- Returns
List of supported assets.
- Return type
list
-
asset_checker
(assets)¶ Helper function to determine if the requested asset(s) is(are) valid.
- Parameters
asset (str) – Unique ID corresponding to the asset’s ticker.
- Raises
InvalidAssetError
-
get_metrics
()¶ Fetch list of available metrics.
- Returns
List of supported metrics.
- Return type
list
-
metric_checker
(metrics)¶ Helper function to determine if the requested metric(s) is(are) valid.
- Parameters
metrics (str) – Unique ID corresponding to metric.
- Raises
InvalidMetricError
-
get_exchanges
()¶ Fetch list of available exchanges.
- Returns
List of supported exchanges.
- Return type
list
-
exchange_checker
(exchanges)¶ Helper function to determine if the requested exchange(s) is(are) valid.
- Parameters
exchanges (str) – Unique ID corresponding to the exchange.
- Raises
InvalidExchangeError
-
get_markets
()¶ Fetch list of available markets.
- Returns
List of supported markets.
- Return type
list
-
market_checker
(markets)¶ Helper function to determine if the requested market(s) is(are) valid.
- Parameters
market (str) – Unique ID corresponding to the market.
- Raises
InvalidMarketError
-
timestamp_checker
(begin_timestamp, end_timestamp)¶ Helper function to determine if the provided timerange is valid.
- Parameters
begin_timestamp (str or datetime) – Start of time inverval.
end_timestamp (str or datetime) – End of time inverval.
- Raises
InvalidTimeRangeError
-
Alias Methods¶
A group of alternative methods that function identically to the references functions above. This is to support any legacy API method names.
-
class
coinmetrics.base.
Base
(api_key='') Coin Metrics API Base Object
-
get_supported_assets
()¶ An alias for
get_assets()
-
assets
()¶ An alias for
get_assets()
-
getmetrics
()¶ An alias for
get_metrics()
-
metrics
()¶ An alias for
get_metrics()
-
getexchanges
()¶ An alias for
get_exchanges()
-
exchange
()¶ An alias for
get_exchanges()
-
getmarkets
()¶ An alias for
get_markets()
-
markets
()¶ An alias for
get_markets()
-