Skip to content

Commit

Permalink
updated check if pro version in __api_url_params & updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
man-c committed Aug 30, 2022
1 parent 5e837e4 commit 1b9d527
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@ python3 setup.py install

### Usage

For **free API**:
```python
from pycoingecko import CoinGeckoAPI
cg = CoinGeckoAPI()
```

For users with **Pro API** Key:
```python
from pycoingecko import CoinGeckoAPI
cg = pycoingecko.CoinGeckoAPI(api_key='YOUR_API_KEY')
```

### Examples
The required parameters for each endpoint are defined as required (mandatory) parameters for the corresponding functions.\
**Any optional parameters** can be passed using same names, as defined in CoinGecko API doc (https://www.coingecko.com/api/docs/v3)
**Any optional parameters** can be passed using same names, as defined in CoinGecko API doc (https://www.coingecko.com/en/api/documentation)

For any parameter:
- ***Lists** are supported as input for multiple-valued comma-separated parameters\
Expand Down Expand Up @@ -58,10 +65,10 @@ Usage examples:
```

### API documentation
https://www.coingecko.com/api/docs/v3
https://www.coingecko.com/en/api/documentation

### 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)*.
> :warning: **Endpoints documentation**: To make sure that you are using properly each endpoint you should check the [API documentation](https://www.coingecko.com/en/api/documentation). 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)*.
<details><summary>ping</summary>
<p>
Expand Down
6 changes: 3 additions & 3 deletions pycoingecko/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, api_base_url=__API_URL_BASE, api_key: str = '', retries=5):
self.session.mount('https://', HTTPAdapter(max_retries=retries))

def __request(self, url):
print(url)
# print(url)
try:
response = self.session.get(url, timeout=self.request_timeout)
except requests.exceptions.RequestException:
Expand All @@ -46,8 +46,8 @@ def __request(self, url):
raise

def __api_url_params(self, api_url, params, api_url_has_params=False):
# if using pro version of coingecko, inject key in every call
if len(self.api_key) > 0:
# if using pro version of CoinGecko, inject key in every call
if self.api_key:
params['x_cg_pro_api_key'] = self.api_key

if params:
Expand Down

0 comments on commit 1b9d527

Please sign in to comment.