Skip to navigation

TypeScript SDK

Typed client for Node.js and the browser.

Install

npm i evcloud-sdk

Create a client

Pass the production API, https://api.ev-cloud.ai, as environment.

import { EvcloudSDK } from "evcloud-sdk";
const client = new EvcloudSDK({
environment: "https://api.ev-cloud.ai",
token: process.env.EVCLOUD_TOKEN!,
});

See Authentication for the token.

Make a call

Each domain is a namespace: client.cpo, client.emsp, client.energy, client.webhooks and client.ocpi. Request and response fields keep the API’s snake_case names; methods are camelCase.

quickstart.ts
import { EvcloudSDK } from "evcloud-sdk";
const client = new EvcloudSDK({
environment: process.env.EVCLOUD_BASE_URL!, // e.g. https://api.ev-cloud.ai
token: process.env.EVCLOUD_TOKEN!,
});
async function main(): Promise<void> {
// List methods return a page you can iterate across every page.
const locations = await client.cpo.locations.list({ limit: 50 });
for await (const location of locations) {
console.log(location.location_id, location.name);
}
// Cap a charger at 11 kW, then read the charger's answer.
const request = await client.energy.controlRequests.create({
charge_point_id: "CP-AMS-001",
action: "SET_EVSE_INPUT_LIMIT",
connector_id: 0,
limit: 11000,
unit: "W",
});
const outcome = await client.energy.controlRequests.get({ request_id: request.request_id });
console.log(outcome.result);
}
main();

Errors, retries and which calls are never resent: Errors and retries.