gas-network-sdk


Namegas-network-sdk JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryPython SDK for Gas Network API - gas price prediction and optimization
upload_time2025-08-28 18:37:28
maintainerNone
docs_urlNone
authorrshuwy
requires_python>=3.8
licenseNone
keywords gas ethereum blockchain web3 api gas-prices
VCS
bugtrack_url
requirements httpx pydantic pytest pytest-asyncio pytest-httpx black mypy ruff
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Gas Network SDK

A Python SDK for the Gas Network API, providing gas price prediction and optimization for blockchain transactions.

## Features

- **Multi-chain support**: Ethereum, Polygon, Bitcoin, SEI, Optimism, Arbitrum, Base, Linea, Unichain
- **Real-time gas price estimates** with confidence levels
- **Base fee and blob fee predictions** (Ethereum only)
- **Gas price distribution analysis** (Ethereum only)
- **Oracle integration** for on-chain gas data
- **Async/await support** with httpx
- **Type-safe** with Pydantic models
- **Comprehensive error handling**

## Installation

```bash
pip install gas-network-sdk
```

## Quick Start

```python
import asyncio
from gas_network_sdk import GasNetworkClient, Chain

async def main():
    # Create client with your API key (optional)
    client = GasNetworkClient(api_key="your_api_key_here")
    
    # Get gas prices for Ethereum
    gas_prices = await client.get_gas_prices(Chain.ETHEREUM)
    print(f"Current gas prices: {gas_prices}")
    
    # Get next block estimate with 90% confidence
    estimate = await client.get_next_block_estimate(Chain.ETHEREUM, confidence_level=90)
    print(f"Next block estimate: {estimate.price} gwei")
    
    await client.close()

# Run the example
asyncio.run(main())
```

## API Reference

### Client Creation

```python
from gas_network_sdk import GasNetworkClient

# With API key (recommended for higher rate limits)
client = GasNetworkClient(api_key="your_api_key")

# Without API key (rate limited)
client = GasNetworkClient()
```

### Gas Price Estimation

```python
# Get comprehensive gas price data
prices = await client.get_gas_prices(Chain.BASE)

# Get specific confidence level estimate
estimate = await client.get_next_block_estimate(Chain.ETHEREUM, confidence_level=95)
```

### Base Fee Prediction (Ethereum only)

```python
base_fees = await client.get_base_fee_estimates(Chain.ETHEREUM)
print(f"Current base fee: {base_fees.base_fee_per_gas} gwei")
print(f"Blob base fee: {base_fees.blob_base_fee_per_gas} gwei")

# Get estimates for next 5 blocks
for block_estimate in base_fees.estimated_base_fees:
    for pending_block, estimates in block_estimate.pending_block.items():
        for estimate in estimates:
            print(f"{pending_block}: Base fee {estimate.base_fee} gwei ({estimate.confidence}% confidence)")
```

### Gas Distribution Analysis (Ethereum only)

```python
distribution = await client.get_gas_distribution(Chain.ETHEREUM)
print(f"Current block: {distribution.current_block_number}")
for price, count in distribution.top_n_distribution.distribution:
    print(f"Price: {price} gwei, Transactions: {count}")
```

### Oracle Data

```python
# Get oracle data for a specific chain ID
oracle_data = await client.get_oracle_data(1)  # Ethereum mainnet
```

## Supported Chains

- Ethereum
- Polygon  
- Bitcoin
- SEI
- Optimism
- Arbitrum
- Base
- Linea
- Unichain

## Error Handling

The SDK uses comprehensive error handling:

```python
from gas_network_sdk import GasNetworkError, UnsupportedChainError, APIError

try:
    prices = await client.get_gas_prices(Chain.ETHEREUM)
    print(f"Success: {prices}")
except UnsupportedChainError as e:
    print(f"Unsupported chain: {e}")
except APIError as e:
    print(f"API error: {e}")
except GasNetworkError as e:
    print(f"Other error: {e}")
```

## Context Manager Usage

```python
async with GasNetworkClient(api_key="your_api_key") as client:
    prices = await client.get_gas_prices(Chain.ETHEREUM)
    print(prices)
# Client is automatically closed
```

## Authentication

You can optionally use an API key from [Blocknative](https://blocknative.com) for higher rate limits. The API works without authentication but with rate limitations.

## License

Licensed under either of

- Apache License, Version 2.0
- MIT License

at your option.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gas-network-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "gas, ethereum, blockchain, web3, api, gas-prices",
    "author": "rshuwy",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/c9/d8/0e759cca310c512d08c2a95a3d274da58c5393e6ac167350c6b6a1a839a3/gas_network_sdk-0.1.0.tar.gz",
    "platform": null,
    "description": "# Gas Network SDK\n\nA Python SDK for the Gas Network API, providing gas price prediction and optimization for blockchain transactions.\n\n## Features\n\n- **Multi-chain support**: Ethereum, Polygon, Bitcoin, SEI, Optimism, Arbitrum, Base, Linea, Unichain\n- **Real-time gas price estimates** with confidence levels\n- **Base fee and blob fee predictions** (Ethereum only)\n- **Gas price distribution analysis** (Ethereum only)\n- **Oracle integration** for on-chain gas data\n- **Async/await support** with httpx\n- **Type-safe** with Pydantic models\n- **Comprehensive error handling**\n\n## Installation\n\n```bash\npip install gas-network-sdk\n```\n\n## Quick Start\n\n```python\nimport asyncio\nfrom gas_network_sdk import GasNetworkClient, Chain\n\nasync def main():\n    # Create client with your API key (optional)\n    client = GasNetworkClient(api_key=\"your_api_key_here\")\n    \n    # Get gas prices for Ethereum\n    gas_prices = await client.get_gas_prices(Chain.ETHEREUM)\n    print(f\"Current gas prices: {gas_prices}\")\n    \n    # Get next block estimate with 90% confidence\n    estimate = await client.get_next_block_estimate(Chain.ETHEREUM, confidence_level=90)\n    print(f\"Next block estimate: {estimate.price} gwei\")\n    \n    await client.close()\n\n# Run the example\nasyncio.run(main())\n```\n\n## API Reference\n\n### Client Creation\n\n```python\nfrom gas_network_sdk import GasNetworkClient\n\n# With API key (recommended for higher rate limits)\nclient = GasNetworkClient(api_key=\"your_api_key\")\n\n# Without API key (rate limited)\nclient = GasNetworkClient()\n```\n\n### Gas Price Estimation\n\n```python\n# Get comprehensive gas price data\nprices = await client.get_gas_prices(Chain.BASE)\n\n# Get specific confidence level estimate\nestimate = await client.get_next_block_estimate(Chain.ETHEREUM, confidence_level=95)\n```\n\n### Base Fee Prediction (Ethereum only)\n\n```python\nbase_fees = await client.get_base_fee_estimates(Chain.ETHEREUM)\nprint(f\"Current base fee: {base_fees.base_fee_per_gas} gwei\")\nprint(f\"Blob base fee: {base_fees.blob_base_fee_per_gas} gwei\")\n\n# Get estimates for next 5 blocks\nfor block_estimate in base_fees.estimated_base_fees:\n    for pending_block, estimates in block_estimate.pending_block.items():\n        for estimate in estimates:\n            print(f\"{pending_block}: Base fee {estimate.base_fee} gwei ({estimate.confidence}% confidence)\")\n```\n\n### Gas Distribution Analysis (Ethereum only)\n\n```python\ndistribution = await client.get_gas_distribution(Chain.ETHEREUM)\nprint(f\"Current block: {distribution.current_block_number}\")\nfor price, count in distribution.top_n_distribution.distribution:\n    print(f\"Price: {price} gwei, Transactions: {count}\")\n```\n\n### Oracle Data\n\n```python\n# Get oracle data for a specific chain ID\noracle_data = await client.get_oracle_data(1)  # Ethereum mainnet\n```\n\n## Supported Chains\n\n- Ethereum\n- Polygon  \n- Bitcoin\n- SEI\n- Optimism\n- Arbitrum\n- Base\n- Linea\n- Unichain\n\n## Error Handling\n\nThe SDK uses comprehensive error handling:\n\n```python\nfrom gas_network_sdk import GasNetworkError, UnsupportedChainError, APIError\n\ntry:\n    prices = await client.get_gas_prices(Chain.ETHEREUM)\n    print(f\"Success: {prices}\")\nexcept UnsupportedChainError as e:\n    print(f\"Unsupported chain: {e}\")\nexcept APIError as e:\n    print(f\"API error: {e}\")\nexcept GasNetworkError as e:\n    print(f\"Other error: {e}\")\n```\n\n## Context Manager Usage\n\n```python\nasync with GasNetworkClient(api_key=\"your_api_key\") as client:\n    prices = await client.get_gas_prices(Chain.ETHEREUM)\n    print(prices)\n# Client is automatically closed\n```\n\n## Authentication\n\nYou can optionally use an API key from [Blocknative](https://blocknative.com) for higher rate limits. The API works without authentication but with rate limitations.\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0\n- MIT License\n\nat your option.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python SDK for Gas Network API - gas price prediction and optimization",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/rshuwy/gas-network-python-sdk/issues",
        "Documentation": "https://github.com/rshuwy/gas-network-python-sdk#readme",
        "Homepage": "https://github.com/rshuwy/gas-network-python-sdk",
        "Repository": "https://github.com/rshuwy/gas-network-python-sdk"
    },
    "split_keywords": [
        "gas",
        " ethereum",
        " blockchain",
        " web3",
        " api",
        " gas-prices"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "05bfdcad1bd76440a12a26dd30149478db7c79ebbe37f3a6880eca0ac5615777",
                "md5": "e7b13e4d2b93cff78b9c189e215bd123",
                "sha256": "7891a1189d31f92de19c1b61fa040b6a1b6794e8240420a6bdcb429b7e319447"
            },
            "downloads": -1,
            "filename": "gas_network_sdk-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e7b13e4d2b93cff78b9c189e215bd123",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 12133,
            "upload_time": "2025-08-28T18:37:27",
            "upload_time_iso_8601": "2025-08-28T18:37:27.439201Z",
            "url": "https://files.pythonhosted.org/packages/05/bf/dcad1bd76440a12a26dd30149478db7c79ebbe37f3a6880eca0ac5615777/gas_network_sdk-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c9d80e759cca310c512d08c2a95a3d274da58c5393e6ac167350c6b6a1a839a3",
                "md5": "215ab6a3193777439a0657ae91573e53",
                "sha256": "42603b64aa694743f6b843f8d979bc2b0f7e722711f8b70979e136ce3fea3124"
            },
            "downloads": -1,
            "filename": "gas_network_sdk-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "215ab6a3193777439a0657ae91573e53",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 17613,
            "upload_time": "2025-08-28T18:37:28",
            "upload_time_iso_8601": "2025-08-28T18:37:28.619425Z",
            "url": "https://files.pythonhosted.org/packages/c9/d8/0e759cca310c512d08c2a95a3d274da58c5393e6ac167350c6b6a1a839a3/gas_network_sdk-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-28 18:37:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rshuwy",
    "github_project": "gas-network-python-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "httpx",
            "specs": [
                [
                    ">=",
                    "0.24.0"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    ">=",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    ">=",
                    "7.0.0"
                ]
            ]
        },
        {
            "name": "pytest-asyncio",
            "specs": [
                [
                    ">=",
                    "0.21.0"
                ]
            ]
        },
        {
            "name": "pytest-httpx",
            "specs": [
                [
                    ">=",
                    "0.21.0"
                ]
            ]
        },
        {
            "name": "black",
            "specs": [
                [
                    ">=",
                    "23.0.0"
                ]
            ]
        },
        {
            "name": "mypy",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "ruff",
            "specs": [
                [
                    ">=",
                    "0.1.0"
                ]
            ]
        }
    ],
    "lcname": "gas-network-sdk"
}
        
Elapsed time: 4.31011s