Skip to content
ESP32 HTTP & Websocket API

ESP32 HTTP & Websocket API

Base URL: http://<device-ip>/ (HTTP port is the ESP-IDF default unless changed in firmware).
All JSON bodies use Content-Type: application/json where applicable.


REST

Pages (HTML)

MethodPathDescription
GET/Index
GET/devicesDevice list UI
GET/device/*Device editor UI (/device/<folder>)
GET/sim/*Simulation UI
GET/central/*Central UI
GET/scanScanner UI
GET/fsFile manager UI

JSON / config

MethodPathDescription
GET/api/devicesJSON array of devices (manifest metadata + folder)
GET/api/device/<id>/<resource>Load JSON; resource is manifest key or alias (info, manifest, adv, ble, interface, …). Optional .json suffix is stripped.
PATCH/api/device/<id>/<resource>Partial update of that JSON file (editor / manifest-resolved paths).

Wi‑Fi (stored config; reboot may be required to apply)

MethodPathBody (JSON, partial OK)Response
GET/api/wifissid, has_psk, mode (sta_first | ap_only), ap_ssid, ap_ssid_effective, has_ap_psk
POST/api/wifissid, psk, mode, ap_ssid, ap_psk (all optional)ok, optional error / note

Log filter (controls WebSocket log stream)

MethodPathBodyResponse
GET/api/log/filterenabled, info_enabled, allowed_info_tags[]
POST/api/log/filterenabled, info_enabled, allowed_info_tags (all optional){"status":"ok"}

Relay (outbound WebSocket client to another node)

MethodPathBodyResponse
POST/api/relay/connect{"target":"<ip-or-host>"}status: connected | failed
GET/api/relay/disconnect{"status":"disconnected"}

LittleFS file manager

MethodPathQuery / bodyDescription
GET/fs/lspath, optional recursive=1Directory listing (JSON)
GET/fs/dfFree / used space (JSON)
GET/fs/existspathStat path (JSON)
GET/fs/downloadpathFile download
POST/fs/uploadmultipart/form-dataUpload file
POST/fs/mkdirForm body: current_dir=…&folder_name=… (URL-encoded)Create directory
GET/fs/deletepath, type=file|dirDelete file or empty dir
GET/fs/rmdirpathRecursive directory delete
GET/fs/renamefrom, toRename / move

Static assets

MethodPathDescription
GET/static/<file>Shared static file from LittleFS /html (if exists) or embedded bundle
GET/static/<device_id>/<file>Device asset: /devices/<device_id>/assets/<file>, or manifest-resolved name without extension

WebSocket

Endpoint: ws://<device-ip>/ws
Framing: text frames, one JSON object per message.
type field: required on every client message; server dispatches on type.

On connect (server → client)

  • Replays saved UI state (background + elements) for the smart display.
  • Unicast: hellotype, src (node id, e.g. ESP_AABBCC), caps.
  • Unicast: device_statusscanning, central (string or null), peripheral (string or null).

Broadcasts add src (originating node) when sent over the network.


Client → server (by type)

typePayloadAction
hellooptional srcLogged; no state change
statusBroadcast device_status to all clients
scanneraction: start (connectable bool), stop, status, connectBLE scan control; connect uses addr, optional read_values, pairing_mode, strategy, pin, save_result, open_central
centralaction: start (device), stop, status, menu_select (id)Central mode + UI delegation
simaction: start (device), stop, statusPeripheral simulation
sim_buttonidRuns Lua hook for simulated button
devicesaction: listBroadcasts devices_list
systemaction: reboot / restart, memory, versionReboot, or push memory_status / version
ble_sim_traceenabled (bool)Enable or disable GATT trace events
relaySee Relay belowGATT relay or response delivery
fscmd: ls, df, exists, mkdir, delete, rmdir, rename, patchFile manager over WS (see server file manager source for fields)

Unhandled type values are logged and ignored.


Relay (type: relay)

Sim / peripheral side (typical): forward GATT operations toward a peer that runs central and has called POST /api/relay/connect to this device.

FieldMeaning
actionread, write, write_noresp, read_desc, subscribe, unsubscribe, or responses: read_rsp, write_rsp, subscribe_rsp, read_desc_rsp, notify_rx, indicate_rx
svc, chrUUID strings
dataHex string for writes / read response payload
seqCorrelates request/response
indicateBool for subscribe action (notify vs indicate)
descDescriptor UUID for read_desc
srcOptional requester id

Central side (incoming over outbound relay client): the firmware also accepts the same relay request shapes on the client connection to the peer (see web_server_relay.c).


Server → client (by type)

typeWhenNotes
helloNew clientUnicast
device_statusConnect / client statusScan + active central + peripheral ids
scan_statusScan start/stop/statusMay be stateful or transient (result, count, …)
scan_deviceAdvertisementsupdate, addr, name, adv_data hex, RSSI, flags, …
connection_progressDiscovery / connectionphase, status, addr, detail
scan_discovery_resultAfter connect + discoveraddr, rc, viable, services
central_statusCentral start/stopstatus, device
sim_statusSimulation start/stopstatus, device, optional adv
devices_listList refreshdevices array
gfxLua / graphicscmd: png, svg, background, color, text, notification, clear, remove + layout fields
logWhen wslog enabledlevel, tag, msg
memory_statussystem actionHeap stats
versionsystem actionFirmware / IDF / build time
ble_sim_traceOptionalGATT traffic debug
fs_responseFS over WScmd, ok or error
relayRelay pathResponses and notifications

Graphics smart display state

On connect, the server replays canvas state only: the last background command and each message that carried an element id (as used by gfx draws). Typical scan, relay, status, and log traffic is not replayed.

© BLESPlo.it · BLE Research Tool · GitHub