Unofficial Python wrapper for DeFi Llama API client using PyCurl module.
Reason this release was yanked:
Deprecated API release
Project description
DeFiLlama Python API
Unofficial Python wrapper for the DeFi Llama API using PyCurl module
Inspired from itzmestar's DeFi Llama Python API.
For detailed information about the API endpoints, see DeFi Llama API Documentation
Installation:
Use pip to install:
pip install DeFiLlama
Authentication:
Endpoints are accessible without an API key.
Documentation:
To import the package and initialize API client
# Import library
from defillama import defillama
# Client object to interact with DeFi Llama API
llama = DefiLlama()
TVL : Retrieve TVL data -->
- GET/protocols : List all protocols on defillama along with their TVL.
llama.get_protocols()
- GET/protocol/{protocol} : Get historical TVL of a protocol and breakdown by token and chain.
# For e.g. aave
llama.get_protocol(protocol='aave')
- GET/charts : Get historical TVL of DeFi on all chains.
llama.get_charts()
- GET/charts/{chain} : Get historical TVL of a chain.
Chains can be obtained from GET/chains or the chains property on GET/protocols.
# For e.g. Ethereum
llama.get_chart(chain='Ethereum')
- GET/tvl/{protocol} : Get only protocol TVL as a number.
# For e.g. uniswap
llama.get_tvl_protocol(protocol='uniswap')
- GET/chains : Get current TVL of all chains.
llama.get_chains()
coins : General blockchain data used by DeFi Llama and open-sourced -->
- GET/block/{chain}/{timestamp} : Get the closest block on a timestamp (UNIX formatted).
Runs binary search over a blockchain's blocks to get the closest one to a timestamp.
Every time this is run DeFi Llama adds new data to their database, so each query permanently speeds up future queries.
# For e.g. Fantom chain for timestamp 1650207158
llama.get_block_timestamp(block='fantom', timestamp=1650207158)
- POST/prices : Get current or historical prices of tokens by contract address.
If timestamp is not provided we just return the latest data.
# Sample data JSON
body = {
"coins": [
"ethereum:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"avax:0xd586e7f844cea2f87f50152665bcbc2c279d8d70"
],
"timestamp": 1603964988
}
# API usage
llama.post_prices(data=body)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
DeFiLlama-Curl-1.0.tar.gz
(8.3 kB
view hashes)
Built Distribution
Close
Hashes for DeFiLlama_Curl-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27d4d5809d95a00b2a614a9fddf614313fd199768300a785a6b52696aea9eee5 |
|
MD5 | 013b95c2c3c0104dbf99af2c2ea59566 |
|
BLAKE2b-256 | 14efeeda2e7fcdd3d38a93d63d249b50c98d647ac0f782cc0100bf179fa31fa1 |