Skip to main content

Async Python client for National Grid built on aiohttp

Project description

aionatgrid

PyPI

Async Python client for National Grid's GraphQL and REST APIs.

Installation

pip install aionatgrid

Quick Start

import asyncio
from aionatgrid import NationalGridClient, NationalGridConfig

async def main() -> None:
    config = NationalGridConfig(
        username="user@example.com",
        password="your-password",
    )

    async with NationalGridClient(config=config) as client:
        accounts = await client.get_linked_accounts()
        for account in accounts:
            print(account["billingAccountId"])

if __name__ == "__main__":
    asyncio.run(main())

API Methods

Method Returns Description
get_linked_accounts() list[AccountLink] Get linked billing account IDs
get_billing_account() BillingAccount Get account details (region, meters, address)
get_energy_usage_costs() list[EnergyUsageCost] Get energy costs for a billing period
get_energy_usages() list[EnergyUsage] Get historical usage data
get_ami_energy_usages() list[AmiEnergyUsage] Get AMI hourly energy usage
get_interval_reads() list[IntervalRead] Get real-time meter interval reads

All methods return typed results using TypedDict models.

Examples

uv run python examples/list-accounts.py --username user@example.com --password secret
uv run python examples/account-info.py --username user@example.com --password secret
uv run python examples/energy-usage.py --username user@example.com --password secret
uv run python examples/interval-reads.py --username user@example.com --password secret
uv run python examples/ami-usage.py --username user@example.com --password secret

Development

Requires Python 3.10+ and uv.

uv sync                # install dependencies
uv run pytest          # run tests
uv run ruff check .    # lint
uv run ruff format .   # format
uv run mypy src        # type-check

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

aionatgrid-0.4.0.tar.gz (32.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aionatgrid-0.4.0-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file aionatgrid-0.4.0.tar.gz.

File metadata

  • Download URL: aionatgrid-0.4.0.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aionatgrid-0.4.0.tar.gz
Algorithm Hash digest
SHA256 33786b6a18040a43183bc8ca7a43fa086e6828b7db92da44cc753dbcd1dff15f
MD5 2210cab873089e9e221748919784765f
BLAKE2b-256 f20c8f8acf310719f0041003c6f93ab4c95bc783c6fc25c0d37726d8ff8d32d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for aionatgrid-0.4.0.tar.gz:

Publisher: release.yml on RyanMorash/aionatgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aionatgrid-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: aionatgrid-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aionatgrid-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efcd353ac1935e56c8891ccd6047ea82ab769b910d1a1e10aca8bd66c91e6360
MD5 8aaf9cf96b085053e47ca3cd2c078d0b
BLAKE2b-256 5494ce8bab85562abf508c79004f29c4df8306efe02234541fbedf27f6d92ada

See more details on using hashes here.

Provenance

The following attestation bundles were made for aionatgrid-0.4.0-py3-none-any.whl:

Publisher: release.yml on RyanMorash/aionatgrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page