defillama2


Namedefillama2 JSON
Version 0.7.5 PyPI version JSON
download
home_pagehttps://github.com/coindataschool/defillama2
SummaryPython client for DefiLlama API
upload_time2023-07-23 23:21:18
maintainer
docs_urlNone
authorCoin Data School
requires_python
license
keywords python 3 defillama api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # defillama2

[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)
[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/)
[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/)
[![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-390/)
[![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3100/)

## Python client for DeFiLlama API

Download data from DefiLlama.com via its [APIs](https://defillama.com/docs/api). 
This package gets you tidy pandas data frames that are ready for downstream 
analysis and modeling.

![](https://github.com/coindataschool/defillama2/blob/main/splash.png)

### Installation

`pip install defillama2`

### Quick Start

```
from defillama2 import DefiLlama

# create a DefiLlama instance
obj = DefiLlama()

# get historical DeFi TVL on all chains
obj.get_defi_hist_tvl()                   # don't give any input

# get historical TVL of a specific chain
obj.get_chain_hist_tvl('Arbitrum')

# get current TVL of all chains
obj.get_chains_curr_tvl()                 # don't give any input

# get current TVL of a specific protocol
obj.get_protocol_curr_tvl('gmx')     

# get current TVL of a specific protocol by chain
obj.get_protocol_curr_tvl_by_chain('gmx') 

# get historical TVL of a specific protocol by chain
obj.get_protocol_hist_tvl_by_chain('gmx') 

# get fundamentals for all protocols
obj.get_protocols_fundamentals()          # don't give any input

# consider the following tokens and chains
dd = {# GMX on arbitrum
      '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a':'arbitrum',  
      # GMX on avalanche
      '0x62edc0692BD897D2295872a9FFCac5425011c661':'avax',      
      # GLP on arbitrum
      '0x4277f8f2c384827b5273592ff7cebd9f2c1ac258':'arbitrum',  
      # GLP on avalanche
      '0x01234181085565ed162a948b6a5e88758CD7c7b8':'avax',      
      }

# get their current prices
obj.get_tokens_curr_prices(dd)

# get their prices at a specific time '2022-09-15 13:25:43'
obj.get_tokens_hist_snapshot_prices(dd, '2022-09-15 13:25:43')

# get their historical daily close/open prices 
obj.get_daily_open_close(dd, start='2022-08-01', end='2022-09-01', kind='close')
obj.get_daily_open_close(dd, start='2022-08-01', end='2022-09-01', kind='open')

# get hourly prices
obj.get_tokens_hist_prices(dd, start='2022-11-12', end='2022-11-14', freq='hour')

# get daily open, high, low, close, mean, median, std of prices
obj.get_tokens_hist_prices(dd, start='2022-11-12', end='2022-11-14', freq='daily')

# get basic info on all stablecoins, along with their circulating amounts
obj.get_stablecoins_circulating()          # don't give any input

# get all stablecoins' circulating amounts for each chain
obj.get_stablecoins_circulating_by_chain() # don't give any input

# get historical mcaps of a stablecoin, for example, USDT
obj.get_stablecoin_hist_mcap(1) # 1 is USDT

# get historical mcaps of a stablecoin on a particular chain, for example, 
# USDT on ethereum
obj.get_stablecoin_hist_mcap_on_a_chain(1, 'ethereum') 

# get current total mcap of all stablecoins on each chain
obj.get_stablecoins_curr_mcap_by_chain()   # don't give any input

# get historical prices of all stablecoins
obj.get_stablecoins_prices()               # don't give any input

# get the latest yields for all available pools, along with other information
obj.get_pools_yields()

# get the historical APY and TVL of a pool
obj.get_pool_hist_apy(pool_id)  # pool_id can be obtained from get_pools_yields()
```

### Demo Code

- [Get TVL and other fundamental data](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_tvl.ipynb).
- [Get on-chain prices, including exotic tokens](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_coins.ipynb).
- [Get circulating amount, mcap, prices and other data points for stablecoins](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_stablecoins.ipynb).
- [Get liquidity pools' yields data](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_yields.ipynb).
- [Get dexes volumes](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_volumes.ipynb)
- [Get bridges transaction tokens and volumes](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_bridges.ipynb)
- [Get protocols fees and revenue](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_fees_and_revenue.ipynb)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/coindataschool/defillama2",
    "name": "defillama2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python 3,defillama,api",
    "author": "Coin Data School",
    "author_email": "<coindataschool@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c8/20/c4dd00d589cc99b4300b6de07b95517bfc2c1660ae5fff574f01ba6da9af/defillama2-0.7.5.tar.gz",
    "platform": null,
    "description": "# defillama2\n\n[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)\n[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/)\n[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/)\n[![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-390/)\n[![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3100/)\n\n## Python client for DeFiLlama API\n\nDownload data from DefiLlama.com via its [APIs](https://defillama.com/docs/api). \nThis package gets you tidy pandas data frames that are ready for downstream \nanalysis and modeling.\n\n![](https://github.com/coindataschool/defillama2/blob/main/splash.png)\n\n### Installation\n\n`pip install defillama2`\n\n### Quick Start\n\n```\nfrom defillama2 import DefiLlama\n\n# create a DefiLlama instance\nobj = DefiLlama()\n\n# get historical DeFi TVL on all chains\nobj.get_defi_hist_tvl()                   # don't give any input\n\n# get historical TVL of a specific chain\nobj.get_chain_hist_tvl('Arbitrum')\n\n# get current TVL of all chains\nobj.get_chains_curr_tvl()                 # don't give any input\n\n# get current TVL of a specific protocol\nobj.get_protocol_curr_tvl('gmx')     \n\n# get current TVL of a specific protocol by chain\nobj.get_protocol_curr_tvl_by_chain('gmx') \n\n# get historical TVL of a specific protocol by chain\nobj.get_protocol_hist_tvl_by_chain('gmx') \n\n# get fundamentals for all protocols\nobj.get_protocols_fundamentals()          # don't give any input\n\n# consider the following tokens and chains\ndd = {# GMX on arbitrum\n      '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a':'arbitrum',  \n      # GMX on avalanche\n      '0x62edc0692BD897D2295872a9FFCac5425011c661':'avax',      \n      # GLP on arbitrum\n      '0x4277f8f2c384827b5273592ff7cebd9f2c1ac258':'arbitrum',  \n      # GLP on avalanche\n      '0x01234181085565ed162a948b6a5e88758CD7c7b8':'avax',      \n      }\n\n# get their current prices\nobj.get_tokens_curr_prices(dd)\n\n# get their prices at a specific time '2022-09-15 13:25:43'\nobj.get_tokens_hist_snapshot_prices(dd, '2022-09-15 13:25:43')\n\n# get their historical daily close/open prices \nobj.get_daily_open_close(dd, start='2022-08-01', end='2022-09-01', kind='close')\nobj.get_daily_open_close(dd, start='2022-08-01', end='2022-09-01', kind='open')\n\n# get hourly prices\nobj.get_tokens_hist_prices(dd, start='2022-11-12', end='2022-11-14', freq='hour')\n\n# get daily open, high, low, close, mean, median, std of prices\nobj.get_tokens_hist_prices(dd, start='2022-11-12', end='2022-11-14', freq='daily')\n\n# get basic info on all stablecoins, along with their circulating amounts\nobj.get_stablecoins_circulating()          # don't give any input\n\n# get all stablecoins' circulating amounts for each chain\nobj.get_stablecoins_circulating_by_chain() # don't give any input\n\n# get historical mcaps of a stablecoin, for example, USDT\nobj.get_stablecoin_hist_mcap(1) # 1 is USDT\n\n# get historical mcaps of a stablecoin on a particular chain, for example, \n# USDT on ethereum\nobj.get_stablecoin_hist_mcap_on_a_chain(1, 'ethereum') \n\n# get current total mcap of all stablecoins on each chain\nobj.get_stablecoins_curr_mcap_by_chain()   # don't give any input\n\n# get historical prices of all stablecoins\nobj.get_stablecoins_prices()               # don't give any input\n\n# get the latest yields for all available pools, along with other information\nobj.get_pools_yields()\n\n# get the historical APY and TVL of a pool\nobj.get_pool_hist_apy(pool_id)  # pool_id can be obtained from get_pools_yields()\n```\n\n### Demo Code\n\n- [Get TVL and other fundamental data](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_tvl.ipynb).\n- [Get on-chain prices, including exotic tokens](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_coins.ipynb).\n- [Get circulating amount, mcap, prices and other data points for stablecoins](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_stablecoins.ipynb).\n- [Get liquidity pools' yields data](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_yields.ipynb).\n- [Get dexes volumes](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_volumes.ipynb)\n- [Get bridges transaction tokens and volumes](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_bridges.ipynb)\n- [Get protocols fees and revenue](https://github.com/coindataschool/defillama2/blob/main/notebooks/defillama_api_fees_and_revenue.ipynb)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python client for DefiLlama API",
    "version": "0.7.5",
    "project_urls": {
        "Homepage": "https://github.com/coindataschool/defillama2"
    },
    "split_keywords": [
        "python 3",
        "defillama",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bc567390738a7b43d84c3c7b47f6302dfd00c76158535c77e6d072e51b3ccc6a",
                "md5": "00e10d8dbf8c42ae3d2cdec87c38c595",
                "sha256": "7df28856d32a941163104c223fdf6023d3e2927c0cf994785da94cb7ca3d3d09"
            },
            "downloads": -1,
            "filename": "defillama2-0.7.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "00e10d8dbf8c42ae3d2cdec87c38c595",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 13168,
            "upload_time": "2023-07-23T23:21:16",
            "upload_time_iso_8601": "2023-07-23T23:21:16.443017Z",
            "url": "https://files.pythonhosted.org/packages/bc/56/7390738a7b43d84c3c7b47f6302dfd00c76158535c77e6d072e51b3ccc6a/defillama2-0.7.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c820c4dd00d589cc99b4300b6de07b95517bfc2c1660ae5fff574f01ba6da9af",
                "md5": "42d9c66a1bd86f10487910175cc05353",
                "sha256": "a84509f31a4c88f73a2aa5b3dda961a4684ace6cd6338b7a4b03ceedbf3c6d82"
            },
            "downloads": -1,
            "filename": "defillama2-0.7.5.tar.gz",
            "has_sig": false,
            "md5_digest": "42d9c66a1bd86f10487910175cc05353",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 1331136,
            "upload_time": "2023-07-23T23:21:18",
            "upload_time_iso_8601": "2023-07-23T23:21:18.923761Z",
            "url": "https://files.pythonhosted.org/packages/c8/20/c4dd00d589cc99b4300b6de07b95517bfc2c1660ae5fff574f01ba6da9af/defillama2-0.7.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-23 23:21:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "coindataschool",
    "github_project": "defillama2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "defillama2"
}
        
Elapsed time: 0.26120s