For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Dashboard
DocsAPI Reference
DocsAPI Reference
  • Docs
    • Welcome
    • Quickstart
    • Concepts
    • Common workflows
  • SDKs
    • Python
    • TypeScript
  • Authentication
    • Overview
  • Reference
    • API reference
    • Support
Dashboard
LogoLogo
On this page
  • Install
  • Initialize
  • Provision a single charger
  • Bulk-provision from a template
  • Spin up a CPO bundle
  • Async client
  • Error handling
  • Retries and timeouts
  • Next step
SDKs

Python SDK

Install, configure, and run the OCPPLAB Python client
||View as Markdown|
Was this page helpful?
Edit this page
Previous

Common workflows

Next

Node.js SDK

Built with

The ocpplab Python SDK wraps the OCPPLAB Gateway REST API with typed models and both sync and async clients. Source lives in ocpplab-sdk/sdks/python.

Install

$pip install ocpplab

Initialize

1from ocpplab import OcpplabSDK
2
3client = OcpplabSDK(
4 token="<access-token>",
5 base_url="https://<your-api-host>",
6)

token maps to Authorization: Bearer <token>. User tokens are all you need — see Authentication for the admin case.

Provision a single charger

1client.chargers.create(
2 identity="CP-BAY-01",
3 brand_slug="alfen",
4 model_slug="alfen_eve_double_pg_line_de",
5 connector_type="Type2",
6 ws_url="wss://ocpp.ocpplab.com",
7 ocpp_version="OCPP1.6",
8 charge_point_name="Bay 01",
9 location_id=location.id,
10 location_name="Bare Hub 01",
11)

Bulk-provision from a template

1from ocpplab import ChargerGroup, ChargerTemplate
2
3client.location_chargers.create(
4 location_id=location.id,
5 request=[
6 ChargerGroup(
7 template=ChargerTemplate(
8 brand_slug="alfen",
9 model_slug="alfen_eve_double_pg_line_de",
10 connector_type="Type2",
11 ocpp_version="OCPP1.6",
12 ws_url="wss://ocpp.ocpplab.com",
13 identity_prefix="SITE_01_",
14 template_name="Bay",
15 ),
16 charger_ids=["001", "002"],
17 )
18 ],
19)

Spin up a CPO bundle

1cpo = client.ocpi_cpos.create(
2 template="small-urban-ac",
3 country_code="FR",
4 party_id="DEM",
5 name_prefix="demo",
6)

Async client

1import asyncio
2from ocpplab import AsyncOcpplabSDK
3
4client = AsyncOcpplabSDK(
5 token="<access-token>",
6 base_url="https://<your-api-host>",
7)
8
9async def main() -> None:
10 await client.ocpi_cpos.create(
11 template="small-urban-ac",
12 country_code="FR",
13 party_id="DEM",
14 name_prefix="demo",
15 )
16
17asyncio.run(main())

Error handling

1from ocpplab.core.api_error import ApiError
2
3try:
4 client.chargers.create(...)
5except ApiError as e:
6 print(e.status_code, e.body)

Retries and timeouts

The SDK retries on 408, 429, and 5xx with exponential backoff (default: 2 attempts). Default timeout is 60 seconds.

1client = OcpplabSDK(..., timeout=20.0)
2
3client.chargers.create(
4 ...,
5 request_options={"max_retries": 1, "timeout_in_seconds": 10},
6)

Next step

Continue to Quickstart for the end-to-end onboarding flow, or Common workflows for bulk provisioning and OCPI bundles.