uw-api
Async Python client for the Utility Warehouse customer portal API.
Endpoints are hardcoded (discovered from myaccount.uw.co.uk/) and require no
configuration — just provide credentials.
Installation
pip install uw-api
Usage
import asyncio
from uw_api import UWClient
async def main():
async with UWClient(email="user@example.com", password="secret") as client:
await client.login()
account = await client.gql.get_account()
print(f"Account: {account.account_number}")
bills = await client.gql.get_bills()
for bill in bills:
print(f"Bill {bill.bill_id}: £{bill.total_amount_gbp}")
consumption = await client.gql.get_consumption()
print(f"Electricity: {consumption.electricity_kwh} kWh")
print(f"Gas: {consumption.gas_kwh} kWh")
meters = await client.gql.get_meters()
for meter in meters:
print(f"{meter.meter_type}: {meter.meter_number} (smart={meter.is_smart})")
tariff = await client.gql.get_tariff()
if tariff:
print(f"Tariff: {tariff.tariff_name}")
asyncio.run(main())
API Reference
Auth
client = UWClient(email="...", password="...")
await client.login()
Authenticates via OAuth2 PKCE at account.uw.co.uk/v2/login. Session cookies are
managed automatically. The library re-authenticates on 401 responses.
Account
account = await client.gql.get_account()
Returns UWAccount with account_id and account_number.
Energy
consumption = await client.gql.get_consumption()
services = await client.gql.get_energy_services()
usage = await client.gql.get_energy_usage()
get_consumption()→EnergyConsumption(latest electricity/gas kWh)get_energy_services()→ raw list of energy service dictsget_energy_usage()→ list ofEnergyUsagewith per-meter readings
Meters
meters = await client.gql.get_meters()
readings = await client.gql.get_meter_readings()
get_meters()→ list ofMeter(type, serial, smart status, last reading date)get_meter_readings()→ list ofMeterReading(value, type, date, source)
Bills
bills = await client.gql.get_bills()
pdf_url = await client.gql.get_pdf_url(month=1, year=2026)
get_bills()→ list ofBill(ID, date, amount, status, PDF URL)get_pdf_url(month, year)→ str URL for the bill PDF
Financial
balance = await client.gql.get_balance()
services = await client.gql.get_live_services()
tariff = await client.gql.get_tariff()
get_balance()→{"due": float, "overdue": float}get_live_services()→ dict of service statusesget_tariff()→EnergyTariff(name, code, rates)
Hardcoded Endpoints
| Purpose | URL |
|---|---|
| Login page | https://account.uw.co.uk/v2/login |
| GraphQL API | https://myaccount.uw.co.uk/server/graphql |
11 GraphQL operations are embedded in uw_api/graphql/queries.py.
Discovery Script (optional)
A HAR-based discovery script is included for verifying or re-discovering endpoints:
python scripts/discover_api.py parse-har capture.har
This is not required for normal use — the library ships with hardcoded
endpoints discovered from myaccount.uw.co.uk/ in July 2026.
Architecture
UWClient → UWAuth (OAuth2 PKCE)
→ UWGraphQL → /server/graphql (POST)
→ Pydantic v2 models
- Auth: CSRF token extraction from login page HTML, form-encoded POST with Castle.io device token
- GraphQL: All data via
POST /server/graphqlwith operation-oriented queries - Retry: 3 attempts with exponential backoff on 429/5xx, re-auth on 401
- Models:
UWAccount,EnergyUsage,EnergyConsumption,EnergyTariff,Meter,MeterReading,Bill,BillPDFMetadata
Metadata
Release files for uw-api 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| uw_api-0.2.2.tar.gz | 21.4 kB | With provenance | Details for uw_api-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| uw_api-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for uw_api-0.2.2-py3-none-any.whl |
Total release size: 37.3 kB
Release files / uw_api-0.2.2.tar.gz
| Download URL | uw_api-0.2.2.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33639c810097e841f8666f39ff001e632b7cf85fe1b3c802f52d5a80159bbede
|
|
BLAKE2b-256 checksum How to use checksums |
4b9275f56b1d93cdcba64b69932b8711b6ae7b1872006d91dfd4aef20b566b49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency logRelease files / uw_api-0.2.2-py3-none-any.whl
| Download URL | uw_api-0.2.2-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1ae7fc8e502b1aedc9f66dd40a51e69f0ff979ba9d872515cce65e77fd54f527
|
|
BLAKE2b-256 checksum How to use checksums |
4fe48da93c6db76d9e61ad7605c5b4b72868cd1adce39def77483f2d17e4758d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency logSecurity for uw-api 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for uw_api-0.2.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.