REST API - Projects
Connection and authorization · Playback control · Calendar
All methods require a session cookie. filename is a path on the LS4 computer, not on the client computer. In JSON the backslash is escaped: "D:\\Shows\\Facade.ls".
Reading and opening
| Method and path | Body | Result |
|---|---|---|
GET /api/projects/current |
— | Information about the current project and the loading flag.
|
GET /api/projects/recent |
— | An array of recent projects, not a list of all files on the computer. |
POST /api/projects/check-version |
{"filename":"D:\\Shows\\Facade.ls"} |
The file version and its comparison with the LS4 version; a missing file — 404.
|
POST /api/projects/open |
{"filename":"D:\\Shows\\Facade.ls"} |
Open the project: 204; no such file — 404, another project operation is already in progress — 409.
|
A project list element: filename, name, exists, sizeBytes, modified, isCurrent, isBackup. The modified field is the file modification date/time; the size is in bytes.
The current project additionally contains scenes, fieldWidth, fieldHeight, loading. With no project, an object with an empty file name and zero characteristics is returned, not 404. With loading=true the information may be incomplete; wait for the operation to finish before the next command.
Version check response:
{
"fileVersion":"4.0.0",
"currentVersion":"4.0.0",
"isOlder":false,
"isNewer":false,
"versionMismatch":false
}
The numbers in the example are illustrative. The comparison uses the full version, while the strings show three components, so use the flags to decide. The version check does not open the project. open does not automatically save the current project and does not require the result of check-version: save any changes you need before switching.
Saving and backup
| Method and path | Result |
|---|---|
POST /api/projects/save |
Write the current project to its file, like Ctrl+S. 200: {"filename":"..."}.
|
POST /api/projects/backup |
Write a backup of the manual kind to the project's backup folder (Backups next to the project or your own folder from the settings) under the name project — date and time — manual.ls, leaving the previous project current. 200: {"filename":"..."} — the full path to the copy.
|
No request bodies are needed. If the project has no file name or an open/save operation is already in progress, the response is 409; if the backup folder could not be created or the copy could not be written — 500. Each backup call creates a new file (a coinciding second gets " (2)"), and as many of the latest manual copies are kept as set in the "Number of copies" setting — older ones are deleted. Copies do not appear in the recent list. For more about the kinds of copies, see "Backups, autosave and recovery".
After renaming scenes/groups and editing calendar events, use save so that the changes persist after reopening the .ls.
Downloading a project
Preparing the file is asynchronous and takes three steps.
Step 1. Prepare the download
POST /api/projects/package
Content-Type: application/json
{"collect":true}
collect:true — collect the current project with its resources into a ZIP. collect:false — prepare a copy of the existing .ls from disk, without resources. In the second case, unsaved changes will not be included in the download: first call POST /api/projects/save.
Response 200:
{"token":"opaque-download-ticket"}
The ticket in the example is illustrative; use the response string unchanged. If the project has no file name or is busy with an operation — 409. A failure to start the preparation — 500 with {"code":"pack-failed"}.
Step 2. Wait until it is ready
GET /api/projects/package/{token}/status
Example of a ready response 200:
{"state":"ready","filename":"Facade.zip","sizeBytes":1048576,"code":""}
States: pending — being prepared, ready — can be downloaded, failed — error. Possible code values: missing (no source file), save-failed (the project being collected could not be saved), pack-failed (packing error). An unknown/expired ticket — 404.
Step 3. Download the file
GET /api/projects/package/{token}
The response is a binary file, application/octet-stream; the name is passed in the download header. Save the body to a file. The ticket is single-use and has a lifetime of 30 minutes. While the file is not ready, after it has been downloaded, or for an invalid ticket, 404 is returned. Do not use the download route to check readiness.
Example with the cookie from the connection instructions:
curl --fail-with-body --show-error -b ls4-cookies.txt -c ls4-cookies.txt -o Facade.zip "https://192.168.1.50:443/api/projects/package/REPLACE_WITH_TOKEN"
Uploading a project to the LS4 computer
POST /api/projects/upload?name=Facade.zip Content-Type: application/octet-stream <binary file content>
Accepted are .ls and .zip containing an .ls. The body is the file itself, not JSON, not Base64 and not multipart/form-data. Pass the file name with its extension in the name query parameter; URL-encode spaces and non-Latin characters.
curl --fail-with-body --show-error -b ls4-cookies.txt -c ls4-cookies.txt -H "Content-Type: application/octet-stream" --data-binary @Facade.zip "https://192.168.1.50:443/api/projects/upload?name=Facade.zip"
In PowerShell use curl.exe. Response 200:
{"filename":"C:\\LS4\\Projects\\Facade\\Facade.ls","name":"Facade"}
The path is illustrative: the server itself places the received project in the LS4 projects folder and returns the actual path. The uploaded project is added to the recent list but is not opened automatically. Take filename from the response, check the version if needed and call POST /api/projects/open.
Errors: 409 — another project operation; 400 with code:unsupported — unsupported format; 400 with code:no-project-in-archive — no .ls in the archive; 500 with code:upload-failed — upload/extraction error.