HTTP-API

La superficie HTTP del robot: stato, configurazione, rete, apps, viso, voce, notifiche, media e file. Il firmware registra 115 route; molteplici metodi sullo stesso percorso contano come registrazioni separate. The robot's HTTP surface: status, configuration, network, apps, face, voice, notifications, media, and files. The firmware registers 115 routes; multiple methods on the same path count as separate registrations.

Schermata API della web UI
Route registratiRegistered routes115
GruppiGroups9
MetodiMethodsGET · POST · DELETE
FormatoFormatJSON
FonteSourceWebService.cpp

ConvenzioniConventions

Prima di usare un endpoint: URL base, metodo, formato del corpo e codici di risposta.Before using an endpoint: base URL, method, body format, and response codes.

Il server web è attivo solo quando il robot è connesso al Wi-Fi e non si trova in modalità BLE-only. Le richieste sono servite una alla volta e la risposta chiude la connessione. Il formato generale è JSON; fanno eccezione la pagina web e i suoi asset, il framebuffer BMP, la copertina audio e l'esportazione CSV delle statistiche.The web server is active only when the robot is connected to Wi-Fi and is not in BLE-only mode. Requests are served one at a time and the response closes the connection. The general format is JSON; exceptions are the web page and its assets, the BMP framebuffer, the audio cover, and the CSV statistics export.

Un POST con corpo JSON richiede al firmware di attendere il body e può impiegare circa dieci secondi. Quando il route accetta parametri di query, è preferibile usarli: vengono letti subito dopo le intestazioni. Gli errori applicativi usano {"ok": false, "error": "…"} con codici 400, 404, 409, 410, 415, 500 o 503.A POST with a JSON body requires the firmware to wait for the body and can take about ten seconds. When a route accepts query parameters, prefer them: they are read immediately after the headers. Application errors use {"ok": false, "error": "…"} with codes 400, 404, 409, 410, 415, 500, or 503.

POST /api/config non accette più scritture e risponde 410 Gone: la configurazione vive in quattro file JSON sulla scheda SD. Le API di rete, volume, luminosità e notifiche sono invece ancora attive.POST /api/config no longer accepts writes and answers 410 Gone: configuration lives in four JSON files on the SD card. Network, volume, brightness, and notification APIs are still active.

CodiceCodeSignificatoMeaning
200Operazione riuscitaOperation succeeded
400Richiesta malformataMalformed request
404Risorsa assenteResource not found
409Stato incompatibileConflicting state
410Endpoint deprecatoDeprecated endpoint
415Tipo di contenuto non supportatoUnsupported content type
500Errore internoInternal error
503Servizio non prontoService not ready

Esempio rapidoQuick example

curl "http:///api/info"
curl -X POST "http:///api/app/music?action=open"
curl -X POST "http:///api/face/expr?name=Happy"
curl -X POST "http:///api/screen?on=false"

Regole operativeOperating rules

  • Il server accetta un solo client per volta: non aprire richieste parallele persistenti.The server accepts one client at a time: do not open parallel persistent requests.
  • Le coordinate di /api/input/tap sono in unità del viso (x 0..128, y −44.9..111), non pixel./api/input/tap coordinates are face units (x 0..128, y −44.9..111), not pixels.
  • Le route che cambiano stato sono POST o DELETE: un GET non deve mai attivare un'azione.State-changing routes are POST or DELETE: a GET must never trigger an action.

Route per area funzionaleRoutes by functional area

Ogni voce è tratta dal router del firmware; i metodi sono indicati esplicitamente.Every entry comes from the firmware router; methods are listed explicitly.

GET Sistema, display e diagnostica System, display, and diagnostics (25)
MetodoMethodPercorsoPathFunzionePurpose
GET/Pagina principale della web UI.Main web-UI page.
GET/controlVista ridotta del vetro con comandi remoti.Reduced glass view with remote commands.
GET/facesReindirizza alla sezione Brain (HTTP 302).Redirects to the Brain section (HTTP 302).
GET/app/*Asset statici compilati nel firmware: CSS, JS, tab, grafici.Static assets compiled into firmware: CSS, JS, tabs, charts.
GET/api/infoStato dispositivo: uptime, heap, RSSI, IP, SD, IMU, batteria, ora.Device status: uptime, heap, RSSI, IP, SD, IMU, battery, time.
GET/api/versionVersione e metadati di build del firmware.Firmware version and build metadata.
GET/api/serialLog seriale degli eventi, filtrabile per timestamp.Event serial log, filterable by timestamp.
GET/api/perfMetriche di prestazioni e tempi di ciclo.Performance metrics and cycle timings.
GET/api/statsSommario metriche, eventi principali e attività recente.Metric summary, top events, and recent activity.
GET/api/stats/exportStorico completo in formato CSV.Full history in CSV format.
GET/api/powerPotenza della sessione: batteria e consumo corrente.Session power: battery level and current draw.
GET/api/pmuLettura dettagliata del PMU AXP2101.Detailed AXP2101 PMU reading.
GET/api/diagDiagnostica coordinata di display, touch, microfono e codec.Coordinated display, touch, microphone, and codec diagnostics.
GET/api/configConfigurazione corrente (sola lettura).Current configuration (read-only).
POST/api/configNon più supportato: risponde 410 Gone. Usare i file JSON sulla SD.No longer supported: answers 410 Gone. Use the JSON files on the SD card.
GET/api/settingsImpostazioni correnti: volume, luminosità, lingue, notifiche, Wi-Fi.Current settings: volume, brightness, languages, notifications, Wi-Fi.
POST/api/settingsSalva e applica subito le impostazioni.Saves and immediately applies settings.
POST/api/levelsImposta volume, luminosità e volume MP3.Sets volume, brightness, and MP3 volume.
POST/api/screenAccende o spegne il display.Turns the display on or off.
GET/api/screen.bmpFramebuffer RGB565 368×448 (circa 495 KB).368×448 RGB565 framebuffer (about 495 KB).
GET/api/screen.vlqFotogramma ridotto 92×112 per la vista /control.Reduced 92×112 frame for the /control view.
POST/api/rebootRiavvia il robot.Reboots the robot.
GET Rete, Wi-Fi e BLE Network, Wi-Fi, and BLE (22)
MetodoMethodPercorsoPathFunzionePurpose
GET/api/netStato della connessione Wi-Fi corrente.Current Wi-Fi connection state.
GET/api/net/retryRilancia il tentativo di connessione.Retries the connection attempt.
POST/api/net/retryRilancia il tentativo di connessione.Retries the connection attempt.
GET/api/net/forgetDimentica una rete salvata.Forgets a saved network.
POST/api/net/forgetDimentica una rete salvata.Forgets a saved network.
GET/api/wifi/scanReti trovate dalla scansione in corso.Networks found by the running scan.
POST/api/wifi/scanAvvia la scansione delle reti vicine.Starts scanning nearby networks.
GET/api/wifi/savedReti salvate nel dispositivo.Networks saved on the device.
POST/api/wifi/saveSalva le credenziali di una rete.Saves a network's credentials.
POST/api/wifi/connectSalva e connette a una rete.Saves and connects to a network.
POST/api/wifi/useConnette a una rete già salvata.Connects to an already saved network.
POST/api/wifi/forgetRimuove una rete dall'elenco salvato.Removes a network from the saved list.
GET/api/bleStato BLE: heap, MAC e dispositivi rilevati.BLE state: heap, MAC, and detected devices.
POST/api/ble/toggleAttiva o disattiva la radio BLE a runtime.Enables or disables the BLE radio at runtime.
GET/api/ble/scanRisultati della scansione BLE.BLE scan results.
POST/api/ble/scanAvvia una scansione BLE di cinque secondi.Starts a five-second BLE scan.
GET/api/ble/inspectServizi GATT di un dispositivo.GATT services of a device.
POST/api/ble/inspectEsplora i servizi GATT di un dispositivo.Inspects a device's GATT services.
POST Apps sul vetro e input On-glass apps and input (9)
MetodoMethodPercorsoPathFunzionePurpose
GET/api/appsCatalogo delle app registrate.Catalogue of registered apps.
GET/api/appAlias del catalogo delle app.Alias of the app catalogue.
GET/api/app/Stato dell'app richiesta: stato, errore, dettaglio.State of the requested app: state, error, detail.
POST/api/app/?action=openApre l'app sul vetro. Sono accettati anche cmd e key, o un POST vuoto.Opens the app on the glass. cmd and key are also accepted, as is an empty POST.
POST/api/app/?action=closeChiude l'app e torna al launcher (back e home sono equivalenti).Closes the app and returns to the launcher (back and home are equivalent).
POST/api/app/?action=Esegue un comando o una chiave sull'app attiva; arg ripete un'azione iterativa.Runs a command or key on the active app; arg repeats an iterative action.
POST/api/input/tapSimula un tocco. Le coordinate sono in unità del viso: x 0..128, y −44.9..111.Simulates a tap. Coordinates are face units: x 0..128, y −44.9..111.
GET/api/input/tapSimula un tocco (stessa semantica del POST).Simulates a tap (same semantics as POST).
POST/api/input/buttonSimula un pulsante laterale: boot/pwr, short/long.Simulates a side button: boot/pwr, short/long.
GET/api/input/buttonSimula un pulsante laterale (stessa semantica del POST).Simulates a side button (same semantics as POST).
GET Viso, espressioni e atti Face, expressions, and acts (7)
MetodoMethodPercorsoPathFunzionePurpose
GET/api/face/stateEspressione corrente, atto in scena e stato generale.Current expression, active act, and overall state.
GET/api/face/exprsCatalogo completo delle 56 espressioni.Full catalogue of the 56 expressions.
GET/api/face/graphGrafo delle transizioni tra espressioni.Expression transition graph.
GET/api/face/actsElenco dei 49 atti disponibili.List of the 49 available acts.
GET/api/face/liveFotogramma corrente del vetro in formato ridotto.Current glass frame in reduced format.
GET/api/face/expr?name=Forza un'espressione specifica.Forces a specific expression.
POST/api/face/expr?name=Forza un'espressione specifica.Forces a specific expression.
GET/api/face/act?name=Esegue un atto animato.Runs an animated act.
POST/api/face/act?name=Esegue un atto animato.Runs an animated act.
POST Voce, chat e assistente Voice, chat, and assistant (17)
MetodoMethodPercorsoPathFunzionePurpose
GET/api/chatInvia un messaggio testuale all'assistente attivo.Sends a text message to the active assistant.
POST/api/chatInvia un messaggio testuale all'assistente attivo.Sends a text message to the active assistant.
GET/api/chat/statusStato della chat: occupato, ultima risposta, errori.Chat status: busy, last reply, errors.
GET/api/chat/profileProfilo attivo e parametri della chat.Active profile and chat parameters.
GET/api/voice/statusStato della sessione vocale: off, connecting, listening, speaking.Voice session state: off, connecting, listening, speaking.
GET/api/voice/ttsGenera e riproduce la voce con il motore configurato.Generates and plays speech with the configured engine.
POST/api/voice/ttsGenera e riproduce la voce con il motore configurato.Generates and plays speech with the configured engine.
GET/api/voice/sttRegistra quattro secondi e trascrive l'audio.Records four seconds and transcribes the audio.
POST/api/voice/sttRegistra quattro secondi e trascrive l'audio.Records four seconds and transcribes the audio.
GET/api/assistantConfigurazione degli assistenti.Assistant configuration.
POST/api/assistantSalva la configurazione degli assistenti.Saves assistant configuration.
POST/api/assistant/verifyVerifica la raggiungibilità di un endpoint LLM.Verifies the reachability of an LLM endpoint.
POST/api/assistant/modelsElenco dei modelli disponibili su un endpoint.List of models available on an endpoint.
POST/api/assistant/voiceboxGestione dei profili vocali Voicebox.Voicebox voice-profile management.
GET/api/assistant/discoverI server voce trovati con mDNS e l'errore dell'ultima ricerca.The voice servers found through mDNS and the error of the last search.
POST/api/assistant/discoverForza una ricerca mDNS dei server voce.Forces an mDNS search for the voice servers.
POST/api/assistant/startAvvia l'attività dell'assistente.Starts the assistant activity.
POST/api/assistant/stopArresta l'attività dell'assistente.Stops the assistant activity.
Il server che risponde può essere locale:The server that answers can be local: queste route parlano con il server indicato nell'URL del profilo. Un server self-hosted come AiLocalVoiceServer (C#/.NET 10, API OpenAI-compatible e Voicebox-compatible, eseguibile anche su Android) espone le stesse rotte e rende la catena voce offline e senza servizi a pagamento: il robot non va modificato, basta l'URL http://:17500 e la chiave API vuota. La procedura è in docs/10-Sintesi-vocale-locale.md. these routes talk to the server set in the profile URL. A self-hosted server such as AiLocalVoiceServer (C#/.NET 10, OpenAI-compatible and Voicebox-compatible APIs, runnable on Android too) exposes the same routes and makes the voice chain offline and free of paid services: the robot needs no change, only the URL http://:17500 and an empty API key. The procedure is in docs/10-Sintesi-vocale-locale.md.
POST Notifiche Notifications (5)
MetodoMethodPercorsoPathFunzionePurpose
POST/api/notifyInvia una notifica: testo, TTS o audio WAV, con priorità e opzioni di interazione.Sends a notification: text, TTS, or WAV audio, with priority and interaction options.
GET/api/notifyMessaggio attivo, coda, contatori ed eventuale risposta sì/no.Active message, queue, counters, and any yes/no response.
DELETE/api/notifySvuota completamente la coda dei messaggi.Clears the message queue completely.
POST/api/notify/cancelAnnulla il messaggio corrente e ferma audio e digitazione.Cancels the current message and stops audio and typing.
POST/api/notify/respondRisponde a una notifica interattiva sì/no.Answers an interactive yes/no notification.
POST Media: musica, audio e foto Media: music, audio, and photos (15)
MetodoMethodPercorsoPathFunzionePurpose
GET/api/audio/listElenco delle clip audio caricate.List of uploaded audio clips.
POST/api/audioCarica una clip audio (multipart form).Uploads an audio clip (multipart form).
GET/api/audio/statusStato della clip e del codec.Clip and codec status.
GET/api/audio/coverCopertina della clip richiesta.Cover art of the requested clip.
POST/api/audio/playRiproduce una clip WAV con volume opzionale.Plays a WAV clip with optional volume.
POST/api/audio/deleteElimina una clip dalla scheda SD.Deletes a clip from the SD card.
GET/api/music/listElenco dei brani MP3 in una cartella.List of MP3 tracks in a folder.
POST/api/music/playRiproduce un brano MP3 con volume opzionale.Plays an MP3 track with optional volume.
POST/api/music/stopFerma la riproduzione musicale.Stops music playback.
POST/api/music/volumeImposta il volume del player musicale.Sets the music player's volume.
GET/api/music/statusBrano in corso e volume memorizzato.Current track and stored volume.
GET/api/photosElenco delle immagini sulla SD.List of images on the SD card.
GET/api/photos/listElenco delle immagini sulla SD.List of images on the SD card.
GET/api/photos/showMostra un'immagine sul vetro.Shows an image on the glass.
POST/api/photos/showMostra un'immagine sul vetro.Shows an image on the glass.
GET File system (SD) File system (SD) (6)
MetodoMethodPercorsoPathFunzionePurpose
GET/api/fs/listElenco del contenuto di una cartella sulla SD.Lists the contents of an SD-card folder.
POST/api/fs/uploadCarica un file sulla SD (multipart, con chunking).Uploads a file to the SD card (multipart, chunked).
GET/api/fs/downloadScarica un file dalla SD.Downloads a file from the SD card.
POST/api/fs/deleteElimina un file o una cartella.Deletes a file or a folder.
POST/api/fs/mkdirCrea una cartella.Creates a folder.
POST/api/fs/renameRinomina o sposta un file.Renames or moves a file.
GET Streaming e notizie Streaming and news (13)
MetodoMethodPercorsoPathFunzionePurpose
GET/api/streamsElenco degli stream MJPEG salvati.List of saved MJPEG streams.
POST/api/streams/saveSalva lo stream corrente.Saves the current stream.
POST/api/streams/deleteElimina uno stream salvato.Deletes a saved stream.
POST/api/stream/playAvvia uno stream sul vetro.Starts a stream on the glass.
GET/api/streamStato dello stream: fps, risoluzione, byte trasmessi.Stream status: fps, resolution, bytes transferred.
GET/api/stream/openApre uno stream da URL.Opens a stream from a URL.
POST/api/stream/openApre uno stream da URL.Opens a stream from a URL.
GET/api/stream/closeChiude lo stream attivo.Closes the active stream.
POST/api/stream/closeChiude lo stream attivo.Closes the active stream.
GET/api/stream/audioRiproduce audio PCM da URL.Plays PCM audio from a URL.
POST/api/stream/audioRiproduce audio PCM da URL.Plays PCM audio from a URL.
GET/api/newsTitoli dalle sorgenti RSS/Atom configurate.Headlines from configured RSS/Atom sources.
GET/api/news/sourcesElenco delle sorgenti di notizie configurate.List of configured news sources.
POST/api/news/sourcesSalva le sorgenti di notizie.Saves news sources.
Fonte canonica e limiti:Canonical source and limits: L'elenco deriva dalle registrazioni in sparky-amoled/src/web/WebService.cpp. Le route /api/defaults, /api/tts/info e /api/llm/select non appartengono al robot: sono endpoint del server di supporto e non vanno pubblicati qui. Alcune route sono implementate ma non documentate in docs/5-API-HTTP.md, come /api/version e /api/notify/respond. The list derives from the registrations in sparky-amoled/src/web/WebService.cpp. The /api/defaults, /api/tts/info, and /api/llm/select routes do not belong to the robot: they are companion-server endpoints and must not be published here. Some routes are implemented but not documented in docs/5-API-HTTP.md, such as /api/version and /api/notify/respond.