Skip to main content

Python wrapper for the CoinGecko API

Project description

PyPI PyPI - Downloads

Python API wrapper for CoinGecko API

This CoinGecko Python library provides convenient access to CoinGecko API.

Requirements

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

coingecko-0.13.tar.gz (11.9 kB view hashes)

Uploaded Source

Built Distribution

coingecko-0.13-py3-none-any.whl (17.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page