Skip to content

Integration

TypeScript SDK

Typed client for the Ladehase API, live updates via server-sent events and webhook verification.

The SDK @ladehase/sdk is a lean, fully typed client. It is generated from the OpenAPI description and therefore always matches the API.

Installation

npm install @ladehase/sdk

Create a client

import { ladehase } from "@ladehase/sdk";

const lh = ladehase({ apiKey: process.env.LADEHASE_KEY! });

const { data, error } = await lh.GET("/v1/devices");
if (error) throw new Error(error.title);
for (const device of data.data) console.log(device.id, device.name);

Paths, parameters and responses are typed. Your editor suggests endpoints and fields.

Start and stop charging

const { data: session } = await lh.POST("/v1/sessions", {
  body: { device_id: "dev_…" },
  headers: { "idempotency-key": crypto.randomUUID() },
});

await lh.POST("/v1/sessions/{id}/stop", { params: { path: { id: session!.id } } });

Preview a tariff

const { data: preview } = await lh.POST("/v1/tariffs/preview", {
  body: { rules: { energyPrice: 4500, serviceFee: 50 }, energy_wh: [20000] },
});

Verify webhooks

import { verifyWebhook } from "@ladehase/sdk";

const ok = await verifyWebhook(rawBody, signatureHeader, process.env.LADEHASE_WEBHOOK_SECRET!);

The function uses Web Crypto and runs in Node.js, Deno, Bun and edge runtimes. Details under Webhooks.

Other languages

For other languages, generate a client from the OpenAPI description at www.ladehase.com/openapi.json, for example with openapi-generator, or use the REST API directly with any HTTP client.

Found a mistake? Write to developer@ladehase.com.