Python wrapper around the Pesto API
Project description
Pesto API wrapper
Python3 wrapper around the Pesto API (v2)
Supports both Public and Pro API:
Installation
PyPI
pip install -U pypestoai
or from source
git clone https://github.com/elitezchen/pestoai_sdk.git pypestoai
cd pypestoai
python3 setup.py install
Usage
For Demo API:
- 🔑 with a demo api key:
from pypestoai import PestoAPI pto = PestoAPI(demo_api_key='YOUR_DEMO_API_KEY')
For Production API:
- 🔑 with a pro api key:
from pypestoai import PestoAPI pto = PestoAPI(api_key='YOUR_PRODUCTION_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 Pesto API doc (https://docs.pestoai.fun/docs/pesto/get-list-coins-categories-with-market-data-v-2-coins-categories-get)
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'') orbool(True,False)
(e.g. see /simple/price usage examples).*
Usage examples:
# /simple/price endpoint with the required parameters
>>> pto.get_price(ids='bitcoin', vs_currencies='usd')
{'bitcoin': {'usd': 3462.04}}
>>> pto.get_price(ids='bitcoin,litecoin,ethereum', vs_currencies='usd')
# OR (lists can be used for multiple-valued arguments)
>>> pto.get_price(ids=['bitcoin', 'litecoin', 'ethereum'], vs_currencies='usd')
{'bitcoin': {'usd': 3461.27}, 'ethereum': {'usd': 106.92}, 'litecoin': {'usd': 32.72}}
>>> pto.get_price(ids='bitcoin,litecoin,ethereum', vs_currencies='usd,eur')
# OR (lists can be used for multiple-valued arguments)
>>> pto.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.pestoai.fun/api/docs/v2)
>>> pto.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)
>>> pto.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://docs.pestoai.fun/docs/category/pesto-api
📡 Endpoints included
:warning: Endpoints documentation: To make sure that you are using properly each endpoint you should check the API documentation. Return behaviour and parameters of the endpoints, such as pagination, might have changed.
Any optional parameters defined in Pesto API doc can be passed as function parameters using same parameters names with the API (see Examples above).
ping
- /ping
Check API server status
pto.ping()
key
- [Pro API] 💼 /key
Monitor your account's API usage, including rate limits, monthly total credits, remaining credits, and more
pto.key()
simple
-
/simple/price
Get the current price of any cryptocurrencies in any other supported currencies that you need
pto.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
pto.get_token_price()
-
/simple/supported_vs_currencies Get list of supported_vs_currencies
pto.get_supported_vs_currencies()
coins
-
/coins/list
List all supported coins id, name and symbol (no pagination required)
pto.get_coins_list()
-
[Pro API] 💼 /coins/top_gainers_losers
Query the top 30 coins with largest price gain and loss by a specific time duration
pto.get_coin_top_gainers_losers()
-
[Pro API] 💼 /coins/list/new
Query the latest 200 coins that recently listed on Pesto
pto.get_coins_list_new()
-
/coins/markets
List all supported coins price, market cap, volume, and market related data
pto.get_coins_markets()
-
/coins/{id}
Get current data (name, price, market, ... including exchange tickers) for a coin
pto.get_coin_by_id()
-
/coins/{id}/tickers
Get coin tickers (paginated to 100 items)
pto.get_coin_ticker_by_id()
-
/coins/{id}/history
Get historical data (name, price, market, stats) at a given date for a coin
pto.get_coin_history_by_id()
-
/coins/{id}/market_chart
Get historical market data include price, market cap, and 24h volume (granularity auto)
pto.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)
pto.get_coin_market_chart_range_by_id()
-
/coins/{id}/ohlc
Get the OHLC chart (Open, High, Low, Close) of a coin based on particular coin id
pto.get_coin_ohlc_by_id()
-
[Pro API] 💼 /coins/{id}/ohlc/range
Get the OHLC chart (Open, High, Low, Close) of a coin within a range of timestamp based on particular coin id
pto.get_coin_ohlc_by_id_range()
-
[Pro API] 👑 /coins/{id}/circulating_supply_chart
Query historical circulating supply of a coin by number of days away from now based on provided coin id
pto.get_coin_circulating_supply_chart()
-
[Pro API] 👑 /coins/{id}/circulating_supply_chart/range
Query historical circulating supply of a coin, within a range of timestamp based on the provided coin id
pto.get_coin_circulating_supply_chart_range()
-
[Pro API] 👑 /coins/{id}/total_supply_chart
Query historical total supply of a coin by number of days away from now based on provided coin id
pto.get_coin_total_supply_chart()
-
[Pro API] 👑 /coins/{id}/total_supply_chart/range
Query historical total supply of a coin, within a range of timestamp based on the provided coin id
pto.get_coin_total_supply_chart_range()
contract
-
/coins/{id}/contract/{contract_address}
Get coin info from contract address
pto.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
pto.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
pto.get_coin_market_chart_range_from_contract_address_by_id()
asset_platforms
-
/asset_platforms
List all asset platforms (Blockchain networks)
pto.get_asset_platforms()
-
[Pro API] 👑 /token_lists/{asset_platform_id}/all.json
Get full list of tokens of a blockchain network (asset platform) that is supported by Ethereum token list standard
pto.get_asset_platform_by_id()
categories
-
/coins/categories/list
List all categories
pto.get_coins_categories_list()
-
coins/categories List all categories with market data
pto.get_coins_categories()
exchanges
-
/exchanges
List all exchanges
pto.get_exchanges_list()
-
/exchanges/list
List all supported markets id and name (no pagination required)
pto.get_exchanges_id_name_list()
-
/exchanges/{id}
Get exchange volume in BTC and top 100 tickers only
pto.get_exchanges_by_id()
-
/exchanges/{id}/tickers
Get exchange tickers (paginated, 100 tickers per page)
pto.get_exchanges_tickers_by_id()
-
/exchanges/{id}/volume_chart
Get volume_chart data for a given exchange
pto.get_exchanges_volume_chart_by_id()
-
[Pro API] 💼 /exchanges/{id}/volume_chart/range
Query the historical volume chart data in BTC by specifying date range in UNIX based on exchange’s id
pto.get_exchanges_volume_chart_by_id_within_time_range()
indexes
-
/indexes
List all market indexes
pto.get_indexes()
-
/indexes/{market_id}/{id}
Get market index by market id and index id
pto.get_indexes_by_market_id_and_index_id()
-
/indexes/list
List market indexes id and name
pto.get_indexes_list()
derivatives
-
/derivatives
List all derivative tickers
pto.get_derivatives()
-
/derivatives/exchanges
List all derivative exchanges
pto.get_derivatives_exchanges()
-
/derivatives/exchanges/{id}
Show derivative exchange data
pto.get_derivatives_exchanges_by_id()
-
/derivatives/exchanges/list List all derivative exchanges name and identifier
pto.get_derivatives_exchanges_list()
exchange_rates
- /exchange_rates
Get BTC-to-Currency exchange rates
pto.get_exchange_rates()
search
- /search
Search for coins, categories and markets on Pesto
pto.search()
trending
- /search/trending
Get trending search coins (Top-7) on Pesto in the last 24 hours
pto.get_search_trending()
global
-
/global
Get cryptocurrency global data
pto.get_global()
-
/global/decentralized_finance_defi
Get cryptocurrency global decentralized finance(defi) data
pto.get_global_decentralized_finance_defi()
-
[Pro API] 💼 /global/market_cap_chart
Query historical global market cap and volume data by number of days away from now)
pto.get_global_market_cap_chart()
companies (beta)
- /companies/public_treasury/{coin_id}
Query public companies’ bitcoin or ethereum holdings
python pto.get_companies_public_treasury_by_coin_id()
Test
Installation
Install required packages for testing using:
pip install pytest responses
Usage
Run unit tests with:
# after installing pytest and responses using pip3
pytest tests
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pypestoai-2.2.3.tar.gz.
File metadata
- Download URL: pypestoai-2.2.3.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc7b377f86e5789e0d9ee83b17b3e29163b9f8de241dc5af688a4bfd088072d7
|
|
| MD5 |
cca5a00a81a45f49ed70743e72595f3f
|
|
| BLAKE2b-256 |
a2df12e82be1ba5239cf3ad1e532be245665247a61f536f566bb099ca6fc2894
|
File details
Details for the file pypestoai-2.2.3-py3-none-any.whl.
File metadata
- Download URL: pypestoai-2.2.3-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad2e48bf28baf63c8f19862147c861e5312ffa1a19f5fa79047571ba76187d32
|
|
| MD5 |
888de92fc78a02607cb9a578e1fe0ba2
|
|
| BLAKE2b-256 |
eb75f83b7b9b9501bc0e68aaecac0fde0a1e705c3d756054c12e1a01de017210
|