Python wrapper for coingecko.com v3 api
Project description
python-coingecko
A Python wrapper for coingecko.com V3 api. Other notable api wrappers that didn't satisfy my need:- pycoingecko has not been active in over two years and does not support the newer api endpoints
Features
- 🪙 CoinGecko api routes, including current beta
- ♻️ Retry Strategy Sensible defaults to reliably retry/back-off fetching data from coingecko
- ✏️ MyPy Fully typed using most recent versions
- ⚒️ Modern tooling using uv, ruff, and pre-commit
- 📥 GitHub Actions CI/CD to automate everything
- ↩️ Code Coverage Fully tested using tools like Codecov
- 🐍 Python Support All minor versions from 3.9 are supported
Installation
$ pip install python-coingecko
Usage
Demo (free)
>>> from pycoingecko import CoinGecko
>>> coingecko = CoinGecko(api_key=<YOUR_API_KEY>)
>>> coingecko.simple.price_by_id(ids="bitcoin", include_24hr_vol=True) # can use regular Python boolean...will get converted to string
{
"bitcoin": {
"usd": 67187.3358936566,
"usd_market_cap": 1317802988326.25,
"usd_24h_vol": 31260929299.5248,
"usd_24h_change": 3.63727894677354,
"last_updated_at": 1711356300
}
}
Pro
>>> from pycoingecko import CoinGecko
>>> coingecko = CoinGecko(api_key=<YOUR_API_KEY>, is_pro=True)
>>> coingecko.coins.recently_added()
[
{
"id": "long-johnson",
"symbol": "olong",
"name": "Long Johnson",
"activated_at": 1712562430
},
{
"id": "dogita",
"symbol": "doga",
"name": "DOGITA",
"activated_at": 1712562282
},
{
"id": "bebe-on-base",
"symbol": "bebe",
"name": "Bebe on Base",
"activated_at": 1712561709
}
]
On Chain (Pro)
>>> from pycoingecko import CoinGecko
>>> coingecko = CoinGecko(api_key=<YOUR_API_KEY>, is_pro=True)
>>> coingecko.onchain_pools.trending_list_by_network(network="eth", include="base_token")
{
"data": [
{
"id": "eth_0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
"type": "pool",
"attributes": {
"base_token_price_usd": "3653.12491645176",
...
}
...
}
]
}
Development
To develop on this project, you'll need uv installed.
Install dev dependencies
$ uv sync
Run linters black/ruff/isort/mypy
$ make lint-all
Run pytest
$ make test
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
python_coingecko-0.0.9.tar.gz
(17.4 kB
view details)
File details
Details for the file python_coingecko-0.0.9.tar.gz
.
File metadata
- Download URL: python_coingecko-0.0.9.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddf4d432846ee6ea55de75722a83c042e62445f4f6d8ccf1491175f69ce25996 |
|
MD5 | a318f6913fe250b1c01607f98937a547 |
|
BLAKE2b-256 | 4dd6a152cb26bdc0fd8fcd762fbb96eb4e687b78d3a328168ac424e77946517b |