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
  • Error handling
  • Retries and timeouts
  • Next step
SDKs

Node.js SDK

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

Python SDK

Next

Authentication

Built with

The ocpplab TypeScript SDK wraps the OCPPLAB Gateway REST API with typed request and response models. It runs in Node, Deno, Bun, and modern browsers. Source lives in ocpplab-sdk/sdks/typescript.

Install

$npm install ocpplab

Initialize

1import { OcpplabSDK } from "ocpplab";
2
3const client = new OcpplabSDK({
4 token: "<access-token>",
5 baseUrl: "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

1await client.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: locationId,
10 location_name: "Bare Hub 01",
11});

Bulk-provision from a template

1await client.locationChargers.create({
2 location_id: locationId,
3 body: [
4 {
5 template: {
6 brand_slug: "alfen",
7 model_slug: "alfen_eve_double_pg_line_de",
8 connector_type: "Type2",
9 ocpp_version: "OCPP1.6",
10 ws_url: "wss://ocpp.ocpplab.com",
11 identity_prefix: "SITE_01_",
12 template_name: "Bay",
13 },
14 charger_ids: ["001", "002"],
15 },
16 ],
17});

Spin up a CPO bundle

1const cpo = await client.ocpiCpos.create({
2 template: "small-urban-ac",
3 country_code: "FR",
4 party_id: "DEM",
5 name_prefix: "demo",
6});

Error handling

1import { OcpplabApiError } from "ocpplab";
2
3try {
4 await client.chargers.create({ ... });
5} catch (err) {
6 if (err instanceof OcpplabApiError) {
7 console.error(err.statusCode, err.body);
8 }
9 throw err;
10}

Retries and timeouts

The SDK retries on 408, 429, and 5xx with exponential backoff. Override per-request:

1await client.chargers.create(
2 { ... },
3 { maxRetries: 1, timeoutInSeconds: 10 },
4);

Next step

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