Device API Documentation

Get Device Data

Endpoint

GET /devices/{deviceId}/telemetry

Query Parameters

timeRangeor
start-end

Use either timeRange preset or specific start/end dates:

timeRange options:

  • last5mins
  • last1hour
  • last7days
  • latest

Or date range:

  • start: ISO8601 format
  • end: ISO8601 format

Response Structure

Response Fields:

  • pack_voltage: Battery pack voltage
  • cell_voltage: Array of individual cell voltages
  • temperature: Battery temperature
  • soc: State of charge
  • bms_state: Current BMS state

REQUEST EXAMPLE

curl --location 'https://apidev.xbattery.energy/v1/devices/{deviceId}/telemetry?timeRange=latest' \
      -H 'ApiKey: f76d******************d2a'

RESPONSE EXAMPLE

{
  "success": true,
  "data": [
    {
      "deviceId": "STM32H753ZI",
      "Device_id": "BMS_DEVICE_1",
      "pack_voltage": 41.2708,
      "cell_voltage": [
        2.6968,
        2.7811,
        2.8042,
        2.7843,
        2.8008,
        2.7985,
        2.7929,
        2.8156,
        2.7982,
        2.6405,
        2.743,
        2.6616,
        2.7149,
        2.7432,
        2.7851
      ],
      "temperature": 27.315,
      "pack_current": 0,
      "soc": 21.02,
      "ocv_soc": 21.82,
      "soh": 0,
      "bms_state": "DISCHARGING",
      "main_contactor_state": true,
      "charger_contactor_state": false,
      "id": "3806730799eb-42559efd-3afdd8b56d87",
      "_ts": 1736784740
    }
  ],
  "meta": {
    "organizationId": 1,
    "deviceId": "STM32H753ZI",
    "timeRange": "latest",
    "timestamp": "20250220T102405.103Z"
  }
}

Get All Devices

Endpoint

GET /devices

Response Structure

Response Fields:

  • DeviceId: Unique identifier for the device
  • OrganizationId: Organization identifier
  • Name: Device name
  • Model: Device model
  • Location: Device location
  • LastConnected: Last connection timestamp
  • Status: Device status

REQUEST EXAMPLE

curl --location 'https://apidev.xbattery.energy/v1/devices' \
      -H 'ApiKey: f76d******************d2a'

RESPONSE EXAMPLE

{
  "success": true,
  "data": [
    {
      "DeviceId": "DVC12345",
      "OrganizationId": 1,
      "Name": "Battery Storage Unit",
      "Model": "BESSModel-X",
      "Location": "Delhi",
      "LastConnected": "20250220T090354.130Z",
      "Status": "enabled",
      "CreatedAt": "20250220T090354.490Z",
      "UpdatedAt": "20250220T090354.133Z"
    }
  ]
}

Add Device

Endpoint

POST /devices

Request Body Parameters

  • deviceId

    Unique identifier for the device

  • name

    Name of the device

  • model

    Model of the device

  • location

    Physical location of the device

Response Structure

Response Fields:

  • success: Operation status

REQUEST EXAMPLE

curl --location 'https://apidev.xbattery.energy/v1/devices' \
      -H 'ApiKey: f76d******************d2a' \
      -H 'Content-Type: application/json' \
      --data '{
        "deviceId": "DVC12345",
        "name": "Battery Storage Unit",
        "model": "BESSModel-X",
        "location": "Delhi"
      }'

RESPONSE EXAMPLE

{
  "success": true
}