DocsReferenceAPI reference
Storage files
Files in the device storage (littlefs): apps /apps/<id>/, app data /data/<id>/, fonts /fonts/, device web app /www/. Files are read and written whole, ≤ 2 MB
GET /v1/fs/list#
List a storage folder (up to 256 entries)
Lists the files and subfolders one level deep, with the storage total and used bytes
Parameters#
| Parameter | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
path | string | pattern ^/ | length 1–96; ≤ 96 bytes | Folder; the root / when omitted |
Reply#
Folder listing
Folder listing for storage and the microSD card (same format)
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
path | string | Yes | The folder listed | ||
entries | object[] | Yes | ≤ 256 items | Entries, up to 256, in no particular order | |
name | string | Yes | Name (without the path) | ||
dir | boolean | Yes | Whether it is a folder | ||
size | integer | ≥ 0 | File size in bytes; absent for folders | ||
truncated | boolean | true when there are more than 256 entries (only 256 returned) | |||
total | integer | Yes | ≥ 0 | Total bytes of the storage or card | |
used | integer | Yes | ≥ 0 | Used bytes |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_path | path is missing or invalid (see path) |
404 | not_found | No such folder |
400 | not_dir | path is a file. Read files with GET /v1/fs |
503 | no_storage | Storage is not mounted. Restart the device; if it persists, check stick logs |
500 | io_error | Storage read/write error. Retry; if it persists, check stick logs |
For errors any endpoint can return, see Common errors.
GET /v1/fs#
Read a storage file (whole file)
The reply is the file's raw bytes. Host: stick fs get
Parameters#
| Parameter | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
path | string | Yes | pattern ^/ | length 1–96; ≤ 96 bytes | File |
Reply#
File content
The reply is binary.
application/octet-stream
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_path | path is missing or invalid (see path) |
404 | not_found | No such file |
400 | is_dir | path is a folder. List it with GET /v1/fs/list |
503 | no_storage | Storage is not mounted. Restart the device; if it persists, check stick logs |
500 | io_error | Storage read/write error. Retry; if it persists, check stick logs |
For errors any endpoint can return, see Common errors.
PUT /v1/fs#
Write a storage file (≤ 2 MB; replaces an existing one)
The body is the whole file. Parent folders are created; the device writes path~ first and then renames it, so a failure never leaves half a file. Host: stick fs put, stick push, stick www push
Parameters#
| Parameter | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
path | string | Yes | pattern ^/ | length 1–96; ≤ 96 bytes | File |
Request body#
text/plain
File content: UTF-8 text, or the raw bytes of a binary file (such as a font)
string; ≤ 2097152 bytes
Examples#
Write an app's entry file#
ui.label(ui.root(), {text = sys.date("%H:%M"), font = 48, align = "center"})Write an app manifest#
name is the app name shown on screen (时钟 = Clock)
{"id":"clock","name":"时钟","version":"0.1.0","main":"main.lua"}Reply#
Written
The file is written
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
path | string | Yes | The file written | ||
size | integer | Yes | ≥ 0 | File size in bytes |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_path | path is missing or invalid (see path), or names a folder (/ or ending in /) |
409 | is_dir | A folder with this name exists |
409 | bad_parent | A file in the parent path blocks creating the folder |
413 | too_large | Larger than 2 MB |
507 | no_space | Storage is full. Delete unused files (see total and used in GET /v1/fs/list) |
503 | no_storage | Storage is not mounted. Restart the device; if it persists, check stick logs |
500 | io_error | Storage read/write error. Retry; if it persists, check stick logs |
For errors any endpoint can return, see Common errors.
DELETE /v1/fs#
Delete a storage file or folder (recursive=1 deletes its contents)
A folder must be empty unless recursive=1. The root cannot be deleted; /apps, /data and /fonts come back empty after deletion
Parameters#
| Parameter | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
path | string | Yes | pattern ^/ | length 1–96; ≤ 96 bytes | File or folder |
recursive | integer | 0 1; default 0 | 1 = delete a folder with everything in it |
Reply#
Deleted
Successful reply; endpoints add their own fields
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_path | path is missing or invalid (see path), or is the root / |
404 | not_found | No such file or folder |
409 | not_empty | The folder is not empty: add recursive=1 |
503 | no_storage | Storage is not mounted. Restart the device; if it persists, check stick logs |
500 | io_error | Storage read/write error. Retry; if it persists, check stick logs |
For errors any endpoint can return, see Common errors.