Skip to main content

pyyorkshirewater

Async Python client for the Yorkshire Water customer self-service API.

This library is unofficial and not affiliated with Yorkshire Water. It exists so that customers can read their own smart meter consumption data from the same backend that powers my.yorkshirewater.com.

Status

Early alpha. The smart meter rollout is in progress across the Yorkshire Water region between 2025 and 2030, so most accounts will not yet have a live meter. Until a meter is live the client will report a MeterStatus of NO_METER or PENDING_ACTIVATION, and the consumption endpoints (get_your_usage, get_daily_consumption, get_yearly_consumption) will raise YorkshireWaterMeterNotReadyError. The readiness probes (get_meter_details, get_current_consumption) work in every state.

Why cookies, not email and password

Yorkshire Water's portal SPA uses Duende IdentityServer with authorization code plus PKCE only. The SPA OAuth client (css-onlineaccount-fe) is not permitted to use the password grant, the device flow or offline_access, and the login form is protected by invisible Google reCAPTCHA v3 which a non-browser HTTP client cannot pass.

The workable architecture is therefore: the user logs in to my.yorkshirewater.com once in their own browser, where reCAPTCHA succeeds naturally, and exports the IdentityServer session cookie. This library uses that cookie to drive /connect/authorize?prompt=none for silent renewal, mints fresh access tokens on demand and never sees the user's password.

The companion Chrome extension (separate repository) makes cookie export a single click.

Install

pip install pyyorkshirewater

Python 3.11 or newer.

Quick start

import asyncio
from pyyorkshirewater import YorkshireWaterClient, MeterStatus

cookies = {
    "idsrv": "<value from a logged-in browser session>",
    "idsrv.session": "<value from a logged-in browser session>",
    # any other login.yorkshirewater.com cookies your browser holds
}

async def main():
    async with YorkshireWaterClient(cookies=cookies) as client:
        await client.login()

        if client.meter_status is MeterStatus.LIVE:
            daily = await client.get_daily_consumption()
            print(daily)
        else:
            print(f"Meter is {client.meter_status.value}, no data yet.")

asyncio.run(main())

The IdentityServer session cookie typically lives between several hours and several weeks depending on the provider's configuration. Each silent renewal call may extend it (sliding expiration) on servers configured for that. When the cookie eventually expires, the library raises CookieSessionExpiredError (a subclass of YorkshireWaterAuthError) with error="login_required". Callers should catch this and prompt the user for fresh cookies. The Home Assistant integration handles this via a reauth flow.

Meter readiness states

Yorkshire Water's portal exposes a three-state model. The library mirrors it through the MeterStatus enum:

  • NO_METER: the account has no smart meter on it.
  • PENDING_ACTIVATION: a meter is registered but is awaiting network setup by Yorkshire Water.
  • LIVE: the meter is reporting data and the consumption endpoints will return real values.

Application code should check client.meter_status before requesting consumption data.

Logging

The library logs to a named logger called pyyorkshirewater at the DEBUG level. Configure it in the usual way:

import logging
logging.getLogger("pyyorkshirewater").setLevel(logging.DEBUG)

Errors

All errors raised by the library inherit from YorkshireWaterError. The specific subclasses are:

  • YorkshireWaterAuthError: silent renewal failed for a reason that is not cookie expiry. The original IdentityServer error and error_description are exposed on the exception.
  • CookieSessionExpiredError (subclass of YorkshireWaterAuthError): the IdP session cookie is expired or invalid. Re-export from a fresh browser session.
  • YorkshireWaterAPIError: a non-auth HTTP error from the customer API.
  • YorkshireWaterMeterNotReadyError: raised when a consumption endpoint is called against a meter that is not yet LIVE.
  • YorkshireWaterRateLimitError: 429 response with optional retry_after.
  • dan-simms1/ha-yorkshire-water: Home Assistant integration that uses this library.
  • (forthcoming) Chrome extension that extracts the cookies needed by this library and the integration with one click.

Disclaimer

This project is unofficial and not affiliated with, endorsed by or supported by Yorkshire Water Services Limited. Trademarks are the property of their respective owners. Use this software at your own risk and only against accounts that you own.

Licence

MIT. See LICENSE.

Metadata

Release files for pyyorkshirewater 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyyorkshirewater 1.6.0
File Size Uploaded
pyyorkshirewater-1.6.0.tar.gz 31.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyyorkshirewater 1.6.0
File Interpreter ABI Platform
pyyorkshirewater-1.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 57.7 kB

Release files / pyyorkshirewater-1.6.0.tar.gz

Download URL pyyorkshirewater-1.6.0.tar.gz
Size 31.9 kB
Tags Source
SHA-256 checksum
How to use checksums
400b71f10b76c53a657c57ff7e3aa5116b5817bfc3dc518e38999deb35280f95
BLAKE2b-256 checksum
How to use checksums
1cdcbc8713723985045fd5732be32907e76600a7e858f034f5f45ee0b71b4f7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 10, 2026.

Transparency log

Release files / pyyorkshirewater-1.6.0-py3-none-any.whl

Download URL pyyorkshirewater-1.6.0-py3-none-any.whl
Size 25.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f9c4dcff314525c76632b884548e7b680c8ae883b9272d5d81bfa67a672622d
BLAKE2b-256 checksum
How to use checksums
15bb4088df6ee3f5f0d3da058b8487d9d5fde565f6f57c703ef40fffbb7a30e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.6.0 This release

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page