Name | python-ethgas JSON |
Version |
0.2.0
JSON |
| download |
home_page | None |
Summary | Unofficial EthGas client packages |
upload_time | 2024-11-05 08:31:06 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <3.11.6,>=3.11.0 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# python-ethgas
This is a Python3 connector for EthGas's RESTful APIs and WebSocket.
Please note that the python-ethgas package is an <b>unofficial</b> project and should be used at your own risk.
It is <b>NOT</b> affiliated with the EthGas and does <b>NOT</b> provide financial or investment advice.
## Table of Contents
- <b>[Overview](#overview)</b>
- <b>[Features](#features)</b>
- <b>[Documentation](#documentation)</b>
- <b>[Quick Start](#quick-start)</b>
- <b>[Example Usage](#example-usage)</b>
- <b>[Disclaimer](#disclaimer)</b>
- <b>[Contact](#contact)</b>
## Overview
The <code>python-ethgas</code> package is a Python3 connector that allows you to interact with the EthGas.
The package utilizes threads to handle concurrent execution of REST API requests and WebSocket subscriptions.
This allows for efficient handling of multiple requests and real-time data streams without blocking the main execution
thread.
The connector provides a <b>REST client</b> that allows you to make requests to all the available REST API endpoints of
the EthGas.
You can perform actions such as retrieving user information, and more.
It also includes a <b>WebSocket client</b> that enables you to subscribe to real-time data streams from EthGas.
You can subscribe to channels like preconf market data, transaction data etc.
To access private endpoints and perform actions on behalf of a user,
both API and Websocket client classes handle the login process and manage the authentication using the <b>JWT access
token</b>.
After you sign in to `APIClient`, the access token is saved and used for private requests. This access token can also be
employed to log in to `WsClient`.
Within this package, you have the option to pass the authenticated APIClient instance to the WsClient class, allowing
for a private WebSocket connection.
This project is undergoing active development, ensuring that new changes to the EthGas APIs or Websocket will be
promptly integrated.
For feedback or suggestions, please reach out via one of the contact methods specified in <b>[Contact](#contact)</b>.
## Features
<ol style="line-height:180%" type="1">
<li>REST API Handling</li>
<li>WebSocket Handling</li>
<li>Thread-based Execution</li>
<li>Exception Handling and Reconnection</li></ol>
| Release Version | Changelog |
|-----------------|---------------------|
| `0.2.0` | Development release |
## Documentation
For more detailed information, please refer to the [EthGas Developer Docs](https://developers.ethgas.com/#change-log).
## Quick Start
### Prerequisites
<code>python-ethgas</code> is tested on python version: `3.11`.
Earlier or Later versions of Python might work, but they have not been thoroughly tested and could potentially conflict
with the external web3 library.
<code>python-ethgas</code> utilizes web3, threading, websocket-client and requests for its methods, alongside other
built-in modules.
As the package utilizes the web3 library, we suggest to use version `>=7.4.0` here.
### Installation
To get started with the <code>python-ethgas</code> package, you can install it manually or via <b>PyPI</b> with <code>
pip</code>:
```commandline
pip install python-ethgas
```
## Example Usage
To be able to interact with private endpoints, an ethereum EOA account (wallet address) and the corresponding private
key is <b>required</b>.
We suggest to not include those information in your source code directly but alternatively store them in environment
variables.
Again, please note that the <code>python-ethgas</code> package is an <b>unofficial</b> project and should be used at
your own risk.
<b>JWT access token</b> handling is managed in this package for authentication. For interacting with private endpoints
or private websocket, a login is
required on the EthGas side.
If you intend to establish a private WebSocket connection, please create an instance of the `APIClient` class, log into
your account, and pass it to `WsClient`.
If you want to only interact with public endpoints or public websocket, there is no need to supply an account address or
private key. (Refer to sections 2.1a and 2.2a for more details.)
### 1. Import the required modules
```python
# EthGas REST API Client
from ethgas.rest.api_client import APIClient
# EthGas Websocket Client
from ethgas.websocket.ws_client import WsClient
```
### 2. EthGas REST / WEBSOCKET client
#### 2.1 REST client
```python
# EthGas REST API Client
from ethgas.rest.api_client import APIClient
```
##### 2.1a Public REST client
```python
import logging
from ethgas.utils import helper
# EthGas REST API Client
from ethgas.rest.api_client import APIClient
# create logger
logger = helper.create_logger(logger_level=logging.INFO, logger_name="public_api_client")
rest_url = "<EthGas REST API URL>"
chain_id = "<Chain ID>"
# create public api client
rest = APIClient(rest_url=rest_url, chain_id=chain_id,
logger=logger)
```
##### 2.1b Private REST client
```python
import logging
from ethgas.utils import helper
# EthGas REST API Client
from ethgas.rest.api_client import APIClient
# create logger
logger = helper.create_logger(logger_level=logging.INFO, logger_name="private_api_client")
rest_url = "<EthGas REST API URL>"
chain_id = "<Chain ID>"
# set account address and private key
address = "<Account Address>"
private_key = "<Account Private Key>"
# create private api client
rest = APIClient(rest_url=rest_url, chain_id=chain_id,
account_address=address, private_key=private_key,
logger=logger)
```
#### 2.2 WEBSOCKET client
```python
# EthGas Websocket Client
from ethgas.websocket.ws_client import WsClient
```
##### 2.2a Public WEBSOCKET client
```python
import logging
from ethgas.utils import helper
# EthGas Websocket Client
from ethgas.websocket.ws_client import WsClient
# create logger
logger = helper.create_logger(logger_level=logging.INFO, logger_name="public_ws_client")
ws_url = "<EthGas Websocket URL>"
# create public websocket client
ws = WsClient(ws_url=ws_url, auto_reconnect_retries=5, logger=logger)
```
##### 2.2b Private WEBSOCKET client
```python
import logging
from ethgas.utils import helper
# EthGas REST API Client
from ethgas.rest.api_client import APIClient
# EthGas Websocket Client
from ethgas.websocket.ws_client import WsClient
# create logger
logger = helper.create_logger(logger_level=logging.INFO, logger_name="private_ws_client")
rest_url = "<EthGas REST API URL>"
chain_id = "<Chain ID>"
# set account address and private key
address = "<Account Address>"
private_key = "<Account Private Key>"
# create private api client
rest = APIClient(rest_url=rest_url, chain_id=chain_id,
account_address=address, private_key=private_key,
logger=logger)
ws_url = "<EthGas Websocket URL>"
# create private websocket client
ws = WsClient(ws_url=ws_url, api_client=rest, auto_reconnect_retries=5, logger=logger)
```
## Disclaimer
This is an unofficial Python project (the "Package") and made available for informational purpose only and does not
constitute financial, investment or trading advice.
You acknowledge and agree to comply with the Terms of service at https://www.ethgas.com/terms-of-service. If you
do not agree, please do not use this package.
Any unauthorised use of the Package is strictly prohibited.
## Contact
For support, suggestions or feedback please reach out to us via the following email address <code>
gaspy503@gmail.com</code>.
Raw data
{
"_id": null,
"home_page": null,
"name": "python-ethgas",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.11.6,>=3.11.0",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "gaspy503 <gaspy503@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a4/33/69903966fcafbedc322c93c4134f416e27a15d40d61bff81b8cfea1ae41d/python_ethgas-0.2.0.tar.gz",
"platform": null,
"description": "# python-ethgas\n\nThis is a Python3 connector for EthGas's RESTful APIs and WebSocket.\n\nPlease note that the python-ethgas package is an <b>unofficial</b> project and should be used at your own risk.\nIt is <b>NOT</b> affiliated with the EthGas and does <b>NOT</b> provide financial or investment advice.\n\n## Table of Contents\n\n- <b>[Overview](#overview)</b>\n- <b>[Features](#features)</b>\n- <b>[Documentation](#documentation)</b>\n- <b>[Quick Start](#quick-start)</b>\n- <b>[Example Usage](#example-usage)</b>\n- <b>[Disclaimer](#disclaimer)</b>\n- <b>[Contact](#contact)</b>\n\n## Overview\n\nThe <code>python-ethgas</code> package is a Python3 connector that allows you to interact with the EthGas.\nThe package utilizes threads to handle concurrent execution of REST API requests and WebSocket subscriptions.\nThis allows for efficient handling of multiple requests and real-time data streams without blocking the main execution\nthread.\n\nThe connector provides a <b>REST client</b> that allows you to make requests to all the available REST API endpoints of\nthe EthGas.\nYou can perform actions such as retrieving user information, and more.\nIt also includes a <b>WebSocket client</b> that enables you to subscribe to real-time data streams from EthGas.\nYou can subscribe to channels like preconf market data, transaction data etc.\n\nTo access private endpoints and perform actions on behalf of a user,\nboth API and Websocket client classes handle the login process and manage the authentication using the <b>JWT access\ntoken</b>.\nAfter you sign in to `APIClient`, the access token is saved and used for private requests. This access token can also be\nemployed to log in to `WsClient`.\nWithin this package, you have the option to pass the authenticated APIClient instance to the WsClient class, allowing\nfor a private WebSocket connection.\n\nThis project is undergoing active development, ensuring that new changes to the EthGas APIs or Websocket will be\npromptly integrated.\n\nFor feedback or suggestions, please reach out via one of the contact methods specified in <b>[Contact](#contact)</b>.\n\n## Features\n\n<ol style=\"line-height:180%\" type=\"1\">\n<li>REST API Handling</li>\n<li>WebSocket Handling</li>\n<li>Thread-based Execution</li>\n<li>Exception Handling and Reconnection</li></ol>\n\n| Release Version | Changelog |\n|-----------------|---------------------|\n| `0.2.0` | Development release |\n\n## Documentation\n\nFor more detailed information, please refer to the [EthGas Developer Docs](https://developers.ethgas.com/#change-log).\n\n## Quick Start\n\n### Prerequisites\n\n<code>python-ethgas</code> is tested on python version: `3.11`.\nEarlier or Later versions of Python might work, but they have not been thoroughly tested and could potentially conflict\nwith the external web3 library.\n\n<code>python-ethgas</code> utilizes web3, threading, websocket-client and requests for its methods, alongside other\nbuilt-in modules.\nAs the package utilizes the web3 library, we suggest to use version `>=7.4.0` here.\n\n### Installation\n\nTo get started with the <code>python-ethgas</code> package, you can install it manually or via <b>PyPI</b> with <code>\npip</code>:\n\n```commandline\npip install python-ethgas\n```\n\n## Example Usage\n\nTo be able to interact with private endpoints, an ethereum EOA account (wallet address) and the corresponding private\nkey is <b>required</b>.\nWe suggest to not include those information in your source code directly but alternatively store them in environment\nvariables.\nAgain, please note that the <code>python-ethgas</code> package is an <b>unofficial</b> project and should be used at\nyour own risk.\n\n<b>JWT access token</b> handling is managed in this package for authentication. For interacting with private endpoints\nor private websocket, a login is\nrequired on the EthGas side.\nIf you intend to establish a private WebSocket connection, please create an instance of the `APIClient` class, log into\nyour account, and pass it to `WsClient`.\nIf you want to only interact with public endpoints or public websocket, there is no need to supply an account address or\nprivate key. (Refer to sections 2.1a and 2.2a for more details.)\n\n### 1. Import the required modules\n\n```python\n# EthGas REST API Client\nfrom ethgas.rest.api_client import APIClient\n# EthGas Websocket Client\nfrom ethgas.websocket.ws_client import WsClient\n```\n\n### 2. EthGas REST / WEBSOCKET client\n\n#### 2.1 REST client\n\n```python\n# EthGas REST API Client\nfrom ethgas.rest.api_client import APIClient\n```\n\n##### 2.1a Public REST client\n\n```python\nimport logging\nfrom ethgas.utils import helper\n# EthGas REST API Client\nfrom ethgas.rest.api_client import APIClient\n\n# create logger\nlogger = helper.create_logger(logger_level=logging.INFO, logger_name=\"public_api_client\")\nrest_url = \"<EthGas REST API URL>\"\nchain_id = \"<Chain ID>\"\n# create public api client\nrest = APIClient(rest_url=rest_url, chain_id=chain_id,\n logger=logger)\n```\n\n##### 2.1b Private REST client\n\n```python\nimport logging\nfrom ethgas.utils import helper\n# EthGas REST API Client\nfrom ethgas.rest.api_client import APIClient\n\n# create logger\nlogger = helper.create_logger(logger_level=logging.INFO, logger_name=\"private_api_client\")\nrest_url = \"<EthGas REST API URL>\"\nchain_id = \"<Chain ID>\"\n# set account address and private key\naddress = \"<Account Address>\"\nprivate_key = \"<Account Private Key>\"\n# create private api client\nrest = APIClient(rest_url=rest_url, chain_id=chain_id,\n account_address=address, private_key=private_key,\n logger=logger)\n```\n\n#### 2.2 WEBSOCKET client\n\n```python\n# EthGas Websocket Client\nfrom ethgas.websocket.ws_client import WsClient\n```\n\n##### 2.2a Public WEBSOCKET client\n\n```python\nimport logging\nfrom ethgas.utils import helper\n# EthGas Websocket Client\nfrom ethgas.websocket.ws_client import WsClient\n\n# create logger\nlogger = helper.create_logger(logger_level=logging.INFO, logger_name=\"public_ws_client\")\nws_url = \"<EthGas Websocket URL>\"\n# create public websocket client\nws = WsClient(ws_url=ws_url, auto_reconnect_retries=5, logger=logger)\n```\n\n##### 2.2b Private WEBSOCKET client\n\n```python\nimport logging\nfrom ethgas.utils import helper\n# EthGas REST API Client\nfrom ethgas.rest.api_client import APIClient\n# EthGas Websocket Client\nfrom ethgas.websocket.ws_client import WsClient\n\n# create logger\nlogger = helper.create_logger(logger_level=logging.INFO, logger_name=\"private_ws_client\")\nrest_url = \"<EthGas REST API URL>\"\nchain_id = \"<Chain ID>\"\n# set account address and private key\naddress = \"<Account Address>\"\nprivate_key = \"<Account Private Key>\"\n# create private api client\nrest = APIClient(rest_url=rest_url, chain_id=chain_id,\n account_address=address, private_key=private_key,\n logger=logger)\nws_url = \"<EthGas Websocket URL>\"\n# create private websocket client\nws = WsClient(ws_url=ws_url, api_client=rest, auto_reconnect_retries=5, logger=logger)\n```\n\n## Disclaimer\n\nThis is an unofficial Python project (the \"Package\") and made available for informational purpose only and does not\nconstitute financial, investment or trading advice.\nYou acknowledge and agree to comply with the Terms of service at https://www.ethgas.com/terms-of-service. If you\ndo not agree, please do not use this package.\nAny unauthorised use of the Package is strictly prohibited.\n\n## Contact\n\nFor support, suggestions or feedback please reach out to us via the following email address <code>\ngaspy503@gmail.com</code>.\n",
"bugtrack_url": null,
"license": null,
"summary": "Unofficial EthGas client packages",
"version": "0.2.0",
"project_urls": {
"Bug Tracker": "https://github.com/gaspy503/python-ethgas/issues",
"Homepage": "https://github.com/gaspy503/python-ethgas"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2c82b090106aba3584911f4bce885dc67473a6ebebd6b5d0c04cf678ee004760",
"md5": "666ba3017d9af5c48d3bb2b79e2f0354",
"sha256": "0ebdd490717a4eba6d46069f1b4bc0bc2543b8a8b5beaca3ac26f16afe491f81"
},
"downloads": -1,
"filename": "python_ethgas-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "666ba3017d9af5c48d3bb2b79e2f0354",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.11.6,>=3.11.0",
"size": 19164,
"upload_time": "2024-11-05T08:31:04",
"upload_time_iso_8601": "2024-11-05T08:31:04.734843Z",
"url": "https://files.pythonhosted.org/packages/2c/82/b090106aba3584911f4bce885dc67473a6ebebd6b5d0c04cf678ee004760/python_ethgas-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a43369903966fcafbedc322c93c4134f416e27a15d40d61bff81b8cfea1ae41d",
"md5": "73223f3284a9859f44700d3ef8b0fc78",
"sha256": "cee2b86df06336451cef6307fba37afff7440a93127c3455f59f1d564a0d420e"
},
"downloads": -1,
"filename": "python_ethgas-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "73223f3284a9859f44700d3ef8b0fc78",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.11.6,>=3.11.0",
"size": 19833,
"upload_time": "2024-11-05T08:31:06",
"upload_time_iso_8601": "2024-11-05T08:31:06.147899Z",
"url": "https://files.pythonhosted.org/packages/a4/33/69903966fcafbedc322c93c4134f416e27a15d40d61bff81b8cfea1ae41d/python_ethgas-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-05 08:31:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gaspy503",
"github_project": "python-ethgas",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "python-ethgas"
}