Skip to content

JoyceBi9551/coingecko-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

This CoinGecko Python library provides convenient access to CoinGecko API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%