DocsReferenceAPI reference
microSD card
Files on the microSD card (FAT). Read and written in chunks of ≤ 1 MB per request (256 KB on the host), resumable. Leave existing files on the card alone; put your own under /stick/
GET /v1/sd/list#
List a folder on the microSD card (up to 256 entries)
Lists the files and subfolders one level deep, with the card total and used bytes. Temp files x~ left by interrupted uploads are listed too
Parameters#
| Parameter | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
path | string | pattern ^/ | length 1–160; ≤ 160 bytes | Folder; the card 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/sd |
503 | no_card | No card, the card is not FAT, or a mount was just tried (retry in 2 s); message says which |
500 | io_error | Card read/write error; the device unmounted the card and remounts on the next request. Retry |
For errors any endpoint can return, see Common errors.
GET /v1/sd#
Read a card file in chunks (≤ 1 MB per request)
The reply is the raw bytes of [offset, offset+length); the X-Size header is the file size. The host reads 256 KB chunks up to X-Size and resumes from the bytes it already has (stick sd get does this). If the device fails part way it can only drop the connection; re-read a short chunk
Parameters#
| Parameter | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
path | string | Yes | pattern ^/ | length 1–160; ≤ 160 bytes | File |
offset | integer | 0–2147483647 | Start byte; 0 when omitted | ||
length | integer | 0–1048576 | Byte count; up to 1 MB when omitted or larger (never past the end of the file) |
Reply#
Bytes of this part of the file
The reply is binary.
application/octet-stream
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_path | path is missing or invalid (see path) |
400 | bad_args | offset or length is not a non-negative integer |
416 | bad_offset | offset is past the end of the file (400 when over 2 GB) |
404 | not_found | No such file |
400 | is_dir | path is a folder. List it with GET /v1/sd/list |
503 | no_card | No card, the card is not FAT, or a mount was just tried (retry in 2 s); message says which |
500 | io_error | Card read/write error; the device unmounted the card and remounts on the next request. Retry |
For errors any endpoint can return, see Common errors.
PUT /v1/sd#
Write a card file in chunks (≤ 1 MB each, resumable)
Each chunk goes into the temp file path~ at offset: offset=0 starts it, later offsets must equal the bytes written so far; final=1 then renames path~ to path (replacing an existing file). Omitting both offset and final uploads a small file in one go. Parent folders are created. If a chunk arrives incomplete or its hash mismatches, the temp file is cut back to offset; resend from offset. The host uses 256 KB chunks (stick sd put, which also uploads folders)
Parameters#
| Parameter | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
path | string | Yes | pattern ^/ | length 1–160; ≤ 160 bytes | File |
offset | integer | 0–2147483647 | Start byte of this chunk in the file | ||
final | integer | 0 1 | 1 = last chunk; rename when written |
Request body#
application/octet-stream
Bytes of this chunk
Examples#
Small file in one go#
offset and final omitted; the content is hello and a newline
68656c6c6f0aFirst chunk of a large file#
offset=0 starts big.tl~; real chunks are 256 KB, 6 bytes shown here
000001040400Resume with the last chunk#
262144 bytes already written; final=1 renames it to big.tl
1e0002040000Reply#
Chunk written
The chunk is in the temp file; when done, it was renamed to the final file
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
path | string | Yes | The file (without ~) | ||
size | integer | Yes | ≥ 0 | Total bytes written so far; the offset of the next chunk | |
done | boolean | Yes | true = renamed to path, upload complete; false = still in the temp file path~ |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_path | path is missing or invalid (see path), or names a folder (/ or ending in /) |
400 | bad_args | offset is not a non-negative integer, or final is not 0 / 1 |
409 | bad_offset | offset differs from the temp file's current size; the reply also carries size (the current size), resume from there. 400 when offset is over 2 GB. See the example “Resume with the last chunk” for the correct form |
413 | too_large | The chunk is larger than 1 MB |
409 | is_dir | A folder with this name exists |
409 | bad_parent | A file in the parent path blocks creating the folder |
507 | no_space | The card is full; the temp file was deleted |
503 | no_card | No card, the card is not FAT, or a mount was just tried (retry in 2 s); message says which |
500 | io_error | Card read/write error; the device unmounted the card and remounts on the next request. Retry |
For errors any endpoint can return, see Common errors.
DELETE /v1/sd#
Delete a card file or folder (recursive=1 deletes its contents)
A folder must be empty unless recursive=1; the root cannot be deleted. Leave existing files on the card alone and delete only your own (kept under /stick/)
Parameters#
| Parameter | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
path | string | Yes | pattern ^/ | length 1–160; ≤ 160 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_card | No card, the card is not FAT, or a mount was just tried (retry in 2 s); message says which |
500 | io_error | Card read/write error; the device unmounted the card and remounts on the next request. Retry |
For errors any endpoint can return, see Common errors.