Skip to main content

Async Python client for National Grid built on aiohttp

Project description

aionatgrid

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:
        response = await client.linked_billing_accounts()
        print(response.data)

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

Query Methods

Method Description
linked_billing_accounts() Get linked billing account IDs
billing_account_info() Get account details (region, meters, address)
energy_usage_costs() Get energy costs for a billing period
energy_usages() Get historical usage data
ami_energy_usages() Get AMI hourly energy usage
realtime_meter_info() Get real-time meter readings (REST)

For custom queries, use execute() with a GraphQLRequest directly.

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.3.0.tar.gz (32.2 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.3.0-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aionatgrid-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ab02fa0db15e30dbbafb1b419c5cc68d4ffc15cbceb80e217546384c1f9a3901
MD5 6032814b84e8d9add6495d181e85178a
BLAKE2b-256 51c2a60037afe950d329387593bd3cbc2a3640fde9af9663f4d92e87b0d13818

See more details on using hashes here.

Provenance

The following attestation bundles were made for aionatgrid-0.3.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.3.0-py3-none-any.whl.

File metadata

  • Download URL: aionatgrid-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 28.8 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d52ccd360e45c250633ccd578661a93f98a6919b381a15ac70922e585bf26cb
MD5 6cfa93cb718d0a05b986e1e34b622e0d
BLAKE2b-256 ccbd18e20206e0557dbc2fea4f8f5bdcedfbfcdea82753cf8507baae9481033d

See more details on using hashes here.

Provenance

The following attestation bundles were made for aionatgrid-0.3.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