Skip to main content

pyCityParkingPermit

CI PyPI Python versions Issues Security policy

Async client for the CityParkingPermit parking service, built for Home Assistant custom integrations and any asyncio project.

Highlights

  • Async-only HTTP calls via aiohttp; you own the ClientSession.
  • Auth helper handles login and retries on 401/403 with cached defaults.
  • Typed dataclass models expose ISO 8601 timestamp strings.
  • Reservation and favorite helpers map CityParkingPermit Permit endpoints.
  • Requires the CityParkingPermit base_url to target your environment.

Requirements

  • Python 3.13.2+ (matches Home Assistant 2025.12)
  • aiohttp>=3.10.0

Installation

python -m pip install pyCityParkingPermit

Quick start

import asyncio
from aiohttp import ClientSession

from pyCityParkingPermit import Auth, CityParkingPermitAPI

BASE_URL = "https://cityparkingpermit.example"


async def main() -> None:
    async with ClientSession() as session:
        auth = Auth(session, username="user", password="pass", base_url=BASE_URL)
        api = CityParkingPermitAPI(auth)
        account = await api.async_get_account()
        reservations = await api.async_list_reservations()
        favorites = await api.async_list_favorites()
        print(account, reservations, favorites)


asyncio.run(main())

Auth requires the CityParkingPermit base_url; set it to your tenant's endpoint.

API overview

  • async_get_account() -> Account: Fetch account details with remaining time and active reservation count.
  • async_get_zone() -> Zone | None: Fetch the paid block for the current day.
  • async_list_reservations() -> list[Reservation]: List active reservations.
  • async_create_reservation(...) -> Reservation: Create a reservation.
  • async_end_reservation(...) -> None: End a reservation.
  • async_delete_reservation(reservation_id) -> None: Alias for ending a reservation.
  • async_list_favorites() -> list[Favorite]: List favorites.
  • async_create_favorite(...) -> Favorite: Create a favorite.
  • async_update_favorite(...) -> Favorite: Update a favorite by remove + upsert.
  • async_delete_favorite(...) -> None: Delete a favorite.

Creating and ending a reservation:

from datetime import UTC, datetime, timedelta

from aiohttp import ClientSession

from pyCityParkingPermit import Auth, CityParkingPermitAPI

async with ClientSession() as session:
    api = CityParkingPermitAPI(
        Auth(session, "user", "pass", base_url="https://cityparkingpermit.example")
    )
    starts_at = datetime.now(tz=UTC)
    ends_at = starts_at + timedelta(hours=2)

    reservation = await api.async_create_reservation(
        license_plate_value="12-AB-34",
        license_plate_name="My Car",
        date_from=starts_at,
        date_until=ends_at,
    )
    await api.async_end_reservation(reservation_id=reservation.id)

Managing favorites:

await api.async_update_favorite(name="My Car", license_plate="12-AB-34")
await api.async_delete_favorite(name="My Car", license_plate="12-AB-34")

Reading the package version:

from pyCityParkingPermit import __version__
print("pyCityParkingPermit", __version__)

API notes

  • Datetimes are sent as ISO 8601 strings with seconds precision.
  • Incoming timestamps are normalized to ISO 8601 UTC strings; Zone and Reservation timestamp fields are always strings, not datetime objects.
  • Session ownership: you always pass your own aiohttp.ClientSession; the library never creates or closes sessions.

Error handling

from aiohttp import ClientSession

from pyCityParkingPermit import Auth, CityParkingPermitAPI, RateLimitError

async with ClientSession() as session:
    api = CityParkingPermitAPI(
        Auth(session, "user", "pass", base_url="https://cityparkingpermit.example")
    )
    try:
        await api.async_list_reservations()
    except RateLimitError as err:
        print("Retry after:", err.retry_after)
  • AuthError for authentication failures or expired sessions.
  • ParkingConnectionError for network errors and timeouts.
  • RateLimitError for HTTP 429 responses (retry_after hints).
  • ParseError for unexpected response payloads.
  • aiohttp.ClientResponseError is raised for other HTTP errors via raise_for_status().

Development

python -m pip install -e '.[test,dev]'
python -m pip install pre-commit
pre-commit install
pre-commit run --all-files
pytest tests/
ruff check .
ruff format .
mypy

Support and security

MIT License. See LICENSE and NOTICE.

Metadata

Release files for pyCityParkingPermit 0.3.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 pyCityParkingPermit 0.3.0
File Size Uploaded Provenance Actions
pycityparkingpermit-0.3.0.tar.gz 12.4 kB With provenance Details for pycityparkingpermit-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyCityParkingPermit 0.3.0
File Interpreter ABI Platform Actions
pycityparkingpermit-0.3.0-py3-none-any.whl Python 3 none any Details for pycityparkingpermit-0.3.0-py3-none-any.whl

Total release size: 25.9 kB

Release files / pycityparkingpermit-0.3.0.tar.gz

Download URL pycityparkingpermit-0.3.0.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5e8cc826b253cb180ff1760aebe64e28d7f318f040f11820c4c1f1138aa63293
BLAKE2b-256 checksum
How to use checksums
7157073164dc54ba1a2c72bc787977d61d40cffbaab670aee6cb7426d5d6828c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Dec 24, 2025.

Transparency log

Release files / pycityparkingpermit-0.3.0-py3-none-any.whl

Download URL pycityparkingpermit-0.3.0-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbbee75269c595a4e10c81dfae119578aab3f6775ea98a36cebba3f78c79e1a5
BLAKE2b-256 checksum
How to use checksums
c5e49b45b8239d1931fefc15b878e97c3afa07de2c5da39c1a1602cc0919bda6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Dec 24, 2025.

Transparency log

Security for pyCityParkingPermit 0.3.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pycityparkingpermit-0.3.0.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 Dec 24, 2025.

Transparency log

A 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.

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