Skip to content

Commit

Permalink
Merge branch 'release/1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
man-c committed Jul 12, 2020
2 parents 60b54f1 + b54056a commit 2e267df
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

1.3.0 / 2020-07-12
==================

* allow optional arguments for **ALL** endopoints

1.2.0 / 2019-12-13
==================

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Usage examples:
https://www.coingecko.com/api/docs/v3

### Endpoints included
> :warning: **Endpoints documentation**: To make sure that your are using properly each endpoint you should check the [API documentation](https://www.coingecko.com/api/docs/v3). Return behaviour and parameters of the endpoints, such as *pagination*, might have changed. <br> Any **optional parameters** defined in CoinGecko API doc can be passed as function parameters using same parameters names with the API *(see Examples above)*.
- *ping*
- **/ping** (Check API server status)
```python
Expand All @@ -76,7 +77,7 @@ https://www.coingecko.com/api/docs/v3
```python
cg.get_coins_list()
```
- **/coins/markets** (List all supported coins price, market cap, volume, and market related data (no pagination required))
- **/coins/markets** (List all supported coins price, market cap, volume, and market related data)
```python
cg.get_coins_markets()
```
Expand Down Expand Up @@ -130,7 +131,7 @@ https://www.coingecko.com/api/docs/v3
```python
cg.get_exchanges_by_id()
```
- **/exchanges/{id}/tickers** (Get exchange tickers (paginated))
- **/exchanges/{id}/tickers** (Get exchange tickers (paginated, 100 tickers per page))
```python
cg.get_exchanges_tickers_by_id()
```
Expand Down
68 changes: 45 additions & 23 deletions pycoingecko/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ def get_token_price(self, id, contract_addresses, vs_currencies, **kwargs):
api_url = self.__api_url_params(api_url, kwargs)
return self.__request(api_url)

def get_supported_vs_currencies(self):
def get_supported_vs_currencies(self, **kwargs):
"""Get list of supported_vs_currencies"""

api_url = '{0}simple/supported_vs_currencies'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

# ---------- COINS ----------#
Expand All @@ -97,16 +99,17 @@ def get_coins(self, **kwargs):

return self.__request(api_url)

def get_coins_list(self):
def get_coins_list(self, **kwargs):
"""List all supported coins id, name and symbol (no pagination required)"""

api_url = '{0}coins/list'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

@list_args_to_comma_separated
def get_coins_markets(self, vs_currency, **kwargs):
"""List all supported coins price, market cap, volume, and market related data (no pagination required)"""
"""List all supported coins price, market cap, volume, and market related data"""

kwargs['vs_currency'] = vs_currency

Expand Down Expand Up @@ -145,20 +148,22 @@ def get_coin_history_by_id(self, id, date, **kwargs):
return self.__request(api_url)

@list_args_to_comma_separated
def get_coin_market_chart_by_id(self, id, vs_currency, days):
def get_coin_market_chart_by_id(self, id, vs_currency, days, **kwargs):
"""Get historical market data include price, market cap, and 24h volume (granularity auto)"""

api_url = '{0}coins/{1}/market_chart?vs_currency={2}&days={3}'.format(self.api_base_url, id, vs_currency, days)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

@list_args_to_comma_separated
def get_coin_market_chart_range_by_id(self, id, vs_currency, from_timestamp, to_timestamp):
def get_coin_market_chart_range_by_id(self, id, vs_currency, from_timestamp, to_timestamp, **kwargs):
"""Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto)"""

api_url = '{0}coins/{1}/market_chart/range?vs_currency={2}&from={3}&to={4}'.format(self.api_base_url, id,
vs_currency, from_timestamp,
to_timestamp)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

Expand All @@ -173,59 +178,65 @@ def get_coin_status_updates_by_id(self, id, **kwargs):

# ---------- Contract ----------#
@list_args_to_comma_separated
def get_coin_info_from_contract_address_by_id(self, id, contract_address):
def get_coin_info_from_contract_address_by_id(self, id, contract_address, **kwargs):
"""Get coin info from contract address"""

api_url = '{0}coins/{1}/contract/{2}'.format(self.api_base_url, id, contract_address)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

@list_args_to_comma_separated
def get_coin_market_chart_from_contract_address_by_id(self, id, contract_address, vs_currency, days):
def get_coin_market_chart_from_contract_address_by_id(self, id, contract_address, vs_currency, days, **kwargs):
"""Get historical market data include price, market cap, and 24h volume (granularity auto) from a contract address"""

api_url = '{0}coins/{1}/contract/{2}/market_chart/?vs_currency={3}&days={4}'.format(self.api_base_url, id,
contract_address,
vs_currency, days)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

@list_args_to_comma_separated
def get_coin_market_chart_range_from_contract_address_by_id(self, id, contract_address, vs_currency, from_timestamp,
to_timestamp):
to_timestamp, **kwargs):
"""Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto) from a contract address"""

api_url = '{0}coins/{1}/contract/{2}/market_chart/range?vs_currency={3}&from={4}&to={5}'.format(
self.api_base_url, id, contract_address, vs_currency, from_timestamp, to_timestamp)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

# ---------- EXCHANGES ----------#
def get_exchanges_list(self):
def get_exchanges_list(self, **kwargs):
"""List all exchanges"""

api_url = '{0}exchanges'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

def get_exchanges_id_name_list(self):
def get_exchanges_id_name_list(self, **kwargs):
"""List all supported markets id and name (no pagination required)"""

api_url = '{0}exchanges/list'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

@list_args_to_comma_separated
def get_exchanges_by_id(self, id):
def get_exchanges_by_id(self, id, **kwargs):
"""Get exchange volume in BTC and tickers"""

api_url = '{0}exchanges/{1}'.format(self.api_base_url, id)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

@list_args_to_comma_separated
def get_exchanges_tickers_by_id(self, id, **kwargs):
"""Get exchange tickers (paginated)"""
"""Get exchange tickers (paginated, 100 tickers per page)"""

api_url = '{0}exchanges/{1}/tickers'.format(self.api_base_url, id)
api_url = self.__api_url_params(api_url, kwargs)
Expand Down Expand Up @@ -253,17 +264,19 @@ def get_exchanges_volume_chart_by_id(self, id, days, **kwargs):
return self.__request(api_url)

# ---------- FINANCE ----------#
def get_finance_platforms(self):
def get_finance_platforms(self, **kwargs):
"""Get cryptocurrency finance platforms data"""

api_url = '{0}finance_platforms'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

def get_finance_products(self):
def get_finance_products(self, **kwargs):
"""Get cryptocurrency finance products data"""

api_url = '{0}finance_products'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

Expand All @@ -276,25 +289,28 @@ def get_indexes(self, **kwargs):

return self.__request(api_url)

def get_indexes_by_id(self, id):
def get_indexes_by_id(self, id, **kwargs):
"""Get market index by id"""

api_url = '{0}indexes/{1}'.format(self.api_base_url, id)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

def get_indexes_list(self):
def get_indexes_list(self, **kwargs):
"""List market indexes id and name"""

api_url = '{0}indexes/list'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

# ---------- DERIVATIVES ----------#
def get_derivatives(self):
def get_derivatives(self, **kwargs):
"""List all derivative tickers"""

api_url = '{0}derivatives'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

Expand All @@ -306,17 +322,19 @@ def get_derivatives_exchanges(self, **kwargs):

return self.__request(api_url)

def get_derivatives_exchanges_by_id(self, id):
def get_derivatives_exchanges_by_id(self, id, **kwargs):
"""List all derivative tickers"""

api_url = '{0}derivatives/exchanges/{1}'.format(self.api_base_url, id)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

def get_derivatives_exchanges_list(self):
def get_derivatives_exchanges_list(self, **kwargs):
"""List all derivative tickers"""

api_url = '{0}derivatives/exchanges/list'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

Expand All @@ -340,32 +358,36 @@ def get_events(self, **kwargs):

return self.__request(api_url)

def get_events_countries(self):
def get_events_countries(self, **kwargs):
"""Get list of event countries"""

api_url = '{0}events/countries'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

def get_events_types(self):
def get_events_types(self, **kwargs):
"""Get list of event types"""

api_url = '{0}events/types'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

# ---------- EXCHANGE-RATES ----------#
def get_exchange_rates(self):
def get_exchange_rates(self, **kwargs):
"""Get BTC-to-Currency exchange rates"""

api_url = '{0}exchange_rates'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)

# ---------- GLOBAL ----------#
def get_global(self):
def get_global(self, **kwargs):
"""Get cryptocurrency global data"""

api_url = '{0}global'.format(self.api_base_url)
api_url = self.__api_url_params(api_url, kwargs)

return self.__request(api_url)['data']
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setuptools.setup(
name='pycoingecko',
version='1.2.0',
version='1.3.0',
packages=['pycoingecko',],
license='MIT',
description = 'Python wrapper around the CoinGecko API',
Expand Down

0 comments on commit 2e267df

Please sign in to comment.