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:
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33786b6a18040a43183bc8ca7a43fa086e6828b7db92da44cc753dbcd1dff15f
|
|
| MD5 |
2210cab873089e9e221748919784765f
|
|
| BLAKE2b-256 |
f20c8f8acf310719f0041003c6f93ab4c95bc783c6fc25c0d37726d8ff8d32d2
|
Provenance
The following attestation bundles were made for aionatgrid-0.4.0.tar.gz:
Publisher:
release.yml on RyanMorash/aionatgrid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aionatgrid-0.4.0.tar.gz -
Subject digest:
33786b6a18040a43183bc8ca7a43fa086e6828b7db92da44cc753dbcd1dff15f - Sigstore transparency entry: 866449903
- Sigstore integration time:
-
Permalink:
RyanMorash/aionatgrid@ee305c2c9fdb65d1efa76aa247fd2f47940ef958 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/RyanMorash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ee305c2c9fdb65d1efa76aa247fd2f47940ef958 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efcd353ac1935e56c8891ccd6047ea82ab769b910d1a1e10aca8bd66c91e6360
|
|
| MD5 |
8aaf9cf96b085053e47ca3cd2c078d0b
|
|
| BLAKE2b-256 |
5494ce8bab85562abf508c79004f29c4df8306efe02234541fbedf27f6d92ada
|
Provenance
The following attestation bundles were made for aionatgrid-0.4.0-py3-none-any.whl:
Publisher:
release.yml on RyanMorash/aionatgrid
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aionatgrid-0.4.0-py3-none-any.whl -
Subject digest:
efcd353ac1935e56c8891ccd6047ea82ab769b910d1a1e10aca8bd66c91e6360 - Sigstore transparency entry: 866449999
- Sigstore integration time:
-
Permalink:
RyanMorash/aionatgrid@ee305c2c9fdb65d1efa76aa247fd2f47940ef958 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/RyanMorash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ee305c2c9fdb65d1efa76aa247fd2f47940ef958 -
Trigger Event:
release
-
Statement type: