Skip to main content

Python client for Lewisham Council civic data — bin collection schedules and address resolution.

Project description

lewisham-council-client

Framework-neutral Python client for Lewisham Council civic data. Provides asynchronous address resolution and waste collection schedule retrieval for any Lewisham UPRN.

No dependency on FastAPI, Home Assistant, MCP, uvicorn, or any web framework. Designed to be embedded directly in another Python application.

Unofficial — not affiliated with or endorsed by Lewisham Council. Uses undocumented public endpoints that may change without notice; the client raises UpstreamScraperChangedError when the response shape no longer matches expectations.

Installation

pip install lewisham-council-client

Usage

import asyncio
from lewisham_client import LewishamService

async def main() -> None:
    service = LewishamService()
    try:
        addresses = await service.lookup_addresses("SE6 1SQ")
        for address in addresses:
            print(address.uprn, address.title)

        if addresses:
            schedule = await service.get_collection_schedule(addresses[0].uprn)
            for entry in schedule.collections:
                print(entry.waste_type, entry.frequency, entry.next_collection)
    finally:
        await service.aclose()

asyncio.run(main())

LewishamService creates and manages its own httpx.AsyncClient by default. If the host application already manages a shared httpx.AsyncClient, pass it via LewishamClient:

import httpx
from lewisham_client import LewishamClient, LewishamService

async with httpx.AsyncClient() as http:
    service = LewishamService(client=LewishamClient(http_client=http))
    schedule = await service.get_collection_schedule(uprn)

Errors

All errors are subclasses of lewisham_client.DomainError:

Exception When
InvalidAddressSearchError Search input is too short or malformed.
InvalidUprnError UPRN is not a non-empty decimal string.
AddressNotFoundError No Lewisham address found for the given UPRN.
CollectionScheduleNotFoundError Lewisham returned no parseable schedule for the address.
UpstreamScraperChangedError Lewisham's response shape no longer matches expectations.
UpstreamUnavailableError Lewisham could not be reached (timeout or transport error).

Caching

LewishamService uses an in-process MemoryTtlCache by default with conservative TTLs (schedules: 24 h, address searches: 7 d, UPRNs: 30 d, negative results: 1 h). The defaults are suitable for a single-process consumer such as a Home Assistant integration.

Injectable cache and TTL parameters are available for consumers that need different policy or a shared cache.

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

lewisham_council_client-0.1.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

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

lewisham_council_client-0.1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file lewisham_council_client-0.1.0.tar.gz.

File metadata

  • Download URL: lewisham_council_client-0.1.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lewisham_council_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d1cfec7e9353b16897bd18f1ccc84d0af7e8416d5e0b22ea74befe9c86081235
MD5 7da7c49195df8663cba281ef1213ed26
BLAKE2b-256 cb64a3b1ff1095dec4a92e96f7b009065b9e816e3c2301142834b23479baaac4

See more details on using hashes here.

Provenance

The following attestation bundles were made for lewisham_council_client-0.1.0.tar.gz:

Publisher: publish.yml on OliverFarren/lewisham-council-scraper

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

File details

Details for the file lewisham_council_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lewisham_council_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6705916eac0d9764ee2db4b2c2587c893df6f4d0e2aec49897d78796d7f4952
MD5 67fb2490ca26aadb825f554a9c108502
BLAKE2b-256 e014c04713d610dde06f0bc187f16866c2a203bf03a6518d7a5713faaad71cb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for lewisham_council_client-0.1.0-py3-none-any.whl:

Publisher: publish.yml on OliverFarren/lewisham-council-scraper

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