JK BMS
SK EN DE

API & documentation

Both gateways expose a simple HTTP JSON API on your local network. Reads need no login, every change (POST) needs the PIN in the X-PIN header (factory 666666). Pick a product, browse the endpoints and start from the sample code.

All responses are JSON. Example: curl http://jkbms.local/api/realtime

⚠️ More than one battery on the same RS485 bus? Never use address 0. A pack set to address 0 behaves as a "master" on its own and continuously scans the whole bus — this blocks reads of it and its neighbors, even with perfectly correct wiring, termination, and grounding. Set every pack's address via its DIP switches (or the manufacturer's app) to 1-15.
MethodPathDescription
GET /api/info Gateway status (IP, uptime, last poll)
GET /api/realtime[?addr=N] Cell voltages, pack V/I/P, SOC, temperatures, alarms
GET /api/settings[?addr=N] Current protection-parameter values
POST /api/settings[?addr=N] Body: {"fieldName": value, ...} — writes changed fields
GET /api/deviceinfo[?addr=N] Vendor ID, serial number, HW/SW version, power-on count (cached per address)
GET /api/scan Polls slave addresses 0–15, returns which ones respond
GET /api/can Decoded CAN inverter-broadcast summary (SOC, pack V/I/T, charge/discharge limits, flags, manufacturer)
GET /api/can/raw[?n=20] Most-recent raw CAN frames (id, dlc, data[], age in ms)
GET / POST /api/can/config CAN settings — bitrate, autoscan, profile (persisted to NVS)
GET / POST /api/server-config Web server settings — RS485 read timing (write→read turnaround delay, poll interval, response timeout) and optional background reads (persisted to NVS, applied immediately)
GET /api/logs Log history since last boot (poll results, CAN/WiFi/license events) — in-memory only, resets on reboot
GET /api/history[?minutes=N] One-minute averages of the monitored battery (voltage, current, SOC) for the last N minutes, up to 24 h — the data behind the dashboard graph
GET /api/debug/read?reg=0xHEX&count=N[&addr=N] Raw Modbus holding-register read
POST /api/debug/verifywrite?reg=0xHEX[&addr=N] Reads a register, writes the same value back, re-reads — proves the write path reaches that register without changing anything
POST /api/wifi/reset Re-opens the WiFi setup portal so the network can be changed
POST /api/pin Changes the change PIN, body {"newPin":"1234"} (4–8 digits). The current PIN goes in the X-PIN header. It cannot be switched off.
GET /api/firmware/check Gateway asks jkbms.sk whether a newer firmware version exists
POST /api/firmware/update Installs the latest signed release from jkbms.sk (PIN and a verified licence); the gateway restarts into the new version after 1–2 minutes

Sample code

Each sample does one GET /api/realtime and prints voltage, current and SOC. Pass the gateway address as a parameter; the default is its mDNS name.

curl + jq (shell)

Download jkbms_realtime.sh

#!/usr/bin/env bash
# JK BMS Web Gateway — read live pack data with curl + jq.
#
# One HTTP GET, no authentication; the gateway answers JSON, or
# {"error": "..."} when the BMS did not respond.
#
# Usage: ./jkbms_realtime.sh [http://jkbms.local]
#   (use the gateway's IP, e.g. http://192.168.1.50, if mDNS is not reachable)
set -euo pipefail

BASE_URL="${1:-http://jkbms.local}"

curl -sS --max-time 5 "$BASE_URL/api/realtime" | jq -r '
  if .error then error("gateway error: " + .error) else
    "Pack voltage: \(.totalVoltage) V\n" +
    "Current:      \(.current) A\n" +
    "SOC:          \(.soc) %"
  end'

Python 3 (no dependencies)

Download jkbms_realtime.py

#!/usr/bin/env python3
"""JK BMS Web Gateway — read live pack data. Standard library only, no pip installs.

Usage: python3 jkbms_realtime.py [http://jkbms.local]
  (use the gateway's IP, e.g. http://192.168.1.50, if mDNS is not reachable)
"""
import json
import sys
import urllib.request


def fetch_realtime(base_url: str) -> dict:
    """GET /api/realtime and return the decoded JSON.

    Raises on network errors and when the gateway reports {"error": ...}
    (BMS not answering, wrong address, ...).
    """
    with urllib.request.urlopen(f"{base_url}/api/realtime", timeout=5) as response:
        data = json.load(response)
    if "error" in data:
        raise RuntimeError(f"gateway error: {data['error']}")
    return data


def main() -> int:
    """Prints voltage, current, SOC and the cell spread; returns the process exit code."""
    base_url = sys.argv[1] if len(sys.argv) > 1 else "http://jkbms.local"
    try:
        realtime = fetch_realtime(base_url)
    except Exception as ex:  # network, JSON or gateway error: one line, non-zero exit
        print(f"request failed: {ex}", file=sys.stderr)
        return 1

    print(f"Pack voltage: {realtime['totalVoltage']:.2f} V")
    print(f"Current:      {realtime['current']:.2f} A  (positive = charging)")
    print(f"SOC:          {realtime['soc']} %")
    print(f"Cells:        {realtime['minCellVoltage']:.3f} .. {realtime['maxCellVoltage']:.3f} V")
    return 0


if __name__ == "__main__":
    sys.exit(main())

JavaScript (Node.js or browser)

Download jkbms_realtime.js

// JK BMS Web Gateway — read live pack data with fetch().
//
// Runs as-is on Node.js 18+:  node jkbms_realtime.js [http://jkbms.local]
// The gateway sends "Access-Control-Allow-Origin: *", so fetchRealtime()
// works unchanged inside a web page too (drop the process.* lines there).

const baseUrl = process.argv[2] ?? "http://jkbms.local";

// One GET, no authentication; rejects on network errors and on {"error": ...}
async function fetchRealtime(url) {
  const response = await fetch(`${url}/api/realtime`, { signal: AbortSignal.timeout(5000) });
  const data = await response.json();
  if (data.error) {
    throw new Error(`gateway error: ${data.error}`);
  }
  return data;
}

fetchRealtime(baseUrl)
  .then((realtime) => {
    console.log(`Pack voltage: ${realtime.totalVoltage.toFixed(2)} V`);
    console.log(`Current:      ${realtime.current.toFixed(2)} A`);
    console.log(`SOC:          ${realtime.soc} %`);
  })
  .catch((error) => {
    console.error(`request failed: ${error.message}`);
    process.exitCode = 1;
  });

C/C++ console client (libcurl + nlohmann/json)

Download jkbms_client_example.cpp

// JK BMS Web Gateway — minimal REST API console client.
//
// Fetches GET /api/realtime from the gateway and prints pack voltage,
// current, and state of charge. Demonstrates the smallest useful client:
// one HTTP GET, one JSON parse. See the full endpoint list and JSON field
// reference on the site's API documentation page (/dokumentacia).
//
// Build (Linux/macOS, needs libcurl + nlohmann/json):
//   g++ -std=c++17 jkbms_client_example.cpp -lcurl -o jkbms_client_example
// Run:
//   ./jkbms_client_example http://jkbms.local

#include <curl/curl.h>
#include <nlohmann/json.hpp>
#include <cstdio>
#include <cstdlib>
#include <string>

using nlohmann::json;

// libcurl calls this once per received chunk of the HTTP response body;
// appending to a std::string is the standard way to buffer a small response.
static size_t appendToBuffer(char *data, size_t size, size_t count, void *userData) {
    auto *buffer = static_cast<std::string *>(userData);
    buffer->append(data, size * count);
    return size * count;
}

// Performs one blocking HTTP GET and returns the response body.
// Throws std::runtime_error if the transfer itself fails (not on HTTP
// error status — the caller is expected to check the JSON's own "error" field).
static std::string httpGet(const std::string &url) {
    CURL *curl = curl_easy_init();
    if (!curl) {
        throw std::runtime_error("curl_easy_init failed");
    }

    std::string body;
    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, appendToBuffer);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &body);
    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L);

    CURLcode result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);

    if (result != CURLE_OK) {
        throw std::runtime_error(curl_easy_strerror(result));
    }
    return body;
}

int main(int argc, char *argv[]) {
    // Default to the gateway's mDNS name; override with a bare IP if mDNS
    // isn't reachable on your network (e.g. "http://192.168.1.50").
    std::string baseUrl = (argc > 1) ? argv[1] : "http://jkbms.local";

    std::string body;
    try {
        body = httpGet(baseUrl + "/api/realtime");
    } catch (const std::exception &ex) {
        std::fprintf(stderr, "request failed: %s\n", ex.what());
        return 1;
    }

    json realtime = json::parse(body, /*cb*/ nullptr, /*allow_exceptions*/ false);
    if (realtime.is_discarded()) {
        std::fprintf(stderr, "invalid JSON response: %s\n", body.c_str());
        return 1;
    }
    if (realtime.contains("error")) {
        std::fprintf(stderr, "gateway error: %s\n", realtime["error"].get<std::string>().c_str());
        return 1;
    }

    std::printf("Pack voltage: %.2f V\n", realtime.value("totalVoltage", 0.0));
    std::printf("Current:      %.2f A\n", realtime.value("current", 0.0));
    std::printf("SOC:          %d %%\n", realtime.value("soc", 0));
    return 0;
}

All responses are JSON. Example: curl http://deye.local/api/realtime

MethodPathDescription
GET /api/info Gateway status: firmware version, IP/SSID, uptime, last poll result, NTP state.
GET /api/realtime Live inverter data from the poll cache (run state, relays, power, battery, energy, faults).
GET /api/settings Current settings (reads registers 60–347).
POST /api/settings Body: {"field": value, ...} — writes one or more settings, with read-back verification.
GET /api/deviceinfo Device type, serial number, firmware versions, rated power.
GET /api/history?minutes=N 24-hour history of one-minute averages (PV, load, grid, battery, SOC) for the dashboard charts; minutes = 1–1440.
GET / POST /api/server-config Gateway web server settings: inverter poll interval, optional weather forecast and spot electricity prices for the dashboard.
GET /api/logs Log history since last boot (inverter poll results) — in-memory only, resets on reboot.
GET /api/debug/read?reg=N&count=N Raw Modbus register read — any register, count 1–100.
POST /api/debug/verifywrite?reg=N Reads a register, writes the same value back, re-reads — non-destructive write-path check.
POST /api/time/sync Writes the gateway's NTP time into the inverter clock.
POST /api/wifi/reset Re-opens the "DEYE-Setup" WiFi portal so the network can be changed.
POST /api/pin Changes the change PIN, body {"newPin":"1234"} (4–8 digits). The current PIN goes in the X-PIN header. It cannot be switched off.
GET /api/firmware/check Asks jkbms.sk whether a newer DEYE firmware version exists.
POST /api/firmware/update Installs the latest signed release from jkbms.sk (PIN and a verified licence); the gateway restarts into the new version after 1–2 minutes.

Sample code

Each sample does one GET /api/realtime and prints voltage, current and SOC. Pass the gateway address as a parameter; the default is its mDNS name.

curl + jq (shell)

Download deye_realtime.sh

#!/usr/bin/env bash
# DEYE Web Gateway — read live inverter data with curl + jq.
#
# One HTTP GET, no authentication; the gateway answers JSON, or
# {"error": "..."} when the inverter did not respond over Modbus.
#
# Usage: ./deye_realtime.sh [http://deye.local]
#   (use the gateway's IP if mDNS is not reachable)
set -euo pipefail

BASE_URL="${1:-http://deye.local}"

curl -sS --max-time 5 "$BASE_URL/api/realtime" | jq -r '
  if .error then error("gateway error: " + .error) else
    "State:    \(.runStateText)\n" +
    "Battery:  \(.batteryVoltage) V  \(.batteryCurrent) A  SOC \(.batterySoc) %\n" +
    "PV:       \(.pvPowerTotal) W\n" +
    "Load:     \(.loadPowerTotal) W\n" +
    "Grid:     \(.gridPowerTotal) W  (positive = importing)"
  end'

Python 3 (no dependencies)

Download deye_realtime.py

#!/usr/bin/env python3
"""DEYE Web Gateway — read live inverter data. Standard library only, no pip installs.

Usage: python3 deye_realtime.py [http://deye.local]
  (use the gateway's IP if mDNS is not reachable)
"""
import json
import sys
import urllib.request


def fetch_realtime(base_url: str) -> dict:
    """GET /api/realtime and return the decoded JSON.

    Raises on network errors and when the gateway reports {"error": ...}
    (inverter not answering over Modbus).
    """
    with urllib.request.urlopen(f"{base_url}/api/realtime", timeout=5) as response:
        data = json.load(response)
    if "error" in data:
        raise RuntimeError(f"gateway error: {data['error']}")
    return data


def main() -> int:
    """Prints the inverter state and the battery / PV / load / grid power; returns the exit code."""
    base_url = sys.argv[1] if len(sys.argv) > 1 else "http://deye.local"
    try:
        realtime = fetch_realtime(base_url)
    except Exception as ex:  # network, JSON or gateway error: one line, non-zero exit
        print(f"request failed: {ex}", file=sys.stderr)
        return 1

    print(f"State:    {realtime['runStateText']}")
    print(f"Battery:  {realtime['batteryVoltage']:.1f} V  {realtime['batteryCurrent']:.1f} A  SOC {realtime['batterySoc']} %")
    print(f"PV:       {realtime['pvPowerTotal']} W")
    print(f"Load:     {realtime['loadPowerTotal']} W")
    print(f"Grid:     {realtime['gridPowerTotal']} W  (positive = importing)")
    return 0


if __name__ == "__main__":
    sys.exit(main())