API#
spkrepo exposes a RESTful API and returns standard HTTP Status Codes in all responses. Data is returned as JSON.
Authentication#
To access the API, user must be registered, have the developer role and generated an API key from the profile
page. The Authorization header is mandatory and must contain the API key as user with no password.
If the authentication fails, a 401 Unauthorized is returned.
Warning
For security reasons, only one API key can be valid at a time. Should the API key be compromised, a new one can be generated from the profile page.
Errors#
In case of an ambiguous error, a detailed explanation is returned in JSON as message:
HTTP/1.1 422 UNPROCESSABLE ENTITY
Content-Length: 43
Content-Type: application/json
{
"message": "Unknown architecture: myarch"
}
Endpoints#
- POST /api/packages#
Post a SPK to the repository.
First a
Packageis created if not existing already, based on thename. Only users withpackage_adminrole can create new packages, other users must be defined asmaintainersto be able to continue.Then a
Versionis created with its appropriate relationships if not existing already, based on thepackageand theversion.Lastly, a
Buildis created with its appropriate relationships and files saved on the filesystem.Example response:
HTTP/1.1 201 CREATED Content-Length: 97 { "architectures": ["88f628x"], "firmware": "3.1-1594", "package": "btsync", "version": "1.4.103-10" }
- Status Codes:
201 Created – SPK registered
400 Bad Request – Request contained no body
403 Forbidden – Insufficient permission
409 Conflict – A
Buildalready exists422 Unprocessable Entity – Invalid or malformed SPK
500 Internal Server Error – Signing or filesystem issue
- POST /nas/#
Return the package catalog for a DSM/SRM device.
This is the endpoint DSM/SRM devices poll to discover packages available for their architecture, firmware, and language. The response shape depends on the
buildfirmware number: builds below5004get a bare list, builds from5004up to (but not including)40000(DSM 6) additionally get akeyringsentry, and DSM 7+ builds (40000and above) getpackagesonly.- Query Parameters:
build – the device’s firmware build number (required)
arch – the device’s CPU architecture code, as reported by DSM/SRM (required)
language – the device’s language code, e.g.
enu(required)major – the DSM/SRM major version; inferred from
buildagainst known firmware if omittedpackage_update_channel – set to
betato include beta packages (DSM < 7 only; ignored otherwise)
Example response (DSM 7+):
HTTP/1.1 200 OK Content-Type: application/json { "packages": [ { "package": "git", "version": "2.1.2-4", "dname": "Git", "desc": "Distributed version control system.", "link": "https://example.com/.../git.v4.f64570%5Bx86_64%5D.spk", "thumbnail": ["https://example.com/nas/git/4/icon_72.png"], "qinst": true, "qupgrade": true, "qstart": false, "download_count": 1024, "recent_download_count": 87 } ] }
- Status Codes:
200 OK – catalog returned
400 Bad Request – a required parameter is missing and the client did not request an HTML response (browsers are redirected instead)
422 Unprocessable Entity –
language,arch, orbuildis invalid
- GET /nas/#
Return the package catalog for a DSM/SRM device.
This is the endpoint DSM/SRM devices poll to discover packages available for their architecture, firmware, and language. The response shape depends on the
buildfirmware number: builds below5004get a bare list, builds from5004up to (but not including)40000(DSM 6) additionally get akeyringsentry, and DSM 7+ builds (40000and above) getpackagesonly.- Query Parameters:
build – the device’s firmware build number (required)
arch – the device’s CPU architecture code, as reported by DSM/SRM (required)
language – the device’s language code, e.g.
enu(required)major – the DSM/SRM major version; inferred from
buildagainst known firmware if omittedpackage_update_channel – set to
betato include beta packages (DSM < 7 only; ignored otherwise)
Example response (DSM 7+):
HTTP/1.1 200 OK Content-Type: application/json { "packages": [ { "package": "git", "version": "2.1.2-4", "dname": "Git", "desc": "Distributed version control system.", "link": "https://example.com/.../git.v4.f64570%5Bx86_64%5D.spk", "thumbnail": ["https://example.com/nas/git/4/icon_72.png"], "qinst": true, "qupgrade": true, "qstart": false, "download_count": 1024, "recent_download_count": 87 } ] }
- Status Codes:
200 OK – catalog returned
400 Bad Request – a required parameter is missing and the client did not request an HTML response (browsers are redirected instead)
422 Unprocessable Entity –
language,arch, orbuildis invalid
- GET /nas/(path: path)#
Serve a file (SPK, icon, or screenshot) from local storage.
- Parameters:
path – relative file path under DATA_PATH, as returned by the catalog’s
link/thumbnail/snapshotURLs
- Status Codes:
200 OK – file returned
404 Not Found – no file exists at the given path