MyBeacon device provides two types of APIs:
Device Identification:
device_id: eth0 MAC address (e.g., 38:54:39:4b:1b:ad)device_token: Authentication token (received during registration)device_password: 8-digit PIN for dashboard accessBase URL: http://<device-ip> (default port 80)
All responses include CORS headers:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
Returns current device status including network state, scanners status, and counters.
Request:
GET /api/status HTTP/1.1
Host: 192.168.5.244
Response: 200 OK
{
"device_id": "38:54:39:4b:1b:ad",
"registered": true,
"mode": "cloud",
"uptime_sec": 45652,
"network": {
"eth0_ip": "192.168.5.244/24",
"eth0_mac": "38:54:39:4b:1b:ad",
"eth0_rx": 29226155,
"eth0_tx": 53569343,
"wlan0_ip": "192.168.5.100/24",
"wlan0_mac": "38:54:39:4b:1b:ac",
"wlan0_ssid": "MyNetwork",
"wlan0_signal": -45,
"wlan0_channel": 6,
"wlan0_gateway": "192.168.5.1",
"wlan0_dns": "192.168.5.1",
"wlan0_rx": 1234567,
"wlan0_tx": 7654321,
"gateway": "192.168.5.1",
"dns": "192.168.5.1",
"ntp": "pool.ntp.org",
"ap_active": false
},
"scanners": {
"ble_running": true,
"wifi_running": false
},
"counters": {
"ble_events": 12345,
"wifi_events": 6789,
"uploads": 42,
"errors": 0
},
"server_ok": true
}
Fields:
device_id: Device MAC address (eth0)registered: Whether device is registered on servermode: Operating mode (cloud or lan)uptime_sec: System uptime in secondsnetwork.eth0_*: Ethernet interface statsnetwork.wlan0_*: WiFi interface stats (only when connected)network.ap_active: Whether AP fallback is activescanners.*_running: Scanner statuscounters: Event and upload countersserver_ok: Server connection statusReturns system metrics (CPU, memory, temperature, load).
Request:
GET /api/metrics HTTP/1.1
Host: 192.168.5.244
Response: 200 OK
{
"cpu_percent": 15.5,
"mem_used_mb": 42.3,
"mem_total_mb": 245.0,
"temperature": 45.2,
"load_avg": 0.42,
"load_1m": 0.42,
"load_5m": 0.35,
"load_15m": 0.28
}
Fields:
cpu_percent: CPU usage percentagemem_used_mb: Used memory in MBmem_total_mb: Total memory in MBtemperature: SoC temperature in °Cload_avg: 1-minute load averageload_1m/5m/15m: Load averagesReturns current device configuration (without secrets).
Request:
GET /api/config HTTP/1.1
Host: 192.168.5.244
Response: 200 OK
{
"mode": "cloud",
"api_base": "http://server:8000/api/v1",
"ble": {
"enabled": true,
"batch_interval_ms": 2500
},
"wifi": {
"monitor_enabled": true,
"client_enabled": false,
"ssid": "",
"batch_interval_ms": 10000
},
"network": {
"ntp_servers": ["pool.ntp.org"],
"eth0": {
"static": false,
"address": "",
"gateway": "",
"dns": ""
}
},
"dashboard": {
"enabled": true
},
"ssh_tunnel": {
"enabled": false,
"server": "",
"port": 22,
"user": "tunnel",
"remote_port": 0
}
}
Note: Sensitive fields (passwords, keys) are omitted from response.
Returns recent BLE events (last 100, kept for 15 seconds).
Request:
GET /api/ble/recent HTTP/1.1
Host: 192.168.5.244
Response: 200 OK
[
{
"type": "ibeacon",
"mac": "AA:BB:CC:DD:EE:FF",
"rssi": -65,
"ts_ms": 1703001234567,
"uuid": "f7826da64fa24e988024bc5b71e0893e",
"major": 100,
"minor": 1,
"tx_power": -59
},
{
"type": "my-beacon_acc",
"mac": "11:22:33:44:55:66",
"rssi": -72,
"ts_ms": 1703001234568,
"x": 123,
"y": -45,
"z": 678,
"bat": 95,
"temp": 25.5
}
]
BLE Event Types:
ibeacon: Apple iBeacon formatmy-beacon_acc: Custom accelerometer beaconrt_mybeacon: Relay beaconReturns recent WiFi probe requests (last 100).
Request:
GET /api/wifi/recent HTTP/1.1
Host: 192.168.5.244
Response: 200 OK
[
{
"mac": "AA:BB:CC:DD:EE:FF",
"rssi": -55,
"ts_ms": 1703001234567,
"ssid": "MyNetwork",
"freq": 2437,
"channel": 6
}
]
Returns recent daemon log lines (last 500).
Request:
GET /api/logs HTTP/1.1
Host: 192.168.5.244
Response: 200 OK
[
"12:36:28 [ble] Uploaded 2 events to server",
"12:36:31 [ble] Uploaded 1 events to server",
"12:36:33 [scanner] BLE scanner started (pid=1234)"
]
Returns kernel log messages from dmesg (last 500 lines).
Request:
GET /api/kernel-logs HTTP/1.1
Host: 192.168.5.244
Response: 200 OK
[
"[45666.294334] aicwf_sdio mmc1:7a8a:1 wlan0: CLOSE",
"[45666.295543] ieee80211 phy0: HT supp 1, VHT supp 1, HE supp 1"
]
Note: BusyBox dmesg doesn't support -T flag, timestamps are in [seconds.microseconds] format since boot.
Validates device password and creates a session.
Request:
POST /api/unlock HTTP/1.1
Host: 192.168.5.244
Content-Type: application/json
{
"password": "82680499"
}
Response: 200 OK
{
"token": "abc123def456..."
}
Error Response: 401 Unauthorized
Invalid password
Updates device settings (requires valid password).
Request:
POST /api/settings HTTP/1.1
Host: 192.168.5.244
Content-Type: application/json
{
"password": "82680499",
"settings": {
"mode": "cloud",
"wifi_client_enabled": true,
"wifi_ssid": "MyNetwork",
"wifi_psk": "password123",
"wifi_monitor_enabled": false,
"eth0_mode": "dhcp",
"ntp_servers": "pool.ntp.org,time.google.com"
}
}
Settings Fields:
mode: "cloud" or "lan"wifi_client_enabled: Enable WiFi clientwifi_ssid: WiFi network namewifi_psk: WiFi passwordwifi_monitor_enabled: Enable WiFi scanner (LAN mode only)eth0_mode: "dhcp" or "static"eth0_ip: Static IP (when eth0_mode="static")eth0_gateway: Gateway (static mode)eth0_dns: DNS server (static mode)ntp_servers: Comma-separated NTP serversble_enabled: Enable BLE scanner (LAN mode only)ble_batch_interval_ms: BLE batch intervalwifi_monitor_batch_interval_ms: WiFi batch intervalResponse: 200 OK
{
"success": true
}
Error Response: 401 Unauthorized
Invalid password
Note:
Real-time event stream for dashboard updates.
Connection:
const ws = new WebSocket('ws://192.168.5.244/api/ws');
Message Format:
{
"type": "ble",
"event": {
"mac": "AA:BB:CC:DD:EE:FF",
"rssi": -65,
"ts_ms": 1703001234567
}
}
Message Types:
type: "ble": BLE eventtype: "wifi": WiFi eventtype: "log": Log messageBase URL: Configured in device settings (default: http://server:8000/api/v1)
Authentication: Bearer token in Authorization header (except registration).
Registers a new device with the server. Called once on first boot.
Request:
POST /api/v1/registration HTTP/1.1
Host: server:8000
Content-Type: application/json
{
"device_id": "38:54:39:4b:1b:ad",
"eth_ip": "192.168.5.244",
"wlan_ip": "192.168.5.100",
"ssh_public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA..."
}
Fields:
device_id: Device MAC address (eth0)eth_ip: Ethernet IP address (optional)wlan_ip: WiFi IP address (optional)ssh_public_key: SSH public key for tunnel (optional)Response: 201 Created
{
"device_token": "gRMRUKnqO9KXikBzoKhs0aE3uDYUvTxHYuU4/uatyrc=",
"device_password": "82680499",
"ssh_tunnel": {
"enabled": true,
"remote_port": 50123,
"server": "tunnel.example.com"
}
}
Response Fields:
device_token: Authentication token for API calls (save to /opt/mybeacon/etc/device.json)device_password: 8-digit PIN for dashboard (save to device.json)ssh_tunnel: SSH tunnel configuration (optional)Error Response: 400 Bad Request
{
"error": "device_id is required"
}
Fetches device configuration from server (Cloud mode only, polled every 30 seconds).
Request:
GET /api/v1/config?device_id=38:54:39:4b:1b:ad HTTP/1.1
Host: server:8000
Authorization: Bearer gRMRUKnqO9KXikBzoKhs0aE3uDYUvTxHYuU4/uatyrc=
Response: 200 OK
{
"force_cloud": false,
"ble": {
"enabled": true,
"batch_interval_ms": 2500,
"uuid_filter_hex": ""
},
"wifi": {
"client_enabled": false,
"ssid": "",
"psk": "",
"monitor_enabled": true,
"batch_interval_ms": 10000
},
"ssh_tunnel": {
"enabled": true,
"server": "tunnel.example.com",
"port": 22,
"user": "tunnel",
"remote_port": 50123,
"keepalive_interval": 30
},
"dashboard_tunnel": {
"enabled": true,
"server": "tunnel.example.com",
"port": 22,
"user": "tunnel",
"remote_port": 60123,
"keepalive_interval": 30
},
"dashboard": {
"enabled": true
},
"net": {
"ntp": {
"servers": ["pool.ntp.org", "time.google.com"]
}
},
"debug": false
}
Configuration Priority:
Error Response: 401 Unauthorized
Invalid or missing token
Uploads batch of BLE events (gzip compressed).
Request:
POST /api/v1/ble HTTP/1.1
Host: server:8000
Authorization: Bearer gRMRUKnqO9KXikBzoKhs0aE3uDYUvTxHYuU4/uatyrc=
Content-Type: application/json
Content-Encoding: gzip
<gzipped JSON payload>
Uncompressed Payload:
{
"device_id": "38:54:39:4b:1b:ad",
"events": [
{
"type": "ibeacon",
"mac": "AA:BB:CC:DD:EE:FF",
"rssi": -65,
"ts_ms": 1703001234567,
"uuid": "f7826da64fa24e988024bc5b71e0893e",
"major": 100,
"minor": 1,
"tx_power": -59
},
{
"type": "my-beacon_acc",
"mac": "11:22:33:44:55:66",
"rssi": -72,
"ts_ms": 1703001234568,
"x": 123,
"y": -45,
"z": 678,
"bat": 95,
"temp": 25.5,
"ff": false
}
]
}
Event Types and Fields:
iBeacon:
type: "ibeacon"mac: Device MAC addressrssi: Signal strength (dBm)ts_ms: Timestamp (milliseconds since epoch)uuid: iBeacon UUID (32 hex chars, no dashes)major: Major value (0-65535)minor: Minor value (0-65535)tx_power: Calibrated TX powermy-beacon_acc:
type: "my-beacon_acc"mac: Device MAC addressrssi: Signal strength (dBm)ts_ms: Timestampx, y, z: Accelerometer valuesbat: Battery level (0-100)temp: Temperature (°C)ff: Free fall detected (boolean)rt_mybeacon (Relay):
type: "rt_mybeacon"mac: Relay device MACrssi: Signal strength at relayts_ms: Timestamprelay_mac: Original beacon MACrelay_rssi: Original RSSIResponse: 200 OK
Error Response: 401 Unauthorized / 500 Internal Server Error
Notes:
/var/spool/mybeacon/ble/ (max 100MB)Uploads batch of WiFi probe requests (gzip compressed).
Request:
POST /api/v1/wifi HTTP/1.1
Host: server:8000
Authorization: Bearer gRMRUKnqO9KXikBzoKhs0aE3uDYUvTxHYuU4/uatyrc=
Content-Type: application/json
Content-Encoding: gzip
<gzipped JSON payload>
Uncompressed Payload:
{
"device_id": "38:54:39:4b:1b:ad",
"events": [
{
"mac": "AA:BB:CC:DD:EE:FF",
"rssi": -55,
"ts_ms": 1703001234567,
"ssid": "MyNetwork",
"freq": 2437,
"channel": 6
}
]
}
Event Fields:
mac: Device MAC addressrssi: Signal strength (dBm)ts_ms: Timestamp (milliseconds since epoch)ssid: Network SSID (may be empty for probe requests)freq: Frequency (MHz)channel: WiFi channelResponse: 200 OK
Notes:
/var/spool/mybeacon/wifi/Updates WiFi client credentials (Cloud mode only).
Request:
POST /api/v1/wifi-credentials HTTP/1.1
Host: server:8000
Authorization: Bearer gRMRUKnqO9KXikBzoKhs0aE3uDYUvTxHYuU4/uatyrc=
Content-Type: application/json
{
"ssid": "NewNetwork",
"psk": "password123"
}
Response: 200 OK
{
"success": true
}
Purpose: When user changes WiFi credentials via dashboard in Cloud mode, device:
Server can use this for:
Device API:
200 OK: Success401 Unauthorized: Invalid password405 Method Not Allowed: Wrong HTTP method500 Internal Server Error: Server errorServer API:
200 OK: Success201 Created: Resource created400 Bad Request: Invalid request401 Unauthorized: Invalid/missing token500 Internal Server Error: Server error/opt/mybeacon/etc/device.jsondevice_token missing → POST /api/v1/registrationdevice.json/api/v1/config every 30s (Cloud mode)/api/v1/ble or /api/v1/wifi/api/v1/config)/api/settings → apply locallyServer API:
Authorization: Bearer <token>Device API:
device_passwordSwitching Modes: Via dashboard → Settings → Mode → Apply
Force Cloud:
Server can set force_cloud: true in config to prevent mode switching (for support).
Configuration:
/opt/mybeacon/etc/config.json - Local config/opt/mybeacon/etc/device.json - Device state (token, password)/opt/mybeacon/etc/tunnel_key - SSH private keyLogs:
/var/log/mybeacon.log - Daemon logs (tmpfs)dmesgSpool:
/var/spool/mybeacon/ble/ - Failed BLE batches/var/spool/mybeacon/wifi/ - Failed WiFi batchescurl -X POST http://server:8000/api/v1/registration \
-H "Content-Type: application/json" \
-d '{
"device_id": "38:54:39:4b:1b:ad",
"eth_ip": "192.168.5.244"
}'
curl http://192.168.5.244/api/status | jq
curl -X POST http://192.168.5.244/api/settings \
-H "Content-Type: application/json" \
-d '{
"password": "82680499",
"settings": {
"wifi_client_enabled": true,
"wifi_ssid": "MyNetwork",
"wifi_psk": "password123"
}
}'
# Prepare JSON
echo '{
"device_id": "38:54:39:4b:1b:ad",
"events": [{"type":"ibeacon","mac":"AA:BB:CC:DD:EE:FF","rssi":-65,"ts_ms":1703001234567}]
}' | gzip > /tmp/events.json.gz
# Upload
curl -X POST http://server:8000/api/v1/ble \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-H "Content-Encoding: gzip" \
--data-binary @/tmp/events.json.gz
const ws = new WebSocket('ws://192.168.5.244/api/ws');
ws.onmessage = (event) => {
const msg = JSON.parse(event.data);
if (msg.type === 'ble') {
console.log('BLE event:', msg.event);
} else if (msg.type === 'wifi') {
console.log('WiFi event:', msg.event);
} else if (msg.type === 'log') {
console.log('Log:', msg.message);
}
};
ws.onopen = () => console.log('Connected');
ws.onerror = (err) => console.error('Error:', err);
GET /api/status → server_ok: trueGET /api/logsGET /api/status → networkls -lh /var/spool/mybeacon/GET /api/status → network.wlan0_ipGET /api/config → modeCompany ID: 0x004C (Apple)
Type: 0x02 0x15
UUID: 16 bytes
Major: 2 bytes (big-endian)
Minor: 2 bytes (big-endian)
TX Power: 1 byte (signed)
Company ID: 0x0059 (Nordic)
Prefix: "acc" (3 bytes)
X: 2 bytes (signed)
Y: 2 bytes (signed)
Z: 2 bytes (signed)
Battery: 1 byte (0-100)
Temp: 1 byte (signed, °C)
Free Fall: 1 bit
Company ID: 0xFFFF (Custom)
Prefix: "rt" (2 bytes)
Original MAC: 6 bytes
Original RSSI: 1 byte (signed)
Original payload: variable
API Version: 1.0 Last Updated: 2025-12-28 Device Firmware: Alpine Linux + MyBeacon Native Compatible with: Backend API v1
For issues or questions:
GET /api/logsGET /api/kernel-logsssh root@<device-ip> (password: 1)/etc/init.d/S98mybeacon status