messari.defillama package

Submodules

messari.defillama.defillama module

This module is meant to contain the 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.

get_protocols()

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

messari.defillama.helpers module

This module is dedicated to helpers for the DeFiLlama class

messari.defillama.helpers.format_df(df_in: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame

format a typical DF from DL, replace date & drop duplicates

Parameters
df_in: pd.DataFrame

input DataFrame

Returns
DataFrame

formated pandas DataFrame

Module contents

Module to handle initialization, imports, for DeFiLlama class