Web Storage API
Two storage mechanisms on SpinetiX players, each limited to 4 MB:
| Object | Persistence | Cleared On |
|---|---|---|
localStorage | Permanent | localStorage.clear(), Control Center Operations > Reset, or the reset-webstorage configuration key. Survives reboot and publish |
sessionStorage | Semi-permanent | Player restart or publish |
JavaScript Usage
localStorage.setItem('key', 'value');
var val = localStorage.getItem('key');
localStorage.removeItem('key');
// Store objects as JSON
var data = { name: 'John', score: 100 };
localStorage.setItem('player', JSON.stringify(data));
var restored = JSON.parse(localStorage.getItem('player'));REST API (firmware 4.3.0+)
Reads and writes localStorage from external clients over HTTP(S). Not available on HMP300
and DiVA. Needs the SYSTEMS Feature Set.
| Method | Endpoint | Purpose |
|---|---|---|
GET | /webstorage | List all variables |
GET | /webstorage/{key} or /webstorage?name={key} | Get value |
POST | /webstorage | Update one or more variables from a form |
POST | /webstorage/{key} or /webstorage?name={key} | Update one variable with the POST content |
POST | /webstorage/{key}?expect={value} | Update only if the current value equals value |
DELETE | /webstorage/{key} | Delete a variable |
PURGE | /webstorage/ | Delete all variables (firmware 4.6.1+) |
The REST API is off by default: enable the security token access to the Webstorage API in Control Center
under Advanced Applications > API Security. Authentication: the security token (Bearer
header or access_token parameter), or a user with content authoring or admin rights. TLS-SRP
and HTTP Basic are supported.
Status API
Monitor player status: identification, temperature, uptime, network, screen, storage.
Endpoint: GET http(s)://[player_address]/status/info
$(function() {
$.get('http://player/status/info', function(data) {
var doc = $.parseXML(data);
var temp = $(doc.documentElement).find('temp').text();
$.textArea({}).text("Temp: " + temp + "°C").addTo('svg');
}, 'text');
});Related Pages
- Shared Variables — SV ⇄ localStorage bridge
- Data Feeds & AJAX — fetching status/data
- Player APIs — all API overview