Skip to content

Commit 0abd51b

Browse files
committedOct 26, 2022
Merge branch 'release/3.1.0'
2 parents 151bfa1 + 66f0c38 commit 0abd51b

File tree

5 files changed

+136
-85
lines changed

5 files changed

+136
-85
lines changed
 

‎CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11

2+
3.1.0 / 2022-10-26
3+
==================
4+
5+
* added nfts (beta) endpoints (/nfts/list, /nfts/{id}, /nfts/{asset_platform_id}/contract/{contract_address})
6+
* updated tests
7+
28
3.0.0 / 2022-09-01
39
==================
410

‎README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,23 @@ cg.get_indexes_list()
274274
```
275275
</details>
276276

277+
<details><summary>nfts (beta)</summary>
278+
<p>
279+
280+
* **/nfts/list** (List all supported NFT ids, paginated by 100 items per page, paginated to 100 items)
281+
```python
282+
cg.get_nfts_list()
283+
```
284+
* **/nfts/{id}** (Get current data (name, price_floor, volume_24h ...) for an NFT collection. native_currency (string) is only a representative of the currency.)
285+
```python
286+
cg.get_nfts_by_id()
287+
```
288+
* **/nfts/{asset_platform_id}/contract/{contract_address}** (Get current data (name, price_floor, volume_24h ...) for an NFT collection. native_currency (string) is only a representative of the currency)
289+
```python
290+
cg.get_nfts_collection_by_asset_platform_id_and_contract_address()
291+
```
292+
</details>
293+
277294
[//]: # (<details><summary>status_updates</summary>)
278295

279296
[//]: # (<p>)
@@ -360,7 +377,7 @@ cg.get_indexes_list()
360377
```
361378
</details>
362379

363-
<details><summary>companies</summary>
380+
<details><summary>companies (beta)</summary>
364381
<p>
365382

366383
- **/companies/public_treasury/{coin_id}** (Get public companies data)

‎pycoingecko/api.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,34 @@ def get_derivatives_exchanges_list(self, **kwargs):
419419

420420
return self.__request(api_url)
421421

422+
# ---------- NFTS (BETA) ----------#
423+
@func_args_preprocessing
424+
def get_nfts_list(self, **kwargs):
425+
"""List all supported NFT ids, paginated by 100 items per page, paginated to 100 items"""
426+
427+
api_url = '{0}nfts/list'.format(self.api_base_url)
428+
api_url = self.__api_url_params(api_url, kwargs)
429+
430+
return self.__request(api_url)
431+
432+
@func_args_preprocessing
433+
def get_nfts_by_id(self, id, **kwargs):
434+
"""Get current data (name, price_floor, volume_24h ...) for an NFT collection. native_currency (string) is only a representative of the currency"""
435+
436+
api_url = '{0}nfts/{1}'.format(self.api_base_url, id)
437+
api_url = self.__api_url_params(api_url, kwargs)
438+
439+
return self.__request(api_url)
440+
441+
@func_args_preprocessing
442+
def get_nfts_by_asset_platform_id_and_contract_address(self, asset_platform_id, contract_address, **kwargs):
443+
"""Get current data (name, price_floor, volume_24h ...) for an NFT collection. native_currency (string) is only a representative of the currency"""
444+
445+
api_url = '{0}nfts/{1}/contract/{2}'.format(self.api_base_url, asset_platform_id, contract_address)
446+
api_url = self.__api_url_params(api_url, kwargs)
447+
448+
return self.__request(api_url)
449+
422450
# # ---------- STATUS UPDATES ----------#
423451
# @func_args_preprocessing
424452
# def get_status_updates(self, **kwargs):
@@ -514,4 +542,4 @@ def get_companies_public_treasury_by_coin_id(self, coin_id, **kwargs):
514542
api_url = '{0}companies/public_treasury/{1}'.format(self.api_base_url, coin_id)
515543
api_url = self.__api_url_params(api_url, kwargs)
516544

517-
return self.__request(api_url)
545+
return self.__request(api_url)

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setuptools.setup(
55
name='pycoingecko',
6-
version='3.0.0',
6+
version='3.1.0',
77
packages=['pycoingecko',],
88
license='MIT',
99
description = 'Python wrapper around the CoinGecko API',

‎tests/test_api.py

+82-82
Original file line numberDiff line numberDiff line change
@@ -344,31 +344,31 @@ def test_get_coin_market_chart_by_id(self):
344344

345345

346346
#---------- /price/coins/{id}/status_updates ----------#
347-
@responses.activate
348-
def test_failed_get_coin_status_updates_by_id(self):
349-
# Arrange
350-
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/coins/litecoin/status_updates',
351-
status = 404)
352-
exception = HTTPError("HTTP Error")
353-
354-
# Act Assert
355-
with pytest.raises(HTTPError) as HE:
356-
CoinGeckoAPI().get_coin_status_updates_by_id('litecoin')
357-
358-
359-
@responses.activate
360-
def test_get_coin_status_updates_by_id(self):
361-
# Arrange
362-
json_response = [ {'description': 'Travala.com Partners with Litecoin Foundation to Champion Crypto Payments. \r\n#TravelWithLitecoin www.travala.com/litecoin\r\n\r\nRead the full announcement here: bit.ly/2LumY3b', 'category': 'general', 'created_at': '2019-05-14T13:56:43.282Z', 'user': 'Keith Yong', 'user_title': 'Operations Director', 'pin': False, 'project': {'type': 'Coin', 'id': 'litecoin', 'name': 'Litecoin', 'symbol': 'ltc', 'image': {'thumb': 'https://assets.coingecko.com/coins/images/2/thumb/litecoin.png?1547033580', 'small': 'https://assets.coingecko.com/coins/images/2/small/litecoin.png?1547033580', 'large': 'https://assets.coingecko.com/coins/images/2/large/litecoin.png?1547033580'}}} ]
363-
364-
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/coins/litecoin/status_updates',
365-
json = json_response, status = 200)
366-
367-
# Act
368-
response = CoinGeckoAPI().get_coin_status_updates_by_id('litecoin')
369-
370-
## Assert
371-
assert response == json_response
347+
# @responses.activate
348+
# def test_failed_get_coin_status_updates_by_id(self):
349+
# # Arrange
350+
# responses.add(responses.GET, 'https://api.coingecko.com/api/v3/coins/litecoin/status_updates',
351+
# status = 404)
352+
# exception = HTTPError("HTTP Error")
353+
#
354+
# # Act Assert
355+
# with pytest.raises(HTTPError) as HE:
356+
# CoinGeckoAPI().get_coin_status_updates_by_id('litecoin')
357+
#
358+
#
359+
# @responses.activate
360+
# def test_get_coin_status_updates_by_id(self):
361+
# # Arrange
362+
# json_response = [ {'description': 'Travala.com Partners with Litecoin Foundation to Champion Crypto Payments. \r\n#TravelWithLitecoin www.travala.com/litecoin\r\n\r\nRead the full announcement here: bit.ly/2LumY3b', 'category': 'general', 'created_at': '2019-05-14T13:56:43.282Z', 'user': 'Keith Yong', 'user_title': 'Operations Director', 'pin': False, 'project': {'type': 'Coin', 'id': 'litecoin', 'name': 'Litecoin', 'symbol': 'ltc', 'image': {'thumb': 'https://assets.coingecko.com/coins/images/2/thumb/litecoin.png?1547033580', 'small': 'https://assets.coingecko.com/coins/images/2/small/litecoin.png?1547033580', 'large': 'https://assets.coingecko.com/coins/images/2/large/litecoin.png?1547033580'}}} ]
363+
#
364+
# responses.add(responses.GET, 'https://api.coingecko.com/api/v3/coins/litecoin/status_updates',
365+
# json = json_response, status = 200)
366+
#
367+
# # Act
368+
# response = CoinGeckoAPI().get_coin_status_updates_by_id('litecoin')
369+
#
370+
# ## Assert
371+
# assert response == json_response
372372

373373

374374
#---------- /price/coins/{id}/contract/{contract_address} ----------#
@@ -577,60 +577,60 @@ def test_get_global(self):
577577

578578

579579

580-
#---------- FINANCE ----------#
581-
582-
#---------- /finance_platforms ----------#
583-
584-
@responses.activate
585-
def test_failed_get_finance_platforms(self):
586-
# Arrange
587-
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/finance_platforms',
588-
status = 404)
589-
exception = HTTPError("HTTP Error")
590-
591-
# Act Assert
592-
with pytest.raises(HTTPError) as HE:
593-
CoinGeckoAPI().get_finance_platforms()
594-
595-
@responses.activate
596-
def test_get_finance_platforms(self):
597-
# Arrange
598-
json_response = [{"name": "Binance Lending", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Celsius Network", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Compound Finance", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "dYdX", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Nexo", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Staked US", "facts": "", "category": "", "centralized": False, "website_url": "https://staked.us/"}, {"name": "Cobo", "facts": "", "category": "", "centralized": False, "website_url": "https://cobo.com/"}, {"name": "Crypto.com", "facts": "", "category": "", "centralized": True, "website_url": "https://crypto.com/en/"}]
599-
600-
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/finance_platforms',
601-
json = json_response, status = 200)
602-
603-
# Act
604-
response = CoinGeckoAPI().get_finance_platforms()
605-
606-
## Assert
607-
expected_response = [{"name": "Binance Lending", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Celsius Network", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Compound Finance", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "dYdX", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Nexo", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Staked US", "facts": "", "category": "", "centralized": False, "website_url": "https://staked.us/"}, {"name": "Cobo", "facts": "", "category": "", "centralized": False, "website_url": "https://cobo.com/"}, {"name": "Crypto.com", "facts": "", "category": "", "centralized": True, "website_url": "https://crypto.com/en/"}]
608-
assert response == expected_response
609-
610-
#---------- /finance_products ----------#
611-
612-
@responses.activate
613-
def test_failed_get_finance_products(self):
614-
# Arrange
615-
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/finance_products',
616-
status = 404)
617-
exception = HTTPError("HTTP Error")
618-
619-
# Act Assert
620-
with pytest.raises(HTTPError) as HE:
621-
CoinGeckoAPI().get_finance_products()
622-
623-
@responses.activate
624-
def test_get_finance_products(self):
625-
# Arrange
626-
json_response = [{"name": "Binance Lending", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Celsius Network", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Compound Finance", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "dYdX", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Nexo", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Staked US", "facts": "", "category": "", "centralized": False, "website_url": "https://staked.us/"}, {"name": "Cobo", "facts": "", "category": "", "centralized": False, "website_url": "https://cobo.com/"}, {"name": "Crypto.com", "facts": "", "category": "", "centralized": True, "website_url": "https://crypto.com/en/"}]
627-
628-
responses.add(responses.GET, 'https://api.coingecko.com/api/v3/finance_platforms',
629-
json = json_response, status = 200)
630-
631-
# Act
632-
response = CoinGeckoAPI().get_finance_platforms()
633-
634-
## Assert
635-
expected_response = [{"name": "Binance Lending", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Celsius Network", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Compound Finance", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "dYdX", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Nexo", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Staked US", "facts": "", "category": "", "centralized": False, "website_url": "https://staked.us/"}, {"name": "Cobo", "facts": "", "category": "", "centralized": False, "website_url": "https://cobo.com/"}, {"name": "Crypto.com", "facts": "", "category": "", "centralized": True, "website_url": "https://crypto.com/en/"}]
636-
assert response == expected_response
580+
# #---------- FINANCE ----------#
581+
#
582+
# #---------- /finance_platforms ----------#
583+
#
584+
# @responses.activate
585+
# def test_failed_get_finance_platforms(self):
586+
# # Arrange
587+
# responses.add(responses.GET, 'https://api.coingecko.com/api/v3/finance_platforms',
588+
# status = 404)
589+
# exception = HTTPError("HTTP Error")
590+
#
591+
# # Act Assert
592+
# with pytest.raises(HTTPError) as HE:
593+
# CoinGeckoAPI().get_finance_platforms()
594+
#
595+
# @responses.activate
596+
# def test_get_finance_platforms(self):
597+
# # Arrange
598+
# json_response = [{"name": "Binance Lending", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Celsius Network", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Compound Finance", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "dYdX", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Nexo", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Staked US", "facts": "", "category": "", "centralized": False, "website_url": "https://staked.us/"}, {"name": "Cobo", "facts": "", "category": "", "centralized": False, "website_url": "https://cobo.com/"}, {"name": "Crypto.com", "facts": "", "category": "", "centralized": True, "website_url": "https://crypto.com/en/"}]
599+
#
600+
# responses.add(responses.GET, 'https://api.coingecko.com/api/v3/finance_platforms',
601+
# json = json_response, status = 200)
602+
#
603+
# # Act
604+
# response = CoinGeckoAPI().get_finance_platforms()
605+
#
606+
# ## Assert
607+
# expected_response = [{"name": "Binance Lending", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Celsius Network", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Compound Finance", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "dYdX", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Nexo", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Staked US", "facts": "", "category": "", "centralized": False, "website_url": "https://staked.us/"}, {"name": "Cobo", "facts": "", "category": "", "centralized": False, "website_url": "https://cobo.com/"}, {"name": "Crypto.com", "facts": "", "category": "", "centralized": True, "website_url": "https://crypto.com/en/"}]
608+
# assert response == expected_response
609+
#
610+
# #---------- /finance_products ----------#
611+
#
612+
# @responses.activate
613+
# def test_failed_get_finance_products(self):
614+
# # Arrange
615+
# responses.add(responses.GET, 'https://api.coingecko.com/api/v3/finance_products',
616+
# status = 404)
617+
# exception = HTTPError("HTTP Error")
618+
#
619+
# # Act Assert
620+
# with pytest.raises(HTTPError) as HE:
621+
# CoinGeckoAPI().get_finance_products()
622+
#
623+
# @responses.activate
624+
# def test_get_finance_products(self):
625+
# # Arrange
626+
# json_response = [{"name": "Binance Lending", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Celsius Network", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Compound Finance", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "dYdX", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Nexo", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Staked US", "facts": "", "category": "", "centralized": False, "website_url": "https://staked.us/"}, {"name": "Cobo", "facts": "", "category": "", "centralized": False, "website_url": "https://cobo.com/"}, {"name": "Crypto.com", "facts": "", "category": "", "centralized": True, "website_url": "https://crypto.com/en/"}]
627+
#
628+
# responses.add(responses.GET, 'https://api.coingecko.com/api/v3/finance_platforms',
629+
# json = json_response, status = 200)
630+
#
631+
# # Act
632+
# response = CoinGeckoAPI().get_finance_platforms()
633+
#
634+
# ## Assert
635+
# expected_response = [{"name": "Binance Lending", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Celsius Network", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Compound Finance", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "dYdX", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Nexo", "facts": "", "category": "", "centralized": False, "website_url": ""}, {"name": "Staked US", "facts": "", "category": "", "centralized": False, "website_url": "https://staked.us/"}, {"name": "Cobo", "facts": "", "category": "", "centralized": False, "website_url": "https://cobo.com/"}, {"name": "Crypto.com", "facts": "", "category": "", "centralized": True, "website_url": "https://crypto.com/en/"}]
636+
# assert response == expected_response

0 commit comments

Comments
 (0)
Please sign in to comment.