API reference
Getting started
The API is on from the start and can be turned off under Remote control (API) in the admin menu. That screen shows the device's address, the port (2323 unless you choose another) and the access key, which is created automatically. The API only answers while kiosk mode is active.
Security
- Every request needs the access key. Without it the API answers
401. - The traffic is unencrypted HTTP. Only use the API on a network you trust, and never expose the port to the internet. Anyone with the key can control the device and take photos with the camera.
- The key is not included in an exported configuration. Create a new access key makes the old one invalid immediately.
Send the key in one of three ways:
Authorization: Bearer <key>
X-Api-Key: <key>
...?token=<key>
Endpoints
Commands that change something need POST (PUT for the configuration). Parameters can be sent in the query string, as a form or as a JSON body. Answers are JSON: successful commands return {"ok":true} and errors return {"ok":false,"error":"..."} with a matching status code.
| Method | Path | Parameters | Does |
|---|---|---|---|
| GET | /api/status | Device state, see below | |
| POST | /api/screen/off | Turns the screen off | |
| POST | /api/screen/on | Turns the screen on and brings the kiosk to the front | |
| POST | /api/web/load | url | Loads a page in web mode |
| POST | /api/web/reload | Reloads the page | |
| POST | /api/web/home | Goes to the start URL | |
| POST | /api/mode | mode = web, app or media | Changes content mode |
| POST | /api/brightness | percent = 1â100 or system | Sets the brightness |
| POST | /api/volume | percent = 0â100 | Sets the volume |
| GET | /api/camera/photo | camera = front or back (optional) | Takes a photo, answers with image/jpeg |
| GET | /api/motion | State of motion detection | |
| GET | /api/config | The whole configuration as JSON | |
| PUT | /api/config | body: configuration as JSON | Replaces the configuration |
| POST | /api/reboot | Restarts the device |
Status codes: 200 success, 400 wrong or missing parameter, 401 wrong key, 404 unknown path, 405 wrong method, 409 not possible in the current mode (for example a web command when web mode is not active), 413 request too large, 503 camera not available.
Examples
KEY=your-key
HOST=http://192.168.1.50:2323
curl -H "Authorization: Bearer $KEY" $HOST/api/status
curl -H "Authorization: Bearer $KEY" -X POST $HOST/api/screen/off
curl -H "Authorization: Bearer $KEY" -X POST "$HOST/api/web/load?url=https://example.com/menu"
curl -H "Authorization: Bearer $KEY" -X POST "$HOST/api/brightness?percent=40"
curl -H "Authorization: Bearer $KEY" -o photo.jpg "$HOST/api/camera/photo?camera=front"
curl -H "Authorization: Bearer $KEY" $HOST/api/config > config.json
curl -H "Authorization: Bearer $KEY" -X PUT --data-binary @config.json $HOST/api/config
Status
{
"appVersion": "1.0.0",
"appVersionCode": 1,
"deviceOwner": true,
"kioskActive": true,
"mode": "web",
"screenOn": true,
"scheduledScreenOn": true,
"brightnessPercent": -1,
"volumePercent": -1,
"web": { "url": "https://example.com/" },
"battery": { "percent": 100, "charging": true, "temperatureC": 25.0 },
"network": { "connected": true, "ip": "192.168.1.50" },
"motion": { "enabled": true, "secondsSinceMotion": 3 },
"device": { "manufacturer": "Samsung", "model": "SM-X200", "android": "14", "sdk": 34 },
"freeStorageMb": 3561,
"uptimeSeconds": 112,
"timeMs": 1794326916492
}
brightnessPercentandvolumePercentare the configured values;-1means the system controls the brightness, or that the volume is left alone.scheduledScreenOntells what the screen schedule says right now.web.urlisnullwhen web mode is not shown.secondsSinceMotionisnulluntil the first motion has been detected.
Good to know
/api/web/loadmay show an address outside the list of allowed domains, but further navigation from that page follows the list. Add the domain to the list if users should be able to click on./api/brightness,/api/volumeand/api/modechange the configuration and therefore remain after a restart./api/modeanswers409if the mode cannot be turned on, for example if no app is chosen for Single app./api/rebootrequires Device Owner.- Photos are at most 1280 pixels wide. The first photo after the camera has been opened takes a second, while the exposure settles.
- After
/api/screen/off, motion detection waits 15 seconds before it may turn the screen on again.
Motion detection
Turned on under Screensaver and motion in the admin menu. There you also find Test motion detection, which shows live when the camera detects motion and works without kiosk mode. The first time, the app asks for permission to use the camera (as Device Owner it is granted automatically). The camera compares pictures about four times per second. When it detects motion, the screensaver is woken and the inactivity timers are reset, and the screen is turned on if Turn the screen on at motion is on and the screen schedule allows it. Pictures are analysed on the device and are never saved or sent. A picture only leaves the device through /api/camera/photo.
API-beskrivning
Kom igÄng
API:et Àr pÄ frÄn början och kan stÀngas av under FjÀrrstyrning (API) i admin-menyn. SkÀrmen dÀr visar enhetens adress, porten (2323 om inget annat vÀljs) och Ätkomstnyckeln, som skapas automatiskt. API:et svarar bara medan kiosklÀget Àr aktivt.
SĂ€kerhet
- Varje anrop krÀver Ätkomstnyckeln. Utan nyckel svarar API:et
401. - Trafiken Àr okrypterad HTTP. AnvÀnd API:et bara pÄ ett nÀtverk du litar pÄ, och slÀpp aldrig ut porten mot internet. Den som har nyckeln kan styra enheten och ta bilder med kameran.
- Nyckeln följer inte med i en exporterad konfiguration. Skapa ny Ätkomstnyckel gör den gamla ogiltig direkt.
Nyckeln skickas pÄ nÄgot av tre sÀtt:
Authorization: Bearer <nyckel>
X-Api-Key: <nyckel>
...?token=<nyckel>
Anrop
Kommandon som Àndrar nÄgot krÀver POST (PUT för konfigurationen). Parametrar kan skickas i frÄgestrÀngen, som formulÀr eller som JSON-kropp. Svaren Àr JSON: lyckade kommandon ger {"ok":true} och fel ger {"ok":false,"error":"..."} med passande statuskod.
| Metod | SökvÀg | Parametrar | Gör |
|---|---|---|---|
| GET | /api/status | Enhetens lÀge (exempel i den engelska delen) | |
| POST | /api/screen/off | SlÀcker skÀrmen | |
| POST | /api/screen/on | TÀnder skÀrmen och lyfter fram kiosken | |
| POST | /api/web/load | url | Laddar en sida i webblÀget |
| POST | /api/web/reload | Laddar om sidan | |
| POST | /api/web/home | GÄr till start-URL | |
| POST | /api/mode | mode = web, app eller media | Byter innehÄllslÀge |
| POST | /api/brightness | percent = 1â100 eller system | SĂ€tter ljusstyrkan |
| POST | /api/volume | percent = 0â100 | SĂ€tter volymen |
| GET | /api/camera/photo | camera = front eller back (valfri) | Tar en bild, svarar med image/jpeg |
| GET | /api/motion | Rörelsedetekteringens lÀge | |
| GET | /api/config | Hela konfigurationen som JSON | |
| PUT | /api/config | kropp: konfiguration som JSON | ErsÀtter konfigurationen |
| POST | /api/reboot | Startar om enheten |
Statuskoder: 200 lyckat, 400 fel eller saknad parameter, 401 fel nyckel, 404 okÀnd sökvÀg, 405 fel metod, 409 gÄr inte i nuvarande lÀge (t.ex. webbkommando nÀr webblÀget inte Àr aktivt), 413 för stor förfrÄgan, 503 kameran gÄr inte att anvÀnda.
Exempel och statussvarets format stÄr i den engelska delen; de Àr desamma.
Att tÀnka pÄ
/api/web/loadfÄr visa en adress utanför listan med tillÄtna domÀner, men vidare navigering frÄn den sidan följer listan. LÀgg till domÀnen i listan om anvÀndaren ska kunna klicka sig vidare./api/brightness,/api/volumeoch/api/modeÀndrar konfigurationen och ligger dÀrför kvar efter omstart./api/modesvarar409om lÀget inte gÄr att slÄ pÄ, t.ex. om ingen app Àr vald för lÀget En app./api/rebootkrÀver Device Owner.- Bilder har högst 1280 punkters bredd. Första bilden efter att kameran öppnats tar nÄgon sekund, eftersom exponeringen mÄste stÀlla in sig.
- Efter
/api/screen/offvÀntar rörelsedetekteringen 15 sekunder innan den fÄr tÀnda skÀrmen igen.
Rörelsedetektering
SlÄs pÄ under SkÀrmslÀckare och rörelse i admin-menyn. DÀr finns ocksÄ Testa rörelsedetekteringen, som visar direkt nÀr kameran upptÀcker rörelse och fungerar utan kiosklÀge. Första gÄngen frÄgar appen om lov att anvÀnda kameran (som Device Owner beviljas det automatiskt). Kameran jÀmför bilder ungefÀr fyra gÄnger per sekund. Vid rörelse vÀcks skÀrmslÀckaren och inaktivitetstiderna nollstÀlls, och skÀrmen tÀnds om TÀnd skÀrmen vid rörelse Àr pÄ och skÀrmschemat tillÄter det. Bilderna analyseras pÄ enheten och sparas eller skickas aldrig. En bild lÀmnar enheten bara genom /api/camera/photo.