pyCityVisitorParking
Async Python library for Dutch municipal visitor parking providers
Provider-agnostic async Python library for Dutch municipal visitor parking systems.
Designed for Home Assistant, but usable in any async Python application.
About this library
pyCityVisitorParking is an async Python library for Dutch municipal visitor parking providers.
It exposes a small provider-agnostic API for:
- provider discovery
- permit lookup
- reservation management
- favorites management
The library is designed primarily for Home Assistant use, but it can also be used directly in any async Python application.
Status
Currently bundled providers:
- DVS Portal
- The Hague
- 2park
- Rotterdam
Provider manifests are discovered from src/pycityvisitorparking/provider/ without importing all providers up front.
Provider-specific documentation:
Supported municipalities
For the exact base_url, api_uri, and provider-specific notes, see the provider README files.
- DVS Portal: Apeldoorn, Bloemendaal, Delft, Den Bosch, Doetinchem (via Buha), Groningen, Haarlem, Harlingen, Heemstede, Heerenveen, Heerlen, Hengelo, Katwijk, Leiden, Leidschendam-Voorburg, Middelburg, Nissewaard, Oldenzaal, Rijswijk, Roermond, Schouwen-Duiveland, Sittard-Geleen, Smallingerland, Sudwest-Fryslan, Veere, Venlo, Vlissingen, Waadhoeke, Waalwijk, Weert, Zaanstad, Zevenaar, Zutphen, Zwolle
- The Hague: The Hague
- 2park: Amstelveen, Assen, Bergen op Zoom, Breda, Deventer, Dordrecht, Eindhoven, Emmen, Etten-Leur, Gorinchem, Hardenberg, Harderwijk, Maastricht, Oosterhout, Oss, Roosendaal, Sluis, Terneuzen, Tiel, Veenendaal, Vlaardingen
- Rotterdam: Rotterdam
Installation
Requires Python 3.14 or newer.
pip install pycityvisitorparking
Quickstart
import asyncio
from pycityvisitorparking import Client
async def main() -> None:
async with Client(base_url="https://example", api_uri="/api") as client:
provider = await client.get_provider("dvsportal")
await provider.login(credentials={"username": "user", "password": "secret"})
permit = await provider.get_permit()
reservations = await provider.list_reservations()
print(permit)
print(reservations)
asyncio.run(main())
Public API
Client
Client is the main entry point.
list_providers()returns availableProviderInfoobjectsget_provider(provider_id, ...)loads a specific provider on demandClientaccepts an optional injectedaiohttp.ClientSession- if you do not inject a session, the client creates and owns its own session
Configuration options:
base_url: provider base URLapi_uri: optional provider API pathtimeout: optionalaiohttp.ClientTimeoutretry_count: retry count for idempotent GET requests
Data models
Public data models:
ProviderInfoPermitPaidHoursBlockReservationTargetReservationFavorite
Model highlights:
ProviderInfoincludesid,favorite_update_fields,reservation_update_fields,balance_units, andreservation_target_selectionPermitincludesid,remaining_balance,balance_unit, andpaid_hoursPaidHoursBlockcontains UTC ISO 8601start_timeandend_timeReservationTargetincludes an opaqueid, a displayname, an optionaldescription, and its ownpaid_hoursReservationincludesid,name,license_plate,start_time,end_time, andreservation_target_id(Nonewhen the provider has no targets)Favoriteincludesid,name, andlicense_plate
Standardized behavior
- timestamps are returned as UTC ISO 8601 strings
- license plates are normalized and validated
- the public API stays provider-agnostic
- some update operations may be unsupported by a provider; inspect
favorite_update_fieldsandreservation_update_fields
Login and provider state
login() takes username and password, plus the optional keys documented in the provider README (for example a permit_id to select a permit).
Anything a provider resolves during login (product, location, permit media type, session tokens) stays internal to the provider. It is not part of the public contract and callers do not need to persist or replay it: reauthentication after an expired session reuses that state automatically.
Reservation targets
Some providers need a choice before a reservation can start, for example a zone or a
parking machine. ProviderInfo.reservation_target_selection says how:
None: there is nothing to choose;start_reservation()rejects areservation_target_idwithValidationError."list": pick one of the targets fromawait provider.list_reservation_targets()."free_input": the list holds suggestions such as the default target, and the provider also accepts other ids it can resolve itself, such as a number the user reads from a machine. An unknown id raisesValidationError.
list_reservation_targets() returns the default target first and an empty list when the
active permit has nothing to choose. Pass the chosen id as
start_reservation(..., reservation_target_id=...); None uses the default target.
Permit.paid_hours holds the windows of the default target, and
ReservationTarget.paid_hours those of each listed target. The booked target is
returned as Reservation.reservation_target_id; updating a reservation never changes it.
fetch_all() returns (permit, reservations, favorites, targets), so a refresh gets the targets without a second round of requests.
Target ids are opaque strings; provider-native values stay inside the provider.
Common usage
List providers
import asyncio
from pycityvisitorparking import Client
async def main() -> None:
async with Client() as client:
for provider in await client.list_providers():
print(provider.id, provider.reservation_update_fields)
asyncio.run(main())
Manage a reservation
import asyncio
from datetime import datetime, timedelta, timezone
from pycityvisitorparking import Client
async def main() -> None:
async with Client(base_url="https://example", api_uri="/api") as client:
provider = await client.get_provider("dvsportal")
await provider.login(credentials={"username": "user", "password": "secret"})
start_time = datetime(2024, 5, 1, 9, 0, tzinfo=timezone.utc)
end_time = start_time + timedelta(hours=2)
reservation = await provider.start_reservation(
"12AB34",
start_time=start_time,
end_time=end_time,
name="Visitor",
)
print(reservation.id)
asyncio.run(main())
Manage favorites
import asyncio
from pycityvisitorparking import Client, ErrorCode
from pycityvisitorparking.exceptions import ProviderError
async def main() -> None:
async with Client(base_url="https://example", api_uri="/api") as client:
provider = await client.get_provider("dvsportal")
await provider.login(credentials={"username": "user", "password": "secret"})
favorite = await provider.add_favorite("12AB34", name="Visitor")
try:
updated = await provider.update_favorite(favorite.id, name="Visitor 2")
print(updated)
except ProviderError as exc:
if exc.error_code != ErrorCode.NOT_SUPPORTED:
raise
print("Favorite updates are not supported by this provider")
asyncio.run(main())
Error handling
Public methods raise library exceptions instead of raw aiohttp exceptions:
AuthErrorNetworkErrorValidationErrorProviderErrorRateLimitErrorServiceUnavailableErrorNotFoundErrorTimeoutErrorConfigError
Exceptions are technical and integration-facing. Branch on the exception type and/or error_code, never on the message text. User-facing and translated messages are the responsibility of the integration (for Home Assistant: translation keys), not of this library.
Each exception carries:
error_code: a stableErrorCodevalue (aStrEnum, so it also compares equal to its string)detail: a technical, PII-free description for logs and diagnostics
Supported error codes:
error_code |
Exception | Meaning |
|---|---|---|
auth_error |
AuthError |
Invalid credentials, or the session could not be renewed; reauthenticate |
network_error |
NetworkError |
Transport failure talking to the provider; retry later |
timeout |
TimeoutError |
The request timed out; retry later |
validation_error |
ValidationError |
Invalid caller input |
config_error |
ConfigError |
Invalid or missing configuration |
provider_error |
ProviderError |
Unexpected provider failure or response |
rate_limit |
RateLimitError |
The provider rate limit was hit (HTTP 429); retry later |
service_unavailable |
ServiceUnavailableError |
The provider is temporarily unavailable (HTTP 502/503/504, maintenance) |
not_found |
NotFoundError |
The requested provider resource does not exist |
not_supported |
ProviderError |
The operation is not supported by this provider or permit |
provider_rejected |
ProviderError |
The provider refused the action (for example insufficient balance) |
TimeoutError is a subclass of NetworkError; RateLimitError, ServiceUnavailableError and NotFoundError are subclasses of ProviderError; ConfigError is a subclass of ValidationError.
ProviderError with error_code="provider_rejected" means the provider processed the request and refused it, for example because the balance is used up or the time is outside the planning horizon. The session works, so a re-login does not help; detail carries the provider's reason when it gives one (without license plates).
Example:
from pycityvisitorparking import Client, ErrorCode
from pycityvisitorparking.exceptions import (
AuthError,
NetworkError,
ProviderError,
ServiceUnavailableError,
ValidationError,
)
async with Client(base_url=base_url, api_uri=api_uri) as client:
try:
provider = await client.get_provider("dvsportal")
await provider.login(credentials={"username": "user", "password": "secret"})
permit = await provider.get_permit()
except AuthError:
start_reauth_flow()
except ValidationError as exc:
handle_input_error(exc.error_code)
except NetworkError, ServiceUnavailableError:
retry_later()
except ProviderError as exc:
handle_provider_issue(exc.error_code)
Logging
The library logs to the pycityvisitorparking logger using the standard Python logging module.
- credentials are not logged
- full license plates are not logged
- request context can be attached for clearer diagnostics
- expected, recoverable paths log at debug level: reauthentication after an expired session, transient network failures and timeouts, rate limits (HTTP 429), and temporary gateway errors (HTTP 502/503/504)
- warnings are reserved for unexpected responses that need attention
Development
This repository uses uv for local development tasks.
Common checks:
uv run --group lint ruff check .
uv run --group lint ruff format --check .
uv run --group typecheck pyright
uv run --group test pytest
uv run --group schema python -m pytest -o addopts=-q tests/test_manifest_schema.py
uv build
uvx twine check dist/*
Release notes and publishing are handled through GitHub Actions. See docs/RELEASING.md.
Provider development
Providers live under:
src/pycityvisitorparking/provider/<provider_id>/
A provider folder typically contains:
src/pycityvisitorparking/provider/<provider_id>/
manifest.json
__init__.py
api.py
const.py
README.md
CHANGELOG.md
Related documentation:
License
MIT. See LICENSE.
Metadata
Release files for pycityvisitorparking 0.6.0
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 |
|---|---|---|---|---|
| pycityvisitorparking-0.6.0.tar.gz | 122.5 kB | With provenance | Details for pycityvisitorparking-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pycityvisitorparking-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for pycityvisitorparking-0.6.0-py3-none-any.whl |
Total release size: 241.5 kB
Release files / pycityvisitorparking-0.6.0.tar.gz
| Download URL | pycityvisitorparking-0.6.0.tar.gz |
|---|---|
| Size | 122.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7fc9f483c71f8d3a8501bbd78eb615dc8040223ef0ec27e00f420d27a2c93979
|
|
BLAKE2b-256 checksum How to use checksums |
5e71f018cf257be40230b10ea228830da015b2424fda735353ab065f97aa15f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 20, 2026.
Transparency logRelease files / pycityvisitorparking-0.6.0-py3-none-any.whl
| Download URL | pycityvisitorparking-0.6.0-py3-none-any.whl |
|---|---|
| Size | 118.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dba7abb478d3c553e502a37cfa036b349806d8e90e0b41b66f04beaf12ca5279
|
|
BLAKE2b-256 checksum How to use checksums |
35f67b44f9c97793d711386d1453d9e54a9d13f68805fd5054c004851e694d99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 20, 2026.
Transparency logSecurity for pycityvisitorparking 0.6.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.
Attestation for pycityvisitorparking-0.6.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 Nov 20, 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.