NXG Developer Portal
Connecting…

For Embedded Developers

You write the firmware. Here's how your ESP32 talks to the server.

Connection Flow

1
Connect to wss://ws.nxgapi.com/ws/gateway
2
First connect: { "t": "pair", "code": "..." } — receive pair_ok with token, store in NVS
3
Reconnect: { "t": "auth", "token": "..." } — receive auth_ok or auth_reset_required
4
Send data: { "t": "telemetry", "temp": 22.5, ... } or { "t": "status", "door1": "closed", ... }
5
Reply { "t": "pong" } to every { "t": "ping" }. Server pings every 30s, timeout 90s.
6
On cmd: execute, then send { "t": "ack", "id": "...", "ok": true }

What You Send

What You Receive

Live: What Your Devices Are Sending

Waiting for device data…

Device Setup

Register a device to get a connectionCode. Flash the config.h into your firmware. On first pair, the server issues a persistent token. The connectionCode survives resets.

Code: ESP-IDF / C

For Web Developers

You build the web app. Here's how to receive data and send commands.

Connection Flow

1
Listen for { "t": "device_online", "serial": "..." } / device_offline
2
Receive data: { "t": "telemetry", "serial": "...", "ts": ..., "temp": 22.5 }
3
Send commands: { "t": "cmd", "serial": "...", "target": "turn1", "action": "open" }

What You Receive

What You Send

REST API

All REST endpoints require Authorization: Bearer <password>. Errors return { "error": "message" }. Status codes: 200, 201, 401, 404.

GET /api/devices List all registered devices
GET /api/devices/:serial Get single device details
GET /api/devices/:serial/code Get connection code for device
GET /api/history?serial=...&type=...&limit=100 Query stored messages
GET /api/protocol Protocol docs as JSON
POST /api/devices Create device → { serial, code }
POST /api/devices/:serial/reset Reset device (invalidates token, re-pair required)
POST /api/devices/:serial/regenerate Regenerate connectionCode (invalidates token)
DELETE /api/devices/:serial Delete a device permanently

Live: What Your App Receives

This is exactly what arrives in your ws.onmessage handler. Click a message to see the full JSON.

Waiting for messages…

Try It: Gateway Simulator

Simulate an ESP32 in your browser to test your app without hardware.

Disconnected

Try It: Send a Command

Code: TypeScript / Node.js