From ac727f6a6f69d830e7b2252c5a8d8a6b84fed8db Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Thu, 9 Mar 2023 15:24:19 +0000 Subject: automatic import of python-pycoingecko --- .gitignore | 1 + python-pycoingecko.spec | 1300 +++++++++++++++++++++++++++++++++++++++++++++++ sources | 1 + 3 files changed, 1302 insertions(+) create mode 100644 python-pycoingecko.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore index e69de29..2fffef2 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/pycoingecko-3.1.0.tar.gz diff --git a/python-pycoingecko.spec b/python-pycoingecko.spec new file mode 100644 index 0000000..1e4b661 --- /dev/null +++ b/python-pycoingecko.spec @@ -0,0 +1,1300 @@ +%global _empty_manifest_terminate_build 0 +Name: python-pycoingecko +Version: 3.1.0 +Release: 1 +Summary: Python wrapper around the CoinGecko API +License: MIT +URL: https://github.com/man-c/pycoingecko +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/23/03/ed739d694bd1e0681f2e61cb7ff8a9949dc5dd62d8525e911511260b0efe/pycoingecko-3.1.0.tar.gz +BuildArch: noarch + +Requires: python3-requests + +%description +# CoinGecko API wrapper +[![PyPi Version](https://img.shields.io/pypi/v/pycoingecko.svg)](https://pypi.python.org/pypi/pycoingecko/) +![GitHub](https://img.shields.io/github/license/man-c/pycoingecko) + +Python3 wrapper around the [CoinGecko](https://www.coingecko.com/) API (V3) + +### Installation +PyPI +```bash +pip install -U pycoingecko +``` +or from source +```bash +git clone https://github.com/man-c/pycoingecko.git +cd pycoingecko +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/en/api/documentation). + +For any parameter: +- ***Lists** are supported as input for multiple-valued comma-separated parameters\ + (e.g. see /simple/price usage examples).* +- ***Booleans** are supported as input for boolean type parameters; they can be `str` ('true', 'false'') or `bool` (`True`, `False`)\ + (e.g. see /simple/price usage examples).* + +Usage examples: +```python +# /simple/price endpoint with the required parameters +>>> cg.get_price(ids='bitcoin', vs_currencies='usd') +{'bitcoin': {'usd': 3462.04}} + +>>> cg.get_price(ids='bitcoin,litecoin,ethereum', vs_currencies='usd') +# OR (lists can be used for multiple-valued arguments) +>>> cg.get_price(ids=['bitcoin', 'litecoin', 'ethereum'], vs_currencies='usd') +{'bitcoin': {'usd': 3461.27}, 'ethereum': {'usd': 106.92}, 'litecoin': {'usd': 32.72}} + +>>> cg.get_price(ids='bitcoin,litecoin,ethereum', vs_currencies='usd,eur') +# OR (lists can be used for multiple-valued arguments) +>>> cg.get_price(ids=['bitcoin', 'litecoin', 'ethereum'], vs_currencies=['usd', 'eur']) +{'bitcoin': {'usd': 3459.39, 'eur': 3019.33}, 'ethereum': {'usd': 106.91, 'eur': 93.31}, 'litecoin': {'usd': 32.72, 'eur': 28.56}} + +# optional parameters can be passed as defined in the API doc (https://www.coingecko.com/api/docs/v3) +>>> cg.get_price(ids='bitcoin', vs_currencies='usd', include_market_cap='true', include_24hr_vol='true', include_24hr_change='true', include_last_updated_at='true') +{'bitcoin': {'usd': 3458.74, 'usd_market_cap': 60574330199.29028, 'usd_24h_vol': 4182664683.6247883, 'usd_24h_change': 1.2295378479069035, 'last_updated_at': 1549071865}} +# OR (also booleans can be used for boolean type arguments) +>>> cg.get_price(ids='bitcoin', vs_currencies='usd', include_market_cap=True, include_24hr_vol=True, include_24hr_change=True, include_last_updated_at=True) +{'bitcoin': {'usd': 3458.74, 'usd_market_cap': 60574330199.29028, 'usd_24h_vol': 4182664683.6247883, 'usd_24h_change': 1.2295378479069035, 'last_updated_at': 1549071865}} +``` + +### API documentation +https://www.coingecko.com/en/api/documentation + +### Endpoints included +> :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.
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 + cg.ping() + ``` +

+ +
simple +

+ +* **/simple/price** (Get the current price of any cryptocurrencies in any other supported currencies that you need) + ```python + cg.get_price() + ``` +* **/simple/token_price/{id}** (Get current price of tokens (using contract addresses) for a given platform in any other currency that you need) + ```python + cg.get_token_price() + ``` +* **/simple/supported_vs_currencies** (Get list of supported_vs_currencies) + ```python + cg.get_supported_vs_currencies() + ``` +

+ +
coins +

+ +* **/coins/list** (List all supported coins id, name and symbol (no pagination required)) + ```python + cg.get_coins_list() + ``` + +* **/coins/markets** (List all supported coins price, market cap, volume, and market related data) + ```python + cg.get_coins_markets() + ``` +* **/coins/{id}** (Get current data (name, price, market, ... including exchange tickers) for a coin) + ```python + cg.get_coin_by_id() + ``` +* **/coins/{id}/tickers** (Get coin tickers (paginated to 100 items)) + ```python + cg.get_coin_ticker_by_id() + ``` +* **/coins/{id}/history** (Get historical data (name, price, market, stats) at a given date for a coin) + ```python + cg.get_coin_history_by_id() + ``` +* **/coins/{id}/market_chart** (Get historical market data include price, market cap, and 24h volume (granularity auto)) + ```python + cg.get_coin_market_chart_by_id() + ``` +* **/coins/{id}/market_chart/range** (Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto)) + ```python + cg.get_coin_market_chart_range_by_id() + ``` + +[//]: # (* **/coins/{id}/status_updates** (Get status updates for a given coin (beta))) + +[//]: # ( ```python) + +[//]: # ( cg.get_coin_status_updates_by_id()) + +[//]: # ( ```) +* **/coins/{id}/ohlc** (Get coin's OHLC (beta)) + ```python + cg.get_coin_ohlc_by_id() + ``` +

+ +
contract +

+ +* **/coins/{id}/contract/{contract_address}** (Get coin info from contract address) + ```python + cg.get_coin_info_from_contract_address_by_id() + ``` +* **/coins/{id}/contract/{contract_address}/market_chart/** (Get historical market data include price, market cap, and 24h volume (granularity auto) from a contract address) + ```python + cg.get_coin_market_chart_from_contract_address_by_id() + ``` +* **/coins/{id}/contract/{contract_address}/market_chart/range** (Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto) from a contract address) + ```python + cg.get_coin_market_chart_range_from_contract_address_by_id() + ``` +

+ +
asset_platforms +

+ +* **/asset_platforms** (List all asset platforms (Blockchain networks)) + ```python + cg.get_asset_platforms() + ``` +

+ +
categories +

+ +* **/coins/categories/list** (List all categories) + ```python + cg.get_coins_categories_list() + ``` +* **coins/categories** (List all categories with market data) + ```python + cg.get_coins_categories() + ``` +

+ +
exchanges +

+ +* **/exchanges** (List all exchanges) + ```python + cg.get_exchanges_list() + ``` +* **/exchanges/list** (List all supported markets id and name (no pagination required)) + ```python + cg.get_exchanges_id_name_list() + ``` +* **/exchanges/{id}** (Get exchange volume in BTC and top 100 tickers only) + ```python + cg.get_exchanges_by_id() + ``` +* **/exchanges/{id}/tickers** (Get exchange tickers (paginated, 100 tickers per page)) + ```python + cg.get_exchanges_tickers_by_id() + ``` + +[//]: # (* **/exchanges/{id}/status_updates** (Get status updates for a given exchange (beta))) + +[//]: # ( ```python) + +[//]: # ( cg.get_exchanges_status_updates_by_id()) + +[//]: # ( ```) +* **/exchanges/{id}/volume_chart** (Get volume_chart data for a given exchange) + ```python + cg.get_exchanges_volume_chart_by_id() + ``` +

+ +[//]: # (
finance) + +[//]: # (

) + +[//]: # () +[//]: # (* **/finance_platforms** (List all finance platforms)) + +[//]: # ( ```python) + +[//]: # ( cg.get_finance_platforms()) + +[//]: # ( ```) + +[//]: # (* **/finance_products** (List all finance products)) + +[//]: # ( ```python) + +[//]: # ( cg.get_finance_products()) + +[//]: # ( ```) + +[//]: # (

) + +
indexes +

+ +* **/indexes** (List all market indexes) +```python +cg.get_indexes() +``` +* **/indexes/{market_id}/{id}** (Get market index by market id and index id) +```python +cg.get_indexes_by_market_id_and_index_id() +``` +* **/indexes/list** (List market indexes id and name) +```python +cg.get_indexes_list() +``` +

+ +
derivatives +

+ +* **/derivatives** (List all derivative tickers) + ```python + cg.get_derivatives() + ``` +* **/derivatives/exchanges** (List all derivative exchanges) + ```python + cg.get_derivatives_exchanges() + ``` +* **/derivatives/exchanges/{id}** (Show derivative exchange data) + ```python + cg.get_derivatives_exchanges_by_id() + ``` +* **/derivatives/exchanges/list** (List all derivative exchanges name and identifier) + ```python + cg.get_derivatives_exchanges_list() + ``` +

+ +
nfts (beta) +

+ +* **/nfts/list** (List all supported NFT ids, paginated by 100 items per page, paginated to 100 items) + ```python + cg.get_nfts_list() + ``` +* **/nfts/{id}** (Get current data (name, price_floor, volume_24h ...) for an NFT collection. native_currency (string) is only a representative of the currency.) + ```python + cg.get_nfts_by_id() + ``` +* **/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) + ```python + cg.get_nfts_collection_by_asset_platform_id_and_contract_address() + ``` +

+ +[//]: # (
status_updates) + +[//]: # (

) + +[//]: # () +[//]: # (* **/status_updates** (List all status_updates with data (description, category, created_at, user, user_title and pin))) + +[//]: # ( ```python) + +[//]: # ( cg.get_status_updates()) + +[//]: # ( ```) + +[//]: # (

) + +[//]: # (
events) + +[//]: # (

) + +[//]: # () +[//]: # (* **/events** (Get events, paginated by 100)) + +[//]: # ( ```python) + +[//]: # ( cg.get_events()) + +[//]: # ( ```) + +[//]: # (* **/events/countries** (Get list of event countries)) + +[//]: # ( ```python) + +[//]: # ( cg.get_events_countries()) + +[//]: # ( ```) + +[//]: # (* **/events/types** (Get list of events types)) + +[//]: # ( ```python) + +[//]: # ( cg.get_events_types()) + +[//]: # ( ```) + +[//]: # (

) + +
exchange_rates +

+ +* **/exchange_rates** (Get BTC-to-Currency exchange rates) + ```python + cg.get_exchange_rates() + ``` +

+ +
search +

+ +* **/search** (Search for coins, categories and markets on CoinGecko) + ```python + cg.search() + ``` +

+ +
trending +

+ +* **/search/trending** (Get trending search coins (Top-7) on CoinGecko in the last 24 hours) + ```python + cg.get_search_trending() + ``` +

+ +
global +

+ + - **/global** (Get cryptocurrency global data) + ```python + cg.get_global() + ``` + - **/global/decentralized_finance_defi** (Get cryptocurrency global decentralized finance(defi) data) + ```python + cg.get_global_decentralized_finance_defi() + ``` +

+ +
companies (beta) +

+ + - **/companies/public_treasury/{coin_id}** (Get public companies data) + ```python + cg.get_companies_public_treasury_by_coin_id() + ``` +

+ +### Test + +#### Installation +Install required packages for testing using: +```bash +pip install pytest responses +``` + +#### Usage + +Run unit tests with: + +``` +# after installing pytest and responses using pip3 +pytest tests +``` + +## License +[MIT](https://choosealicense.com/licenses/mit/) + + + + +%package -n python3-pycoingecko +Summary: Python wrapper around the CoinGecko API +Provides: python-pycoingecko +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-pycoingecko +# CoinGecko API wrapper +[![PyPi Version](https://img.shields.io/pypi/v/pycoingecko.svg)](https://pypi.python.org/pypi/pycoingecko/) +![GitHub](https://img.shields.io/github/license/man-c/pycoingecko) + +Python3 wrapper around the [CoinGecko](https://www.coingecko.com/) API (V3) + +### Installation +PyPI +```bash +pip install -U pycoingecko +``` +or from source +```bash +git clone https://github.com/man-c/pycoingecko.git +cd pycoingecko +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/en/api/documentation). + +For any parameter: +- ***Lists** are supported as input for multiple-valued comma-separated parameters\ + (e.g. see /simple/price usage examples).* +- ***Booleans** are supported as input for boolean type parameters; they can be `str` ('true', 'false'') or `bool` (`True`, `False`)\ + (e.g. see /simple/price usage examples).* + +Usage examples: +```python +# /simple/price endpoint with the required parameters +>>> cg.get_price(ids='bitcoin', vs_currencies='usd') +{'bitcoin': {'usd': 3462.04}} + +>>> cg.get_price(ids='bitcoin,litecoin,ethereum', vs_currencies='usd') +# OR (lists can be used for multiple-valued arguments) +>>> cg.get_price(ids=['bitcoin', 'litecoin', 'ethereum'], vs_currencies='usd') +{'bitcoin': {'usd': 3461.27}, 'ethereum': {'usd': 106.92}, 'litecoin': {'usd': 32.72}} + +>>> cg.get_price(ids='bitcoin,litecoin,ethereum', vs_currencies='usd,eur') +# OR (lists can be used for multiple-valued arguments) +>>> cg.get_price(ids=['bitcoin', 'litecoin', 'ethereum'], vs_currencies=['usd', 'eur']) +{'bitcoin': {'usd': 3459.39, 'eur': 3019.33}, 'ethereum': {'usd': 106.91, 'eur': 93.31}, 'litecoin': {'usd': 32.72, 'eur': 28.56}} + +# optional parameters can be passed as defined in the API doc (https://www.coingecko.com/api/docs/v3) +>>> cg.get_price(ids='bitcoin', vs_currencies='usd', include_market_cap='true', include_24hr_vol='true', include_24hr_change='true', include_last_updated_at='true') +{'bitcoin': {'usd': 3458.74, 'usd_market_cap': 60574330199.29028, 'usd_24h_vol': 4182664683.6247883, 'usd_24h_change': 1.2295378479069035, 'last_updated_at': 1549071865}} +# OR (also booleans can be used for boolean type arguments) +>>> cg.get_price(ids='bitcoin', vs_currencies='usd', include_market_cap=True, include_24hr_vol=True, include_24hr_change=True, include_last_updated_at=True) +{'bitcoin': {'usd': 3458.74, 'usd_market_cap': 60574330199.29028, 'usd_24h_vol': 4182664683.6247883, 'usd_24h_change': 1.2295378479069035, 'last_updated_at': 1549071865}} +``` + +### API documentation +https://www.coingecko.com/en/api/documentation + +### Endpoints included +> :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.
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 + cg.ping() + ``` +

+ +
simple +

+ +* **/simple/price** (Get the current price of any cryptocurrencies in any other supported currencies that you need) + ```python + cg.get_price() + ``` +* **/simple/token_price/{id}** (Get current price of tokens (using contract addresses) for a given platform in any other currency that you need) + ```python + cg.get_token_price() + ``` +* **/simple/supported_vs_currencies** (Get list of supported_vs_currencies) + ```python + cg.get_supported_vs_currencies() + ``` +

+ +
coins +

+ +* **/coins/list** (List all supported coins id, name and symbol (no pagination required)) + ```python + cg.get_coins_list() + ``` + +* **/coins/markets** (List all supported coins price, market cap, volume, and market related data) + ```python + cg.get_coins_markets() + ``` +* **/coins/{id}** (Get current data (name, price, market, ... including exchange tickers) for a coin) + ```python + cg.get_coin_by_id() + ``` +* **/coins/{id}/tickers** (Get coin tickers (paginated to 100 items)) + ```python + cg.get_coin_ticker_by_id() + ``` +* **/coins/{id}/history** (Get historical data (name, price, market, stats) at a given date for a coin) + ```python + cg.get_coin_history_by_id() + ``` +* **/coins/{id}/market_chart** (Get historical market data include price, market cap, and 24h volume (granularity auto)) + ```python + cg.get_coin_market_chart_by_id() + ``` +* **/coins/{id}/market_chart/range** (Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto)) + ```python + cg.get_coin_market_chart_range_by_id() + ``` + +[//]: # (* **/coins/{id}/status_updates** (Get status updates for a given coin (beta))) + +[//]: # ( ```python) + +[//]: # ( cg.get_coin_status_updates_by_id()) + +[//]: # ( ```) +* **/coins/{id}/ohlc** (Get coin's OHLC (beta)) + ```python + cg.get_coin_ohlc_by_id() + ``` +

+ +
contract +

+ +* **/coins/{id}/contract/{contract_address}** (Get coin info from contract address) + ```python + cg.get_coin_info_from_contract_address_by_id() + ``` +* **/coins/{id}/contract/{contract_address}/market_chart/** (Get historical market data include price, market cap, and 24h volume (granularity auto) from a contract address) + ```python + cg.get_coin_market_chart_from_contract_address_by_id() + ``` +* **/coins/{id}/contract/{contract_address}/market_chart/range** (Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto) from a contract address) + ```python + cg.get_coin_market_chart_range_from_contract_address_by_id() + ``` +

+ +
asset_platforms +

+ +* **/asset_platforms** (List all asset platforms (Blockchain networks)) + ```python + cg.get_asset_platforms() + ``` +

+ +
categories +

+ +* **/coins/categories/list** (List all categories) + ```python + cg.get_coins_categories_list() + ``` +* **coins/categories** (List all categories with market data) + ```python + cg.get_coins_categories() + ``` +

+ +
exchanges +

+ +* **/exchanges** (List all exchanges) + ```python + cg.get_exchanges_list() + ``` +* **/exchanges/list** (List all supported markets id and name (no pagination required)) + ```python + cg.get_exchanges_id_name_list() + ``` +* **/exchanges/{id}** (Get exchange volume in BTC and top 100 tickers only) + ```python + cg.get_exchanges_by_id() + ``` +* **/exchanges/{id}/tickers** (Get exchange tickers (paginated, 100 tickers per page)) + ```python + cg.get_exchanges_tickers_by_id() + ``` + +[//]: # (* **/exchanges/{id}/status_updates** (Get status updates for a given exchange (beta))) + +[//]: # ( ```python) + +[//]: # ( cg.get_exchanges_status_updates_by_id()) + +[//]: # ( ```) +* **/exchanges/{id}/volume_chart** (Get volume_chart data for a given exchange) + ```python + cg.get_exchanges_volume_chart_by_id() + ``` +

+ +[//]: # (
finance) + +[//]: # (

) + +[//]: # () +[//]: # (* **/finance_platforms** (List all finance platforms)) + +[//]: # ( ```python) + +[//]: # ( cg.get_finance_platforms()) + +[//]: # ( ```) + +[//]: # (* **/finance_products** (List all finance products)) + +[//]: # ( ```python) + +[//]: # ( cg.get_finance_products()) + +[//]: # ( ```) + +[//]: # (

) + +
indexes +

+ +* **/indexes** (List all market indexes) +```python +cg.get_indexes() +``` +* **/indexes/{market_id}/{id}** (Get market index by market id and index id) +```python +cg.get_indexes_by_market_id_and_index_id() +``` +* **/indexes/list** (List market indexes id and name) +```python +cg.get_indexes_list() +``` +

+ +
derivatives +

+ +* **/derivatives** (List all derivative tickers) + ```python + cg.get_derivatives() + ``` +* **/derivatives/exchanges** (List all derivative exchanges) + ```python + cg.get_derivatives_exchanges() + ``` +* **/derivatives/exchanges/{id}** (Show derivative exchange data) + ```python + cg.get_derivatives_exchanges_by_id() + ``` +* **/derivatives/exchanges/list** (List all derivative exchanges name and identifier) + ```python + cg.get_derivatives_exchanges_list() + ``` +

+ +
nfts (beta) +

+ +* **/nfts/list** (List all supported NFT ids, paginated by 100 items per page, paginated to 100 items) + ```python + cg.get_nfts_list() + ``` +* **/nfts/{id}** (Get current data (name, price_floor, volume_24h ...) for an NFT collection. native_currency (string) is only a representative of the currency.) + ```python + cg.get_nfts_by_id() + ``` +* **/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) + ```python + cg.get_nfts_collection_by_asset_platform_id_and_contract_address() + ``` +

+ +[//]: # (
status_updates) + +[//]: # (

) + +[//]: # () +[//]: # (* **/status_updates** (List all status_updates with data (description, category, created_at, user, user_title and pin))) + +[//]: # ( ```python) + +[//]: # ( cg.get_status_updates()) + +[//]: # ( ```) + +[//]: # (

) + +[//]: # (
events) + +[//]: # (

) + +[//]: # () +[//]: # (* **/events** (Get events, paginated by 100)) + +[//]: # ( ```python) + +[//]: # ( cg.get_events()) + +[//]: # ( ```) + +[//]: # (* **/events/countries** (Get list of event countries)) + +[//]: # ( ```python) + +[//]: # ( cg.get_events_countries()) + +[//]: # ( ```) + +[//]: # (* **/events/types** (Get list of events types)) + +[//]: # ( ```python) + +[//]: # ( cg.get_events_types()) + +[//]: # ( ```) + +[//]: # (

) + +
exchange_rates +

+ +* **/exchange_rates** (Get BTC-to-Currency exchange rates) + ```python + cg.get_exchange_rates() + ``` +

+ +
search +

+ +* **/search** (Search for coins, categories and markets on CoinGecko) + ```python + cg.search() + ``` +

+ +
trending +

+ +* **/search/trending** (Get trending search coins (Top-7) on CoinGecko in the last 24 hours) + ```python + cg.get_search_trending() + ``` +

+ +
global +

+ + - **/global** (Get cryptocurrency global data) + ```python + cg.get_global() + ``` + - **/global/decentralized_finance_defi** (Get cryptocurrency global decentralized finance(defi) data) + ```python + cg.get_global_decentralized_finance_defi() + ``` +

+ +
companies (beta) +

+ + - **/companies/public_treasury/{coin_id}** (Get public companies data) + ```python + cg.get_companies_public_treasury_by_coin_id() + ``` +

+ +### Test + +#### Installation +Install required packages for testing using: +```bash +pip install pytest responses +``` + +#### Usage + +Run unit tests with: + +``` +# after installing pytest and responses using pip3 +pytest tests +``` + +## License +[MIT](https://choosealicense.com/licenses/mit/) + + + + +%package help +Summary: Development documents and examples for pycoingecko +Provides: python3-pycoingecko-doc +%description help +# CoinGecko API wrapper +[![PyPi Version](https://img.shields.io/pypi/v/pycoingecko.svg)](https://pypi.python.org/pypi/pycoingecko/) +![GitHub](https://img.shields.io/github/license/man-c/pycoingecko) + +Python3 wrapper around the [CoinGecko](https://www.coingecko.com/) API (V3) + +### Installation +PyPI +```bash +pip install -U pycoingecko +``` +or from source +```bash +git clone https://github.com/man-c/pycoingecko.git +cd pycoingecko +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/en/api/documentation). + +For any parameter: +- ***Lists** are supported as input for multiple-valued comma-separated parameters\ + (e.g. see /simple/price usage examples).* +- ***Booleans** are supported as input for boolean type parameters; they can be `str` ('true', 'false'') or `bool` (`True`, `False`)\ + (e.g. see /simple/price usage examples).* + +Usage examples: +```python +# /simple/price endpoint with the required parameters +>>> cg.get_price(ids='bitcoin', vs_currencies='usd') +{'bitcoin': {'usd': 3462.04}} + +>>> cg.get_price(ids='bitcoin,litecoin,ethereum', vs_currencies='usd') +# OR (lists can be used for multiple-valued arguments) +>>> cg.get_price(ids=['bitcoin', 'litecoin', 'ethereum'], vs_currencies='usd') +{'bitcoin': {'usd': 3461.27}, 'ethereum': {'usd': 106.92}, 'litecoin': {'usd': 32.72}} + +>>> cg.get_price(ids='bitcoin,litecoin,ethereum', vs_currencies='usd,eur') +# OR (lists can be used for multiple-valued arguments) +>>> cg.get_price(ids=['bitcoin', 'litecoin', 'ethereum'], vs_currencies=['usd', 'eur']) +{'bitcoin': {'usd': 3459.39, 'eur': 3019.33}, 'ethereum': {'usd': 106.91, 'eur': 93.31}, 'litecoin': {'usd': 32.72, 'eur': 28.56}} + +# optional parameters can be passed as defined in the API doc (https://www.coingecko.com/api/docs/v3) +>>> cg.get_price(ids='bitcoin', vs_currencies='usd', include_market_cap='true', include_24hr_vol='true', include_24hr_change='true', include_last_updated_at='true') +{'bitcoin': {'usd': 3458.74, 'usd_market_cap': 60574330199.29028, 'usd_24h_vol': 4182664683.6247883, 'usd_24h_change': 1.2295378479069035, 'last_updated_at': 1549071865}} +# OR (also booleans can be used for boolean type arguments) +>>> cg.get_price(ids='bitcoin', vs_currencies='usd', include_market_cap=True, include_24hr_vol=True, include_24hr_change=True, include_last_updated_at=True) +{'bitcoin': {'usd': 3458.74, 'usd_market_cap': 60574330199.29028, 'usd_24h_vol': 4182664683.6247883, 'usd_24h_change': 1.2295378479069035, 'last_updated_at': 1549071865}} +``` + +### API documentation +https://www.coingecko.com/en/api/documentation + +### Endpoints included +> :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.
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 + cg.ping() + ``` +

+ +
simple +

+ +* **/simple/price** (Get the current price of any cryptocurrencies in any other supported currencies that you need) + ```python + cg.get_price() + ``` +* **/simple/token_price/{id}** (Get current price of tokens (using contract addresses) for a given platform in any other currency that you need) + ```python + cg.get_token_price() + ``` +* **/simple/supported_vs_currencies** (Get list of supported_vs_currencies) + ```python + cg.get_supported_vs_currencies() + ``` +

+ +
coins +

+ +* **/coins/list** (List all supported coins id, name and symbol (no pagination required)) + ```python + cg.get_coins_list() + ``` + +* **/coins/markets** (List all supported coins price, market cap, volume, and market related data) + ```python + cg.get_coins_markets() + ``` +* **/coins/{id}** (Get current data (name, price, market, ... including exchange tickers) for a coin) + ```python + cg.get_coin_by_id() + ``` +* **/coins/{id}/tickers** (Get coin tickers (paginated to 100 items)) + ```python + cg.get_coin_ticker_by_id() + ``` +* **/coins/{id}/history** (Get historical data (name, price, market, stats) at a given date for a coin) + ```python + cg.get_coin_history_by_id() + ``` +* **/coins/{id}/market_chart** (Get historical market data include price, market cap, and 24h volume (granularity auto)) + ```python + cg.get_coin_market_chart_by_id() + ``` +* **/coins/{id}/market_chart/range** (Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto)) + ```python + cg.get_coin_market_chart_range_by_id() + ``` + +[//]: # (* **/coins/{id}/status_updates** (Get status updates for a given coin (beta))) + +[//]: # ( ```python) + +[//]: # ( cg.get_coin_status_updates_by_id()) + +[//]: # ( ```) +* **/coins/{id}/ohlc** (Get coin's OHLC (beta)) + ```python + cg.get_coin_ohlc_by_id() + ``` +

+ +
contract +

+ +* **/coins/{id}/contract/{contract_address}** (Get coin info from contract address) + ```python + cg.get_coin_info_from_contract_address_by_id() + ``` +* **/coins/{id}/contract/{contract_address}/market_chart/** (Get historical market data include price, market cap, and 24h volume (granularity auto) from a contract address) + ```python + cg.get_coin_market_chart_from_contract_address_by_id() + ``` +* **/coins/{id}/contract/{contract_address}/market_chart/range** (Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto) from a contract address) + ```python + cg.get_coin_market_chart_range_from_contract_address_by_id() + ``` +

+ +
asset_platforms +

+ +* **/asset_platforms** (List all asset platforms (Blockchain networks)) + ```python + cg.get_asset_platforms() + ``` +

+ +
categories +

+ +* **/coins/categories/list** (List all categories) + ```python + cg.get_coins_categories_list() + ``` +* **coins/categories** (List all categories with market data) + ```python + cg.get_coins_categories() + ``` +

+ +
exchanges +

+ +* **/exchanges** (List all exchanges) + ```python + cg.get_exchanges_list() + ``` +* **/exchanges/list** (List all supported markets id and name (no pagination required)) + ```python + cg.get_exchanges_id_name_list() + ``` +* **/exchanges/{id}** (Get exchange volume in BTC and top 100 tickers only) + ```python + cg.get_exchanges_by_id() + ``` +* **/exchanges/{id}/tickers** (Get exchange tickers (paginated, 100 tickers per page)) + ```python + cg.get_exchanges_tickers_by_id() + ``` + +[//]: # (* **/exchanges/{id}/status_updates** (Get status updates for a given exchange (beta))) + +[//]: # ( ```python) + +[//]: # ( cg.get_exchanges_status_updates_by_id()) + +[//]: # ( ```) +* **/exchanges/{id}/volume_chart** (Get volume_chart data for a given exchange) + ```python + cg.get_exchanges_volume_chart_by_id() + ``` +

+ +[//]: # (
finance) + +[//]: # (

) + +[//]: # () +[//]: # (* **/finance_platforms** (List all finance platforms)) + +[//]: # ( ```python) + +[//]: # ( cg.get_finance_platforms()) + +[//]: # ( ```) + +[//]: # (* **/finance_products** (List all finance products)) + +[//]: # ( ```python) + +[//]: # ( cg.get_finance_products()) + +[//]: # ( ```) + +[//]: # (

) + +
indexes +

+ +* **/indexes** (List all market indexes) +```python +cg.get_indexes() +``` +* **/indexes/{market_id}/{id}** (Get market index by market id and index id) +```python +cg.get_indexes_by_market_id_and_index_id() +``` +* **/indexes/list** (List market indexes id and name) +```python +cg.get_indexes_list() +``` +

+ +
derivatives +

+ +* **/derivatives** (List all derivative tickers) + ```python + cg.get_derivatives() + ``` +* **/derivatives/exchanges** (List all derivative exchanges) + ```python + cg.get_derivatives_exchanges() + ``` +* **/derivatives/exchanges/{id}** (Show derivative exchange data) + ```python + cg.get_derivatives_exchanges_by_id() + ``` +* **/derivatives/exchanges/list** (List all derivative exchanges name and identifier) + ```python + cg.get_derivatives_exchanges_list() + ``` +

+ +
nfts (beta) +

+ +* **/nfts/list** (List all supported NFT ids, paginated by 100 items per page, paginated to 100 items) + ```python + cg.get_nfts_list() + ``` +* **/nfts/{id}** (Get current data (name, price_floor, volume_24h ...) for an NFT collection. native_currency (string) is only a representative of the currency.) + ```python + cg.get_nfts_by_id() + ``` +* **/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) + ```python + cg.get_nfts_collection_by_asset_platform_id_and_contract_address() + ``` +

+ +[//]: # (
status_updates) + +[//]: # (

) + +[//]: # () +[//]: # (* **/status_updates** (List all status_updates with data (description, category, created_at, user, user_title and pin))) + +[//]: # ( ```python) + +[//]: # ( cg.get_status_updates()) + +[//]: # ( ```) + +[//]: # (

) + +[//]: # (
events) + +[//]: # (

) + +[//]: # () +[//]: # (* **/events** (Get events, paginated by 100)) + +[//]: # ( ```python) + +[//]: # ( cg.get_events()) + +[//]: # ( ```) + +[//]: # (* **/events/countries** (Get list of event countries)) + +[//]: # ( ```python) + +[//]: # ( cg.get_events_countries()) + +[//]: # ( ```) + +[//]: # (* **/events/types** (Get list of events types)) + +[//]: # ( ```python) + +[//]: # ( cg.get_events_types()) + +[//]: # ( ```) + +[//]: # (

) + +
exchange_rates +

+ +* **/exchange_rates** (Get BTC-to-Currency exchange rates) + ```python + cg.get_exchange_rates() + ``` +

+ +
search +

+ +* **/search** (Search for coins, categories and markets on CoinGecko) + ```python + cg.search() + ``` +

+ +
trending +

+ +* **/search/trending** (Get trending search coins (Top-7) on CoinGecko in the last 24 hours) + ```python + cg.get_search_trending() + ``` +

+ +
global +

+ + - **/global** (Get cryptocurrency global data) + ```python + cg.get_global() + ``` + - **/global/decentralized_finance_defi** (Get cryptocurrency global decentralized finance(defi) data) + ```python + cg.get_global_decentralized_finance_defi() + ``` +

+ +
companies (beta) +

+ + - **/companies/public_treasury/{coin_id}** (Get public companies data) + ```python + cg.get_companies_public_treasury_by_coin_id() + ``` +

+ +### Test + +#### Installation +Install required packages for testing using: +```bash +pip install pytest responses +``` + +#### Usage + +Run unit tests with: + +``` +# after installing pytest and responses using pip3 +pytest tests +``` + +## License +[MIT](https://choosealicense.com/licenses/mit/) + + + + +%prep +%autosetup -n pycoingecko-3.1.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-pycoingecko -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu Mar 09 2023 Python_Bot - 3.1.0-1 +- Package Spec generated diff --git a/sources b/sources new file mode 100644 index 0000000..f5574e6 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +0f9f3b5cf1767fd2b261f7151c774ad7 pycoingecko-3.1.0.tar.gz -- cgit v1.2.3