Giter Club home page Giter Club logo

py-gaspriceio's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.