Skip to content

REST Examples

Joseph Mattiello edited this page Nov 13, 2026 · 6 revisions

These examples use curl in a shell. Set ECS_BASE to the origin of your server. The default is http://127.0.0.1:8473 on the server computer. For a remote server, use its configured HTTPS origin.

Check a server

ECS_BASE=http://127.0.0.1:8473
curl --fail --silent --show-error "$ECS_BASE/health"
curl --fail --silent --show-error "$ECS_BASE/api/v1/capabilities"

Read the protocol and features fields before choosing a client flow. The installed Swagger UI and OpenAPI document are available under the same origin. API reference

Browse a library and download content

Set ECS_TOKEN from an authorized session or a device token with read access. Avoid saving the token in shell history. The helper sends the header from standard input.

ecs_read() {
  printf 'Authorization: Bearer %s\n' "$ECS_TOKEN" |
    curl --fail --silent --show-error --header @- "$@"
}

ecs_read "$ECS_BASE/api/v1/browse-libraries"

# Replace LIBRARY_ID with an ID from the previous response.
ecs_read --get "$ECS_BASE/api/v1/browse" \
  --data-urlencode 'libraryId=LIBRARY_ID' \
  --data-urlencode 'category=games' \
  --data-urlencode 'limit=10'

For the next page, use the returned nextCursor as cursor with the same filters and sort. Stop at null. For a managed item, fetch its manifest and use the files' contentPath values. For a scanned source, use source.contentPath. For an asset, use /api/v1/files/ASSET_ID/content. Resolve paths against your configured server origin before attaching authorization.

# Managed game example.
ecs_read "$ECS_BASE/api/v1/items/ITEM_ID/manifest"

# Original scanned source example. Replace SOURCE_ID with the selected source ID.
ecs_read --output game.download "$ECS_BASE/api/v1/sources/SOURCE_ID/content"

For a resumable transfer, keep the ETag and send Range: bytes=<local size>- with If-Range. Append only if the response is 206 and Content-Range starts where your local file ends. On 200, replace the partial file. Inspect Content-Range or send HEAD before retrying a 416. Client integration guide

Browse Atari Jaguar and Jaguar CD

Use the same read token for browsing and artwork. Check features.romDownloadSummaries and features.gameCompanions in the installed server's capabilities response before using the additions.

ecs_read "$ECS_BASE/api/v1/capabilities"

# Use com.provenance.jaguarcd for the CD tab.
ecs_read --get "$ECS_BASE/api/v1/browse" \
  --data-urlencode 'libraryId=LIBRARY_ID' \
  --data-urlencode 'category=games' \
  --data-urlencode 'systemId=com.provenance.jaguar' \
  --data-urlencode 'includeRomDownload=true' \
  --data-urlencode 'limit=10'

Keep the same parameters when passing nextCursor. Uploaded game rows can include the romDownload summary. Fetch a manifest or a scanned disc group only when opening details or importing a game. Scanned games with a cover provide source.artworkPath. Uploaded games with a cover provide previewAsset.id, which can be used with /api/v1/files/ASSET_ID/content.

List and download an optional patch

ecs_read "$ECS_BASE/api/v1/sources/SOURCE_ID/companions"
ecs_read --output translation.bps \
  "$ECS_BASE/api/v1/sources/SOURCE_ID/companions/COMPANION_ID/content"

Use the returned filename and contentPath. Verify sha256 after downloading. When the response includes base.crc32 and base.sizeBytes, check both against the unmodified ROM before applying the patch. A missing base field means the patch header supplies no base checksum. A scanned game can offer a saved patch. Uploaded items report an empty supportedKinds array. Mods and texture packs are reserved for future support.

NAOMI ZIP and CHD sets

NAOMI and NAOMI 2 GD-ROM games use a ZIP primary and its companion directory, for example cart.zip with cart/gdrom.chd. After scanning a matching folder, Games lists the ZIP once. Its groupFileCount and groupError describe the scanned set. Read the group and preserve each returned relativePath under a contained staging directory.

ecs_read "$ECS_BASE/api/v1/sources/ZIP_SOURCE_ID/group"

stage=$(mktemp -d)
mkdir -p "$stage/cart"
ecs_read --output "$stage/cart.zip" "$ECS_BASE/api/v1/sources/ZIP_SOURCE_ID/content" &&
  ecs_read --output "$stage/cart/gdrom.chd" "$ECS_BASE/api/v1/sources/CHD_SOURCE_ID/content"

Replace the IDs with values from the group response and check error and every member's availability first. Register the imported ZIP after all required downloads succeed. Missing previously scanned companions produce an error until they return and the folder is rescanned. A new ZIP without a CHD can be a cartridge game, so Flycast clients should also verify the required GD-ROM filename against their game metadata.

For uploaded items, the v1 manifest can contain two required ROM assets with relativePath values cart.zip and cart/gdrom.chd. Clients verify the manifest hashes and preserve those paths together. Client integration guide

Poll for changes

ecs_read --get "$ECS_BASE/api/v1/changes" \
  --data-urlencode 'cursor=0' \
  --data-urlencode 'limit=50'

Store the returned nextCursor after you process the page. Use that cursor on the next request with the same access scope. Stop draining when the cursor stops advancing and poll again later. Device clients can send excludeOwnDevice=1 to skip their own changes. Sync workstream

Pair a device or manage uploads

  • Device pairing. Create a request with POST /api/v1/device-pairing and the device name. Show the PIN to the owner and keep the challenge secret on the requesting device. After owner approval, redeem the request for a read-only device token. Pairing flow
  • Resumable upload. Create an upload session, send bytes in order with Content-Range, then call the completion endpoint. After an interruption, get the session's saved offset before resuming. Upload recovery
  • Scoped investigation. Create a library-scoped grant with an owner token, then use the returned investigator credential for the permitted /api/v1/investigator operations. The owner reviews proposals in library activity. Investigator guide

Error responses use application/problem+json. Include the request ID when asking for support.

Check file and game lookup activity

Use an owner session. GET /api/v1/library-jobs/overview reports the number of indexed games, saved details, and covers in each folder. An automatic lookup can include jobId, jobState, processed, total, and providerFailures. Follow stoppedJobId when a manual lookup needs attention.

ecs_read "$ECS_BASE/api/v1/library-jobs/overview"
ecs_read "$ECS_BASE/api/v1/library-jobs/JOB_ID"

To add matching evidence for an indexed game, read its selections and replace REVISION in the header with the returned revision. Use null to clear either hint. A changed hint queues another lookup when automatic matching is on and details or the front cover are missing.

ecs_read "$ECS_BASE/api/v1/sources/SOURCE_ID/matches/selections"
ecs_read --request PUT \
  --header 'Content-Type: application/json' \
  --header 'If-Match: "rev-REVISION"' \
  --data '{"title":"Example Game (USA)","systemId":"com.provenance.nes"}' \
  "$ECS_BASE/api/v1/sources/SOURCE_ID/matches/lookup-hints"

Check server update history

Use an owner session with an updater-enabled server. The response shows update mode and channel, the installed and available builds, the last completed check for the selected channel, and recent installations or rollbacks.

ecs_read "$ECS_BASE/api/v1/server/updates"

On Apple Silicon, the notarized nightly desktop app installed in Applications checks at launch and hourly, installs verified desktop updates, and relaunches. Windows and Linux show available desktop installers in Settings → Updates. The server's automatic update mode installs the server package and its bundled web interface. See nightly installation and updates.