> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ocpplab.com/llms.txt.
> For full documentation content, see https://docs.ocpplab.com/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ocpplab.com/_mcp/server.

# Node.js SDK

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`](https://github.com/ocpplab/ocpplab-sdk/tree/main/sdks/typescript).

## Install

```bash
npm install ocpplab
```

## Initialize

```javascript
import { OcpplabSDK } from "ocpplab";

const client = new OcpplabSDK({
  token: "<access-token>",
  baseUrl: "https://<your-api-host>",
});
```

`token` maps to `Authorization: Bearer <token>`. User tokens are all you need — see [Authentication](/authentication) for the admin case.

## Provision a single charger

```javascript
await client.chargers.create({
  identity: "CP-BAY-01",
  brand_slug: "alfen",
  model_slug: "alfen_eve_double_pg_line_de",
  connector_type: "Type2",
  ws_url: "wss://ocpp.ocpplab.com",
  ocpp_version: "OCPP1.6",
  charge_point_name: "Bay 01",
  location_id: locationId,
  location_name: "Bare Hub 01",
});
```

## Bulk-provision from a template

```javascript
await client.locationChargers.create({
  location_id: locationId,
  body: [
    {
      template: {
        brand_slug: "alfen",
        model_slug: "alfen_eve_double_pg_line_de",
        connector_type: "Type2",
        ocpp_version: "OCPP1.6",
        ws_url: "wss://ocpp.ocpplab.com",
        identity_prefix: "SITE_01_",
        template_name: "Bay",
      },
      charger_ids: ["001", "002"],
    },
  ],
});
```

## Spin up a CPO bundle

```javascript
const cpo = await client.ocpiCpos.create({
  template: "small-urban-ac",
  country_code: "FR",
  party_id: "DEM",
  name_prefix: "demo",
});
```

## Error handling

```javascript
import { OcpplabApiError } from "ocpplab";

try {
  await client.chargers.create({ ... });
} catch (err) {
  if (err instanceof OcpplabApiError) {
    console.error(err.statusCode, err.body);
  }
  throw err;
}
```

## Retries and timeouts

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

```javascript
await client.chargers.create(
  { ... },
  { maxRetries: 1, timeoutInSeconds: 10 },
);
```

## Next step

Continue to [Quickstart](/quickstart) for the end-to-end onboarding flow, or [Common workflows](/common-workflows) for bulk provisioning and OCPI bundles.