Skip to main content

py-gaspriceio

PyPI Latest Release

Structured Python wrapper for GasPrice.io API.

Installation

Install py-gaspriceio.

Using pip

pip3 install gaspriceio

Build from source

git clone https://github.com/nekusu/py-gaspriceio.git
cd py-gaspriceio
pip3 install -r requirements.txt
sudo make install  # or `sudo python3 setup.py install`

Usage

Quick example:

>>> from gasprice import *
>>> from gasprice import utils
>>> from threading import Thread

# Estimates
>>> estimates_ = estimates()
>>> estimates_.base_fee
64.318551651
>>> estimates_.eth_price
3828.13
>>> estimates_.instant.fee_cap
73.75040681610001

# History (30 days)
>>> history = history_by_hour()
>>> history[0].estimates.base_fee
70.531785439

# Txpool Analysis
>>> txpool = txpool_analysis()
>>> txpool.base_fee
54.18059689
>>> utils.format_decimals(txpool.data[0].total_fees)
'0.225 ETH'
>>> txpool.data[0].analysis.transfer
0.126

# Lowest base fee
>>> lowest_fee = utils.lowest_base_fee(history)
>>> lowest_fee.estimates.base_fee
50.18255170481667
>>> str(lowest_fee.time)
'2021-10-18 07:00:00'

# Cheapest day
>>> utils.cheapest_day_average(history)
'Saturday'

# Realtime estimates (websocket)
>>> rt = realtime(print)
>>> Thread(target=rt.run).start()
<gasprice.shared.Estimates object (Instant: 140, Fast: 139, Eco: 101)>
<gasprice.shared.Estimates object (Instant: 129, Fast: 128, Eco: 95)>
<gasprice.shared.Estimates object (Instant: 138, Fast: 137, Eco: 95)>
>>> rt.close()

For better understanding, I recommend reading the GasPrice API documentation. All variables/functions names were renamed from camelCase to snake_case.

License

MIT - Copyright (c) 2021

Metadata

Release files for gaspriceio 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gaspriceio 1.0.0
File Size Uploaded
gaspriceio-1.0.0.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gaspriceio 1.0.0
File Interpreter ABI Platform
gaspriceio-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.9 kB

Release files / gaspriceio-1.0.0.tar.gz

Download URL gaspriceio-1.0.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
942ed88b7d1daaf7e2db6fe836b2160bcfa4a67f2b92dbfa8f4f56ba578791c5
BLAKE2b-256 checksum
How to use checksums
cbe09b6143d8713b0039883d16c7f9e2d8452b3b19ac52f1419d36116fc86c8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.4.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.7

Release files / gaspriceio-1.0.0-py3-none-any.whl

Download URL gaspriceio-1.0.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
53917ea0ea496daab1519e071077fcd4058a546c03e269ff2b2ef0a7a684f1ec
BLAKE2b-256 checksum
How to use checksums
ef133b935e294c8662923c855ef36214883dacf2fe556b6392b9e892c8d64d6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.4.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page