Street Manager Python Client
A Python client library for the Street Manager API, providing access to work, reporting, lookup, geojson, party, export, event, and sampling endpoints.
Installation
uv add streetmanager
Usage
# Import the client modules
from streetmanager.work import swagger_client as work_client
from streetmanager.reporting import swagger_client as reporting_client
from streetmanager.lookup import swagger_client as lookup_client
from streetmanager.geojson import swagger_client as geojson_client
from streetmanager.party import swagger_client as party_client
from streetmanager.export import swagger_client as export_client
from streetmanager.event import swagger_client as event_client
from streetmanager.sampling import swagger_client as sampling_client
# Create API client instances
work_api = work_client.DefaultApi()
reporting_api = reporting_client.DefaultApi()
lookup_api = lookup_client.DefaultApi()
geojson_api = geojson_client.DefaultApi()
party_api = party_client.DefaultApi()
export_api = export_client.DefaultApi()
event_api = event_client.DefaultApi()
sampling_api = sampling_client.DefaultApi()
# Use the APIs
# Example: Get work details
work_response = work_api.get_work(work_id="123")
# Example: Get reporting data
reporting_data = reporting_api.get_activity_reporting()
# Example: Lookup street details
street_response = lookup_api.get_street(usrn="123456")
# Example: Get GeoJSON data
geojson_response = geojson_api.get_work_geojson(work_id="123")
# Example: Get party details
party_response = party_api.get_organisation(organisation_id="123")
# Example: Create CSV export
export_request = export_client.PermitCSVExportRequest()
export_response = export_api.create_permit_csv_export(permit_csv_export_request=export_request)
# Example: Get works updates
works_updates = event_api.get_works_updates()
# Example: Get sampling data
sampling_data = sampling_api.get_sample_inspection_targets()
Authentication
To authenticate with the Street Manager API, you'll need to provide your credentials and use the authentication flow:
import os
from streetmanager.work import swagger_client as streetmanager_client
from streetmanager.work.swagger_client.rest import ApiException
class StreetManagerAPI:
def __init__(self, base_url: str, username: str, password: str):
self.base_url = base_url
self.username = username
self.password = password
self.auth_response = self._perform_authentication()
def _perform_authentication(self):
# Initial configuration for authentication
configuration = streetmanager_client.Configuration()
configuration.host = self.base_url
# Create API client for authentication
api_client = streetmanager_client.ApiClient(configuration)
auth_api_instance = streetmanager_client.DefaultApi(api_client)
# Create authentication request
auth_request = streetmanager_client.AuthenticationRequest(
email_address=self.username, password=self.password
)
try:
response = auth_api_instance.authenticate(auth_request)
return response
except ApiException as e:
if e.body:
print("Response body:", e.body)
raise
def get_api_instance(self) -> streetmanager_client.DefaultApi:
if not self.auth_response:
raise Exception("Authentication response not available. Ensure authentication was successful.")
# Create a new configuration for the specific API calls
configuration = streetmanager_client.Configuration()
configuration.host = self.base_url
# Configure for id_token
configuration.api_key["token"] = self.auth_response.id_token
configuration.api_key_prefix["token"] = ""
# Create API client with the token-specific configuration
api_client = streetmanager_client.ApiClient(configuration)
return streetmanager_client.DefaultApi(api_client)
# Configuration
BASE_URL = "https://api.sandbox.manage-roadworks.service.gov.uk/v6/work"
USERNAME = "your-email@example.com"
PASSWORD = os.getenv("STREETMANAGER_PASSWORD") # Store your password securely in environment variables
# Initialize the API Handler
sm_api_handler = StreetManagerAPI(BASE_URL, USERNAME, PASSWORD)
# Get an authenticated API instance
api_instance = sm_api_handler.get_api_instance()
# Now you can use the API instance for authenticated requests
work_response = api_instance.get_work(work_id="123")
Features
- Work API client for managing street works
- Reporting API client for reporting functionality
- Lookup API client for street information
- GeoJSON API client for accessing geographical data
- Party API client for managing party information
- Export API client for data export functionality
- Event API client for getting works updates
- Sampling API client for sampling functionality
Requirements
- Python 3.12 or higher
- Dependencies are automatically installed with the package
API Documentation
The following Swagger documentation URLs are available for each API:
Releasing
- Every merge to
mainis released once.github/workflows/test.ymlpasses on it:.github/workflows/auto-version.ymlwaits for the tests, bumps the patch version unless the PR title ends with[minor]or[major], then tagsvX.Y.Zand creates the GitHub Release as thecogna-package-releaserGitHub App. - The release triggers
.github/workflows/publish.yml, which builds wheels/sdist withuv buildand publishes to PyPI via Trusted Publishing (no token required). - A merge that changes only
.github/, such as a Dependabot action update, releases nothing; the next release includes it. - Nobody can push the bump commit or a
v*tag by hand: the repository rules reserve both for the release app.
Minor and major releases
End the PR title with [minor] or [major], for example Add sampling API client [minor]. The squash-merge commit takes the PR title, and the workflow bumps that part instead of the patch.
Notes
- The repository settings (rules and the
releaseandpypienvironments) are managed in Terraform incogna-co/terraform. Thereleaseenvironment holds the app's client ID (variableRELEASE_APP_CLIENT_ID) and private key (secretRELEASE_APP_PRIVATE_KEY).
Links
- PyPI project page: https://pypi.org/project/streetmanager/
Changelog
- See CHANGELOG.md for notable changes and release notes.
- GitHub Releases: https://github.com/cogna-public/streetmanager/releases
Metadata
Release files for streetmanager 0.3.4
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 |
|---|---|---|---|---|
| streetmanager-0.3.4.tar.gz | 666.6 kB | With provenance | Details for streetmanager-0.3.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| streetmanager-0.3.4-py3-none-any.whl | Python 3 | none | any | Details for streetmanager-0.3.4-py3-none-any.whl |
Total release size: 3.0 MB
Release files / streetmanager-0.3.4.tar.gz
| Download URL | streetmanager-0.3.4.tar.gz |
|---|---|
| Size | 666.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb7ec26595ea5993dc1c96351d8446da5fc173fb6b230a5445e31a9f65bae4c1
|
|
BLAKE2b-256 checksum How to use checksums |
1f618dbea29c09c22af37534c08a4643a1ddc9e05aaf95fb33e07e451425ea43
|
| 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 27, 2026.
Transparency logRelease files / streetmanager-0.3.4-py3-none-any.whl
| Download URL | streetmanager-0.3.4-py3-none-any.whl |
|---|---|
| Size | 2.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d81f74fba65bd2487193adcc5b6601703f93b65a10cc0e51cdc9c28736797de6
|
|
BLAKE2b-256 checksum How to use checksums |
4ee817cae610843aed15f7b9847eb22ffe135fb5d14bd60cad9fe96bd4a3a3ea
|
| 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 27, 2026.
Transparency logSecurity for streetmanager 0.3.4
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 streetmanager-0.3.4.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 Oct 27, 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.