messari package
Messari Class
- class messari.messari.messari.Messari(api_key=None)
Bases:
messari.dataloader.DataLoader
This class is a wrapper around the Messari API
Methods
get_all_assets
([page, limit, asset_fields, ...])Get the paginated list of all assets including metrics and profile.
get_all_markets
([page, limit, to_dataframe])Get the list of all exchanges and pairs that our WebSocket-based market real-time market data API supports.
get_asset
(asset_slugs[, asset_fields, ...])Get basic metadata for an asset.
get_asset_market_data
(asset_slugs[, ...])Get the latest market data for an asset.
get_asset_metrics
(asset_slugs[, ...])Get all the quantitative metrics for an asset.
get_asset_profile
(asset_slugs[, ...])Get all the qualitative information for an asset.
get_metric_timeseries
(asset_slugs, asset_metric)Retrieve historical timeseries data for an asset.
get_response
(endpoint_url[, params, headers])Gets response from endpoint and checks for HTTP errors when requesting data.
set_api_dict
(api_dict)Sets a new dictionary to be used as an API key pair
set_taxonomy_dict
(taxonomy_dict)Sets a new dictionary to be used for taxonomy translations
translate
(input_slugs)Wrapper around messari.utils.validate_input, validate input & check if it's supported by DeFi Llama
- get_all_assets(page: int = 1, limit: int = 20, asset_fields: Optional[Union[str, List]] = None, asset_metric: Optional[str] = None, asset_profile_metric: Optional[str] = None, to_dataframe: Optional[bool] = None) Union[Dict, pandas.core.frame.DataFrame]
Get the paginated list of all assets including metrics and profile.
Data is return only in JSON format when an asset profile is provided due to the high number of text fields. The keys of the object are assets and the value is the associated asset data.
The function can return a pandas DataFrame only when asset metric data is requested.
- Parameters
- page: int
Page number starting at 1. Increment value to paginate through results.
- limit: int
Limit of assets to return. Default is 20, max value is 500.
- asset_fields: str, list
Single filter string or list of fields to filter data. Available fields include:
id
name
slug
metrics
profile
- asset_metric: str
Single metric string to filter metric data. Available metrics include:
market_data
marketcap
supply
blockchain_stats_24_hours
market_data_liquidity
all_time_high
cycle_low
token_sale_stats
staking_stats
mining_stats
developer_activity
roi_data
roi_by_year
risk_metrics
misc_data
lend_rates
borrow_rates
loan_data
reddit
on_chain_data
exchange_flows
alert_messages
- asset_profile_metric: str
Single profile metric string to filter profile data. Available metrics include:
general
contributors
advisors
investors
ecosystem
economics
technology
governance
metadata
- to_dataframe: bool
Return data as pandas DataFrame or JSON. Default is set to JSON.
- Returns
- dict, DataFrame
Dictionary or pandas DataFrame of asset data.
- get_all_markets(page: int = 1, limit: int = 20, to_dataframe: bool = True) Union[List[Dict], pandas.core.frame.DataFrame]
Get the list of all exchanges and pairs that our WebSocket-based market real-time market data API supports.
- Parameters
- page: int
Page number starting at 1. Increment value to paginate through results.
- limit: int
Limit of assets to return. Default is 20, max value is 500.
- to_dataframe: bool
Return data as DataFrame or list of dictionaries. Default is set to DataFrame.
- Returns
- list, DataFrame
List of dictionaries or pandas DataFrame of markets indexed by exchange slug.
- get_asset(asset_slugs: Union[str, List], asset_fields: Optional[Union[str, List]] = None, to_dataframe: bool = True) Union[Dict, pandas.core.frame.DataFrame]
Get basic metadata for an asset.
- Parameters
- asset_slugs: str, list
Single asset slug string or list of asset slugs (i.e. bitcoin).
- asset_fields: str, list
Single filter string or list of fields to filter data. Available fields include:
id
symbol
name
slug
- to_dataframe: bool
Return data as DataFrame or JSON. Default is set to DataFrame.
- Returns
- dict, DataFrame
Dictionary or pandas DataFrame with asset metadata.
- get_asset_market_data(asset_slugs: Union[str, List], to_dataframe: bool = True) Union[Dict, pandas.core.frame.DataFrame]
Get the latest market data for an asset.
- Parameters
- asset_slugs: str, list
Single asset slug string or list of asset slugs (i.e. bitcoin).
- to_dataframe: bool
Return data as DataFrame or JSON. Default is set to DataFrame.
- Returns
- dict, DataFrame
Dictionary or pandas DataFrame with asset market data.
- get_asset_metrics(asset_slugs: Union[str, List], asset_metric: Optional[str] = None, to_dataframe: bool = True) Union[Dict, pandas.core.frame.DataFrame]
Get all the quantitative metrics for an asset.
- Parameters
- asset_slugs: str, list
Single asset slug string or list of asset slugs (i.e. bitcoin).
- asset_metric: str
Single metric string to filter metric data. Available metrics include:
market_data
marketcap
supply
blockchain_stats_24_hours
market_data_liquidity
all_time_high
cycle_low
token_sale_stats
staking_stats
mining_stats
developer_activity
roi_data
roi_by_year
risk_metrics
misc_data
lend_rates
borrow_rates
loan_data
reddit
on_chain_data
exchange_flows
alert_messages
- to_dataframe: bool
Return data as DataFrame or JSON. Default is set to DataFrame.
- Returns
- dict, DataFrame
Dictionary or pandas DataFrame with asset metric data.
- get_asset_profile(asset_slugs: Union[str, List], asset_profile_metric: Optional[str] = None) Dict
Get all the qualitative information for an asset.
Data is return only in JSON format due to high number of text fields. The keys of the object are assets and the value is the associated asset data.
- Parameters
- asset_slugs: str, list
Single asset slug string or list of asset slugs (i.e. bitcoin).
- asset_profile_metric: str
Single profile metric string to filter profile data. Available metrics include:
general
contributors
advisors
investors
ecosystem
economics
technology
governance
metadata
- Returns
- dict
Dictionary with asset profile data
- get_metric_timeseries(asset_slugs: Union[str, List], asset_metric: str, start: Optional[str] = None, end: Optional[str] = None, interval: str = '1d', to_dataframe: bool = True) Union[Dict, pandas.core.frame.DataFrame]
Retrieve historical timeseries data for an asset.
- Parameters
- asset_slugs: str, list
Single asset slug string or list of asset slugs (i.e. bitcoin).
- asset_metric: str
Single metric string to filter timeseries data. Available metrics include:
- blk.cnt
The sum count of blocks created each day.
- txn.fee.avg
The USD value of the mean fee per transaction.
- txn.cnt
The sum count of transactions that interval. Transactions represent a bundle of intended actions to alter the ledger initiated by a user (human or machine). Transactions are counted whether they execute or not and whether they result in the transfer of native units.
- txn.tsfr.val.adj
The sum USD value of all native units transferred removing noise and certain artifacts.
- sply.circ
The circulating supply acknowledges that tokens may be held by projects/foundations which have no intent to sell down their positions, but which have not locked up supply in a formal contract. Thus, circulating supply does not include known project treasury holdings (which can be significant). Note that an investor must carefully consider both liquid and circulating supplies when evaluating an asset, and the two can vary significantly. A risk of depending entirely on circulating supply is that the number can change dramatically based on discretionary sales from project treasuries.
- mcap.circ
The circulating marketcap is the price of the asset multiplied by the circulating supply. If no price is found for an asset because no trades occurred, the last price of the last trade is used. After 30 days with no trades, a marketcap of 0 is reported until trading resumes.
- reddit.subscribers
The number of subscribers on the asset’s primary subreddit
- iss.rate
The percentage of new native units (continuous) issued over that interval, extrapolated to one year (i.e., multiplied by 365), and divided by the current supply at the end of that interval. Also referred to as the annual inflation rate.
- mcap.realized
The sum USD value based on the USD closing price on the day that a native unit last moved (i.e., last transacted) for all native units.
- bitwise.volume
It is well known that many exchanges conduct wash trading practices in order to inflate trading volume. They are incentivized to report inflated volumes in order to attract traders. “Bitwise Volume” refers to the total volume over 10 exchanges identified by Bitwise to be free of wash trading activities. They tend to be regulated exchanges. However, that does not necessarily mean that the volume reported by other exchanges is 100% wash trades. As such, the Bitwise Volume underestimates the total volume.
- txn.tsfr.val.avg
The sum USD value of native units transferred divided by the count of transfers (i.e., the mean “size” in USD of a transfer).
- act.addr.cnt
The sum count of unique addresses that were active in the network (either as a recipient or originator of a ledger change) that interval. All parties in a ledger change action (recipients and originators) are counted. Individual addresses are not double-counted.
- fees.ntv
The sum of all fees paid to miners in native units. Fees do not include new issuance.
- exch.flow.in.usd.incl
The sum USD value sent to exchanges that interval, including exchange to exchange activity.
- blk.size.byte
The sum of the size (in bytes) of all blocks created each day.
- txn.tsfr.val.med
The median transfer value in US dollars.
- exch.flow.in.ntv.incl
The amount of the asset sent to exchanges that interval, including exchange to exchange activity.
- exch.flow.out.usd
The sum USD value withdrawn from exchanges that interval, excluding exchange to exchange activity.’
- txn.vol
The sum USD value of all native units transferred (i.e., the aggregate size in USD of all transfers).
- fees
The sum USD value of all fees paid to miners that interval. Fees do not include new issuance.
- exch.flow.out.ntv.incl
The amount of the asset withdrawn from exchanges that interval, including exchange to exchange activity.
- exch.flow.out.usd.incl
The sum USD value withdrawn from exchanges that interval, including exchange to exchange activity.
- txn.fee.med
The USD value of the median fee per transaction.
- min.rev.ntv
The sum of all miner revenue, which constitutes fees plus newly issued native units.
- exch.sply.usd
The sum USD value of all native units held in hot or cold exchange wallets.
- diff.avg
The mean difficulty of finding a hash that meets the protocol-designated requirement (i.e., the difficulty of finding a new block) that interval. The requirement is unique to each applicable cryptocurrency protocol.
- daily.shp
The Sharpe ratio (performance of the asset compared to a “risk-free” asset) over a window of time).
- txn.tsfr.cnt
The sum count of transfers that interval. Transfers represent movements of native units from one ledger entity to another distinct ledger entity. Only transfers that are the result of a transaction and that have a positive (non-zero) value are counted.
- exch.flow.in.ntv
The amount of the asset sent to exchanges that interval, excluding exchange to exchange activity.
- new.iss.usd
The sum USD value of new native units issued that interval. Only those native units that are issued by a protocol-mandated continuous emission schedule are included (i.e., units manually released from escrow or otherwise disbursed are not included).
- mcap.dom
The marketcap dominance is the asset’s percentage share of total crypto circulating marketcap.
- daily.vol
The annualized standard-deviation of daily returns over a window of time.
- reddit.active.users
The number of active users on the asset’s primary subreddit
- exch.sply
The sum of all native units held in hot or cold exchange wallets
- nvt.adj
The ratio of the network value (or market capitalization, current supply) divided by the adjusted transfer value. Also referred to as NVT.
- exch.flow.out.ntv
The amount of the asset withdrawn from exchanges that interval, excluding exchange to exchange activity.
- min.rev.usd
The sum USD value of all miner revenue, which constitutes fees plus newly issued native units, represented as the US dollar amount earned if all native units were sold at the closing price on the same day.
- bitwise.price
Volume weighted average price over Bitwise 10 exchanges.
- new.iss.ntv
The sum of new native units issued that interval. Only those native units that are issued by a protocol-mandated continuous emission schedule are included (i.e., units manually released from escrow or otherwise disbursed are not included).
- blk.size.bytes.avg
The mean size (in bytes) of all blocks created.
- hashrate
The mean rate at which miners are solving hashes that interval.
- exch.flow.in.usd
The sum USD value sent to exchanges that interval, excluding exchange to exchange activity.
- price
Volume weighted average price computed using Messari Methodology
- real.vol
It is well known that many exchanges conduct wash trading practices in order to inflate trading volume. They are incentivized to report inflated volumes in order to attract traders. “Real Volume” refers to the total volume on the exchanges that we believe with high level of confidence are free of wash trading activities. However, that does not necessarily mean that the volume reported by other exchanges is 100% wash trades. As such, the Messari “Real Volume” applies a penalty to these exchanges to discount the volume believed to come from wash trading activity. For more information, see our methodology page.
- start: str
Starting date string for timeseries data. A default start date will provided if not specified.
- end: str
Ending date string for timeseries data. A default end date will provided if not specified.
- interval: str
Interval of timeseries data. Default value is set to 1d.
For any given interval, at most 2016 points will be returned. For example, with interval=5m, the maximum range of the request is 2016 * 5 minutes = 7 days. With interval=1h, the maximum range is 2016 * 1 hour = 84 days. Exceeding the maximum range will result in an error, which can be solved by reducing the date range specified in the request.
Anything under 1 day requires an enterprise subscription. Please email enterprise@messari.io for information.
- Interval options include:
1m
5m
15m
30m
1hr
1d
1w
- to_dataframe: bool
Return data as DataFrame or JSON. Default is set to DataFrame.
- Returns
- dict, DataFrame
Dictionary or pandas DataFrame of asset data.
DeFiLlama Class
- class messari.defillama.defillama.DeFiLlama
Bases:
messari.dataloader.DataLoader
This class is a wrapper around the DeFi Llama API
Methods
get_chain_tvl_timeseries
(chains_in[, ...])Retrive timeseries TVL for a given chain
get_current_tvl
(asset_slugs)Retrive current protocol tvl for an asset
get_global_tvl_timeseries
([start_date, end_date])Returns timeseries TVL from total of all Defi Llama supported protocols
get_protocol_tvl_timeseries
(asset_slugs[, ...])Returns times TVL of a protocol with token amounts as a pandas DataFrame.
Returns basic information on all listed protocols, their current TVL and the changes to it in the last hour/day/week
get_response
(endpoint_url[, params, headers])Gets response from endpoint and checks for HTTP errors when requesting data.
set_api_dict
(api_dict)Sets a new dictionary to be used as an API key pair
set_taxonomy_dict
(taxonomy_dict)Sets a new dictionary to be used for taxonomy translations
translate
(input_slugs)Wrapper around messari.utils.validate_input, validate input & check if it's supported by DeFi Llama
- get_chain_tvl_timeseries(chains_in: Union[str, List], start_date: Optional[Union[str, datetime.datetime]] = None, end_date: Optional[Union[str, datetime.datetime]] = None) pandas.core.frame.DataFrame
Retrive timeseries TVL for a given chain
- Parameters
- chains_in: str, list
Single asset slug string or list of asset slugs (i.e. bitcoin)
- start_date: str, datetime.datetime
Optional start date to set filter for tvl timeseries (“YYYY-MM-DD”)
- end_date: str, datetime.datetime
Optional end date to set filter for tvl timeseries (“YYYY-MM-DD”)
- Returns
- DataFrame
DataFrame containing timeseries tvl data for each chain
- get_current_tvl(asset_slugs: Union[str, List]) Dict
Retrive current protocol tvl for an asset
- Parameters
- asset_slugs: str, list
Single asset slug string or list of asset slugs (i.e. bitcoin)
- Returns
- DataFrame
Pandas Series for tvl indexed by each slug {slug: tvl, …}
- get_global_tvl_timeseries(start_date: Optional[Union[str, datetime.datetime]] = None, end_date: Optional[Union[str, datetime.datetime]] = None) pandas.core.frame.DataFrame
Returns timeseries TVL from total of all Defi Llama supported protocols
- Parameters
- start_date: str, datetime.datetime
Optional start date to set filter for tvl timeseries (“YYYY-MM-DD”)
- end_date: str, datetime.datetime
Optional end date to set filter for tvl timeseries (“YYYY-MM-DD”)
- Returns
- DataFrame
DataFrame containing timeseries tvl data for every protocol
- get_protocol_tvl_timeseries(asset_slugs: Union[str, List], start_date: Optional[Union[str, datetime.datetime]] = None, end_date: Optional[Union[str, datetime.datetime]] = None) pandas.core.frame.DataFrame
Returns times TVL of a protocol with token amounts as a pandas DataFrame. Returned DataFrame is indexed by df[protocol][chain][asset].
- Parameters
- asset_slugs: str, list
Single asset slug string or list of asset slugs (i.e. bitcoin)
- start_date: str, datetime.datetime
Optional start date to set filter for tvl timeseries (“YYYY-MM-DD”)
- end_date: str, datetime.datetime
Optional end date to set filter for tvl timeseries (“YYYY-MM-DD”)
- Returns
- DataFrame
pandas DataFrame of protocol TVL, indexed by df[protocol][chain][asset] to look at total tvl across all chains, index with chain=’all’ to look at total tvl across all tokens of a chain, asset=’totalLiquidityUSD’ tokens can be indexed by asset=’tokenName’ or by asset=’tokenName_usd’
- get_protocols() pandas.core.frame.DataFrame
Returns basic information on all listed protocols, their current TVL and the changes to it in the last hour/day/week
- Returns
- DataFrame
DataFrame with one column per DeFi Llama supported protocol