Python wrapper for the CoinGecko API
Project description
Python API wrapper for CoinGecko API
This CoinGecko Python library provides convenient access to CoinGecko API.
Requirements
- Python 3.0+
- requests
Installations
The recommended way to install coingecko API wrapper is via pip
pip install --upgrade coingecko
Quickstart
Before you start, visit coingecko to obtain a demo/paid API key. After that, you can start using the API by:
import coingecko
# Demo API key
client = coingecko.CoinGeckoDemoClient(api_key=<insert_your_demo_api_key>)
# Paid API key
client = coingecko.CoinGeckoProClient(api_key=<insert_your_paid_api_key>)
# Test your API key with ping
response = client.ping.get()
Documentation
For the list of endpoints and information, visit CoinGecko API Documentation
Examples
The default values and parameter namings for each endpoints follows the official documentation.
Making your first API Call, PING!
response = client.ping.get()
# -> {'gecko_says': '(V3) To the Moon!'}
Just want to get price? Simple!
# /simple/price - one coin_id/currency
response = client.simple.get_price(ids='bitcoin', vs_currencies='usd')
# -> {'bitcoin': {'usd': 40067}}
Use List from Python instead of comma separated strings!
# /simple/price - multiple coin_ids (pass in a list of strings)
response = client.simple.get_price(ids=['bitcoin', 'ethereum'], vs_currencies=['usd', 'myr'])
# -> {'bitcoin': {'usd': 40067, 'myr': 189478}, 'ethereum': {'usd': 2223.37, 'myr': 10514.34}}
Use booleans instead of string for "true"/"false"
# /simple/price - pass in booleans instead of string
response = client.simple.get_price(ids='bitcoin', vs_currencies='usd', include_24hr_vol=True)
# -> {'bitcoin': {'usd': 40067, 'usd_24h_vol': 16742608673.077057}}
For precisions, use Integer/Strings
# simple/price - precision accepts integer/string
response = client.simple.get_price(ids='bitcoin', vs_currencies='usd', precision=2)
# -> {'bitcoin': {'usd': 40066.81}}
response = client.simple.get_price(ids='bitcoin', vs_currencies='usd', precision="2")
# {'bitcoin': {'usd': 40066.81}}
Need more examples?
Check out here!
License
The library is available as open source under the terms of the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file coingecko-0.14.tar.gz
.
File metadata
- Download URL: coingecko-0.14.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d58caed14c701ad16c7a5087d37cbef60b40ffb3338b50dafdd38b3960c68b6b |
|
MD5 | 24f32b098697fff5d2d1ed4835094393 |
|
BLAKE2b-256 | cc299f5adbce72be62fafabfcfadaa3412b21baea458d18d890cdf4d4c0a7f62 |
File details
Details for the file coingecko-0.14-py3-none-any.whl
.
File metadata
- Download URL: coingecko-0.14-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d1115169fd34fdc843e3e4e28caacd37326fbdb461920357709c733ebf81634 |
|
MD5 | f665b564d7fcb9ed4378e48ebd99d8b2 |
|
BLAKE2b-256 | 2ee9fa9ec85d53816ce53d2e60d10c2a4c7dfe547e12a9ec3c64a1ef759b0447 |