Native API v1 #
Rubylight docs › For developers · HTTP API · Control messages · Hardware metrics
The native API lets a paired client go beyond the Moonlight protocol: read the host's capabilities, game library and session state, run session actions, and, with the device's host control permission, read and change the graphics driver's settings (Radeon, or NVIDIA on a host that streams with an NVIDIA GPU). Further features (wake targets, audio processing, files, the image clipboard, shared folders and USB forwarding) are listed in the capabilities response when the host serves them. Version 1 shipped in Rubylight 3.0.0, and Nightjar is the reference client. This page is the contract between the host and Nightjar's nightjar-core; HTTP API has a short summary. Fake-backend host tests and the compatibility matrix in rust/host/src/nvhttp/native_tests/compat.rs cover the contract, and the hardware matrix records the Radeon round trip and crash restore on real hardware.
Ground rules #
- Transport and authentication are reused. Every endpoint is served by the streaming HTTPS service (
HttpsPortfrom/serverinfo, normally 47984), next to/api/hardware-metricsinrust/host/src/nvhttp.rs. The client presents the certificate it paired with, and the host looks it up withauthenticated()(client_by_certificate, enabled andperm != 0). Plain HTTP, the admin console port, Basic auth, cookies and API tokens do not apply. - Moonlight is unaffected.
PROTOCOL_VERSION,/applist,/launch,/resume,/canceland/appassetstay as they are. The only change stock clients can see is one more/serverinfofield, which they ignore, as they already ignore theRustHost*fields. - Nothing new on the stream path. Play and Resume still go through
/launch?appuuid=and/resumewith the usual RTSP setup. This API reads state and runs actions. It never carries video, input or per-packet telemetry. - All responses are
application/json; charset=utf-8withCache-Control: no-store. POST bodies are at most 16 KiB of JSON, except a file upload (see Files). The host parses the raw body and acceptsapplication/json,text/plain(nightjar-core's transport sends it for POST) or no content type. An empty body counts as{}.
Discovery and capabilities #
/serverinfo gets one field:
<NativeApiVersion>1</NativeApiVersion>
| Value | Meaning for the client |
|---|---|
| missing | The host has no native API (Sunshine, Apollo, Vibepollo, Rubylight before 3.0). Show the classic app grid. |
0 |
The host has it, but not for this request: plain HTTP or an unpaired certificate. Pair first. |
1 (or higher) |
The client may call /api/native/v1/capabilities. A higher number means the host also serves newer versions. v1 stays served (see Versioning). |
This follows HardwareMetricsVersion and NetworkPathVersion: nightjar-core's Evidence stores -1 for a missing field, and Feature::NativeApi comes out Supported, needs Pair, or needs UpdateHost when the host is Rubylight but the field is missing. A 404 from any /api/native/v1/ path also means "no native API". The client never decides by version string.
GET /api/native/v1/capabilities
{
"api_version": 1,
"host": { "name": "GAMING-PC", "version": "4.3.3", "unique_id": "5E0F4B1C-..." },
"features": ["library", "session", "session.close_game", "session.launcher", "wake",
"audio.night_mode", "audio.headphone_surround", "session.mic_only",
"session.continue_here", "power.restart", "power.shutdown",
"radeon.read", "radeon.write", "radeon.profile", "session.couch_menu",
"update", "pairing.approve", "clipboard.image"],
"permissions": { "list": true, "view": true, "launch": true, "host_control": false,
"file_upload": false, "file_download": false, "usb": false,
"shared_folders": false, "coop_join": true, "restart_shutdown": false,
"pairing_approve": true }
}
features says what the host implements and has turned on. Clients ignore feature strings they don't know. Only session.couch_menu depends on the calling device; every other feature is the same for every client.
| Feature | Listed | Section |
|---|---|---|
library, session, session.close_game, session.launcher, session.mic_only, session.continue_here |
always | Library, Session |
wake, audio.night_mode, audio.headphone_surround |
always | Wake targets, Audio processing |
power.restart, power.shutdown |
always | Power and update |
neural.frame_generation |
where one of the PC's GPUs is AMD's or NVIDIA's (whether one can run it is in the answer) | Neural Rendering |
radeon.read, radeon.write, radeon.profile |
where the host started its Radeon worker | Radeon state and writes |
files.upload, files.download |
while the host's file_transfer setting is on |
Files |
session.couch_menu |
to a device with View or Launch whose couch_menu setting (host or device) is on |
Session |
coop |
while this host can run Nucleus Co-op sessions | Endpoints |
update |
where the host installs its own updates (an installed service) | Power and update |
pairing.approve |
while pairing is on (enable_pairing) |
Approve a device |
usb |
while usb_forwarding is on and the USB/IP driver is installed |
USB forwarding |
clipboard.image |
while clipboard_image is on (the default) |
Image clipboard |
folders |
while the host shares at least one folder | Shared folders |
stream.dvr |
always on a host with Stream DVR (whether the replay buffer runs is in GET /dvr) |
Stream DVR |
wake.relay |
while away_wake_relay and internet_play are on |
Away wake relay |
stream.doctor_v2 |
for a device with View or Launch | Stream Doctor |
permissionsbelongs to the calling device.list,viewandlaunchare the List apps, View streams and Launch apps bits.host_controlis the device's Host control grant (see The host control permission), andusbandshared_foldersare described with their features.file_uploadandfile_download(bits1 << 18and1 << 19) are missing from hosts before file transfer and decode asfalse.coop_joinis whether the device may join co-op games (Launch apps and its Can join co-op games setting, which follows Launch apps until set), never a permission bit; hosts before 3.0 leave it out, which decodes asfalse.restart_shutdownis the device's Restart and shut down PC grant (see Power and update); older hosts leave it out.pairing_approveis the device's Approve new devices grant (see Approve a device), which is not implied by Host control and is reported apart from it; older hosts leave it out. With a feature listed but its permission off, the client shows the control disabled, with the sentence from the matching error (for example "Turn on Host control for this device in the Rubylight console").
Endpoints #
All paths start with /api/native/v1. "Owner" means the caller owns the current session (see Session).
| Method | Path | Needs | Result |
|---|---|---|---|
| GET | /serverinfo (existing) |
none | NativeApiVersion |
| GET | /capabilities |
paired | Capabilities |
| GET | /library |
List apps | Library |
| GET | /appasset?appid=N&AssetType=2&AssetIdx=0 (existing) |
List apps | Cover image |
| GET | /session |
paired | Session. Details need View or Launch |
| POST | /session/disconnect |
View or Launch, owner | Session (now suspended) |
| POST | /session/end |
Launch, owner | Session |
| POST | /session/close-game |
Launch + host control, owner, or no session | Session |
| POST | /session/continue-here |
View and Launch | Session. Moves the running game's stream to this device (feature session.continue_here). 403 permission_required, 409 no_session, session_busy or host_in_use |
| POST | /session/couch-menu {"open": true} |
View or Launch, a live stream of the caller's own | {"open"}: whether the menu is open now (feature session.couch_menu). 409 no_session, 503 temporarily_unavailable with the reason the stream can't show it |
| GET | /session/suspend |
View or Launch | QuickSuspendStatus (feature session.quick_suspend, see Quick Suspend) |
| POST | /session/suspend, /session/resume {} |
Launch or host control; the session's owner unless host control | QuickSuspendStatus; a refusal is state refused with reason and message. 403 permission_required |
| GET | /session/curtain |
View or Launch | LaunchCurtainSnapshot (feature session.launch_curtain, see Launch curtain) |
| POST | /session/curtain/dismiss {} |
Launch; the device that launched the game | LaunchCurtainSnapshot; 409 not_session_owner for another device, 409 no_session without a curtain |
| GET | /launch, /resume (existing) |
Launch / View | Play and Resume, unchanged |
| GET | /radeon |
View or Launch | Radeon |
| POST | /radeon/settings |
View + host control, owner of a streaming or suspended session |
Radeon |
| POST | /radeon/restore |
View + host control, owner | Radeon |
| GET | /neural?app= |
View | Neural: the game's switches, each with its state, and the job (feature neural.frame_generation) |
| POST | /neural/settings {"app", "switch", "on", "accept_notice"?} |
View + host control, no stream running | 202 Neural. 409 host_in_use while a stream runs, 422 not_writable (the notice, or this PC can't run it) or invalid_value (a switch the host doesn't have), 503 temporarily_unavailable while busy with the game |
| GET | /wake |
List, View or Launch | Wake (feature wake) |
| GET | /wake/relay |
Launch or host control | WakeRelayInfo: the relays, and with Launch the caller's keys (feature wake.relay) |
| POST | /wake/relay/enroll {"action", ...} |
host control; enroll and refresh also from the PC's own network |
RelayEnrolled. 403 forbidden off or not on the PC's network, 404 not_found for a relay that is not enrolled |
| GET | /audio |
View or Launch | Audio (features audio.night_mode, audio.headphone_surround) |
| POST | /audio/settings |
View or Launch, owner of a streaming or suspended session |
Audio |
| GET | /files |
Download files, File transfer on | FileList |
| POST | /files?name= |
Upload files, File transfer on | 201 Uploaded |
| GET | /files/content?name= |
Download files, File transfer on | The file's bytes |
| GET | /folders |
a folder grant | FolderList (feature folders) |
| GET | /folders/{id}/entries?path= |
a grant for id |
FolderEntries |
| GET | /folders/{id}/content?path= |
a grant for id |
The file's bytes |
| PUT | /folders/{id}/content?path= |
a write grant for id |
201 Uploaded |
| GET | /coop |
List apps | Coop: the co-op games and the co-op sessions, with this device's seat, joinable and refusal; player names only for a device that may join co-op games or holds a seat (feature coop; 503 with the reason while Nucleus Co-op cannot run) |
| GET | /power |
paired | Power: Restart and Shut down, each with available and the reason when not, a single-use token, wake_from_off, last_refusal and last_refusal_unconfirmed (features power.restart, power.shutdown) |
| POST | /power/restart, /power/shutdown {"token": "..."} |
Restart and shut down PC, nothing running | 202 {"action"}, then the host asks Windows. 403 permission_required, 409 host_in_use or token_expired |
| GET | /update |
paired | Update: current_version, latest_version, phase, install_supported, error, waiting_for, install_now (feature update) |
| POST | /update/install |
host control, no other device streaming | 202 Update. 409 host_in_use or update_unavailable |
| GET | /pairing/requests |
approve new devices or host control | PairingRequests: the devices waiting to pair, never a certificate (feature pairing.approve, listed while pairing is on) |
| POST | /pairing/approve {"id", "pin"} |
approve new devices or host control | PairingApproved {"name"} once the device has paired. 403 permission_required, 404 not_found, 409 pairing_ended, pairing_cooldown or pairing_unconfirmed, 422 wrong_pin or invalid_value |
| POST | /pairing/deny {"id"} |
approve new devices or host control | PairingRequests: those still waiting. 404 not_found |
| POST | /coop/join {"session": N} |
Launch; Can join co-op games to take another device's free slot | Joined {"session", "slot", "app_id"}: the slot is held until this device launches app_id. 403 permission_required, 409 no_session or coop_refused, 503 temporarily_unavailable while Nucleus Co-op cannot run |
| GET | /stream/doctor |
View or Launch | DoctorSnapshot (feature stream.doctor_v2, see Stream Doctor) |
| POST | /stream/doctor/apply {"action", "remedy", "trial_id"?} |
Launch, the stream's owner | DoctorSnapshot after it. 409 no_session or not_session_owner, 422 not_writable (message says why) or invalid_value |
| GET | /usb/tunnel |
usb, a token from 0x553A |
101, then USB/IP (feature usb, see USB forwarding) |
Permission bits are the existing ones: List 1 << 24, View 1 << 25, Launch 1 << 26, Upload files 1 << 18, Download files 1 << 19. Host control and Approve new devices are separate per-device flags (see below).
Library #
GET /api/native/v1/library
{
"revision": "9f2c41d0",
"games": [
{
"install_id": "c6f1a9a4-4b51-5f43-9d0b-7a2b1c2d3e4f",
"app_id": 1093052211,
"title": "Dota 2",
"game_id": "steam:570",
"store": { "source": "steam", "id": "570", "name": "Steam" },
"installed": true,
"running": false,
"artwork": {
"cover": "/appasset?appid=1093052211&AssetType=2&AssetIdx=0",
"version": "a41c09e2"
},
"last_played": 1788025796,
"playtime_minutes": 5412
},
{
"install_id": "8d4b3f55-0c2e-4f8a-9a61-2f1c6f0e9b17",
"app_id": 881448767,
"title": "Desktop",
"game_id": null,
"store": null,
"installed": null,
"running": true,
"artwork": { "cover": "/appasset?appid=881448767&AssetType=2&AssetIdx=0", "version": "0c1d2e3f" }
}
]
}
The entries are the host's configured apps (h.apps), in console order. The synthetic Remote session tiles (remote::identify) are left out because session actions replace them. There are three ids, each with one job:
| Field | Stable across | Source | Use |
|---|---|---|---|
install_id |
renames, reorders, host restarts | the app's uuid in apps.json. Imports set it to library::Game::uuid(): Steam's canonical UUID, otherwise UUIDv5 of rubylight:library:<source>:<id> |
The client's primary key per host. Launch with /launch?appuuid= |
game_id |
hosts | <source>:<store id> from launcher-source/launcher-id (or steam-id); a Playnite game takes the id of the one installed game of its library plugin's launcher with the same title; null for manual apps |
Merges one title across paired hosts in the client's library, and keys favourites and per-game profiles |
app_id |
nothing (it is CRC32 of the name unless pinned) | App::id() |
Only for /appasset and old GameStream calls |
store.sourceis a string, not a closed enum, so stores added later don't break v1 clients. In 3.0 it is one ofsteam,epic,battlenet,ea,ubisoft,gog,microsoft(library::Source::key;microsoftcovers Microsoft Store and Xbox PC games), andnameisSource::name().microsoft(Microsoft Store and Xbox PC games,rust/windows/io/src/library/store.rs): the host lists the packages registered for the signed-in user (PackageManager, skipping frameworks, resources and bundles) and takes the ones with aMicrosoftGame.configin the package folder or itsContentfolder, which is what a GDK game ships; it also reads<drive>:\XboxGames\<title>on fixed drives for a game on disk that no package registers (listed, with the reason, and not launchable).idis the config's identity name, the game is started withshell:AppsFolder\<package family>!<application id>(the Start menu's way; the application id is the config'sExecutableId, or the manifest application that runs the same program), and the cover is the config'sSquare150x150Logo. Console-only titles (no executable for PCs) are left out. It starts the package's own entry point and bypasses no licence, sign in or Xbox app check. A Store app that is not a GDK game (a UWP game with noMicrosoftGame.config) cannot be told from any other app and is not listed; add it by hand. A failure to list packages shows as a scan error on the source, never as an empty library.installed:trueorfalsefrom the host's last launcher scan (butterpollo_win_io::library::discover),nullfor manual apps or when no scan has run. The host caches the scan and refreshes it in the background at most every 5 minutes and after console imports. A library request never waits for a scan.running: the app is the host's current game (remote_game), whoever owns it.artwork.coveris a path on the same HTTPS origin and is fetched with the same certificate. It is absent (andversionempty) when the app has no cover of its own, where/appassetwould send the host's placeholder; clients show the title instead.artwork.versionchanges when the image file changes (a hash of its path, size and mtime), so clients can cache covers offline. v1 has covers only.last_played: when the game was last played, in seconds since the epoch, from its store: Steam'sLastPlayedfor a Steam game, Playnite's last activity for an app linked to a Playnite game (the later of the two when both say).0means the store says never played. The field is absent when no store says (a manual app, a store that keeps no such time, Steam history that couldn't be read, a Playnite time that doesn't parse, before the first scan) and from older hosts; clients show nothing then. It comes with the cached launcher scan, so it can be up to 5 minutes old.playtime_minutes: how long the game has been played, in minutes, from its store: Steam'sPlaytimefor a Steam game, Playnite's play time for an app linked to a Playnite game (the longer of the two when both say, since Playnite imports the store's time rather than adding to it).0means the store says never played. Absent when no store says (a manual app, a store that keeps no such time, Steam history that couldn't be read, a Playnite plugin that sent none, before the first scan) and from older hosts. Likelast_played, it comes with the cached launcher scan.collections: the names of the Steam collections or Playnite categories the game is in, absent when none. Steam's come from its cloud-storage file, read only: that of the accountloginusers.vdfmarksMostRecent, or where it marks none or that account has no file, the one Steam wrote last of any account. When the file can't be read, the last collections it gave stay for two more scans at most; the third failed scan in a row drops them. At most 20 names a game, 100 bytes a name and 1 MiB of JSON for all of a scan's names; the host logs what it cuts. Part ofrevision.revisionis a hash of the whole response body withoutrunning,last_playedandplaytime_minutes. Clients refetch when it changes.
Session #
With the feature session.mic_only, /launch takes input_only=1&rlMicOnly=1 with an appid that names no remote session action (0 names no app): a microphone-only session. Remote session tiles (Resume, Remote Input, the running game) are resolved before this flag and refused with it, as is /resume. It needs Launch apps but not the host's input-only mode (enable_input_only_mode); a device that may only view streams cannot start one. It runs no app, device commands or streaming adjustments, has no video or audio stream at all (the PC's sound stays on the PC), and refuses all input. The device's microphone plays on Steam Streaming Microphone as in a stream, with the same level clamp: the host keeps that device's recording level at or below 0 dB while it plays. One microphone plays at a time; another device's waits until the playing one has been quiet for a second. Meanwhile GET /session answers that device with "microphone_busy": true (absent otherwise; Nightjar asks every few seconds during Microphone only and says "Microphone in use on another device"), and the host console shows a microphone_busy warning on its session. It is an input-only session otherwise (/session and the couch menu treat it as one) but never holds Remote Input, and a new one from the same device replaces it.
States: idle → preparing → launching → streaming → suspended → stopping → idle.
GET /api/native/v1/session
{
"revision": 42,
"state": "suspended",
"owner": "you",
"app": { "install_id": "c6f1a9a4-...", "app_id": 1093052211, "title": "Dota 2" },
"game_running": true,
"since_unix_ms": 1792303200000,
"suspended_until_unix_ms": 1792310400000,
"actions": [
{ "id": "resume", "allowed": true },
{ "id": "disconnect", "allowed": false, "reason": "not_streaming" },
{ "id": "end", "allowed": true },
{ "id": "close_game", "allowed": false, "reason": "host_control_required" }
]
}
| State | Meaning |
|---|---|
idle |
No session. game_running can still be true after End session |
preparing |
Launch accepted: displays and integrations are being prepared (display_session::prepare_stream) |
launching |
App commands are running, and the stream is not up yet |
streaming |
Video is flowing to the owner |
suspended |
The owner disconnected. The game and the virtual display stay alive until suspended_until_unix_ms (the reconnect grace period) |
stopping |
Teardown is in progress. Repeating an action is safe |
owner is none, you or other_device. Other devices see state and owner only: app is null and every action is refused with not_session_owner, the same scoping /serverinfo uses for currentgame. Without View or Launch permission, app is null as well. The host always names the owner of a session that isn't idle: native::session_view asserts it in debug builds, since without an owner every caller would read as another device.
The host keeps this state explicitly: butterpollo_core::session_state::Machine, fed by rust/host/src/session_control.rs. It is a projection of what the host observes plus the transitions the launch and teardown code report, so stock Moonlight flows (/launch, /resume, /cancel, RTSP and ENet disconnects, "Quit app") run unchanged and only record what they do.
| From | To | When |
|---|---|---|
idle |
preparing |
/launch or /resume of a stream is accepted |
preparing |
launching |
the app's own commands start |
launching |
streaming |
the client connects (RTSP Play) |
launching |
suspended or idle |
the launch fails, or nobody joins within 30 s. It returns to what still runs |
streaming |
suspended |
the stream ends (client disconnect, Disconnect action) while the game and its display remain |
streaming |
idle |
the stream ends and no game, or no kept display, remains |
suspended, streaming |
preparing |
the owner's /resume is accepted (a stream still running is superseded) |
stopping |
preparing |
a /launch or /resume is accepted during a teardown. It takes over the state, and the teardown ending leaves it alone |
any but preparing, launching |
stopping |
End session, Close game, tray Stop, or the grace period running out |
launching |
stopping |
stock /cancel while the client has not joined yet (it waits for the launch call to finish first) |
stopping |
idle, suspended, streaming |
the last teardown ends: what still runs decides |
Teardowns can overlap (End session while the grace period runs out, /cancel during either). The state stays stopping until the last one has ended. A disconnect or a teardown ending never overwrites a launch in preparing or launching.
The grace period is the existing disconnect delay (Config::display_disconnect_delay): dd_config_revert_delay (3 s) when the display layout is exclusive (unless dd_hold_layout_while_paused is on) or dd_disconnect_behavior is restore, otherwise dd_paused_virtual_display_timeout_secs (2 h; 0 never expires, and suspended_until_unix_ms is then absent). When it runs out, the host ends the session as End session does, and the game keeps running (idle with game_running: true).
The host writes session.json in the profile directory while a session is not idle and deletes it when the session ends. A thread of its own writes the file (no fsync, retrying a failed write or delete every 2 s), so no launch or request waits for the disk. One found at startup means the host stopped mid-session: it is deleted, logged, and shown as the warning session_interrupted for an hour. The host starts idle, so recovery is safe to repeat. Display and audio changes of the dead host come back through the existing display_recovery journals.
Actions. Every action is an empty POST. It is idempotent and returns the Session object after the action has started, often in stopping. disconnect, end, close_game and resume try the existing launch_transition lock and answer session_busy when a launch holds it (so a Disconnect cannot remove the fresh launch of the same device), and end and close_game also when the state is preparing or launching. The exception is the caller's own launch, still running its preparation: end (and close_game, for a launch of either of the device's screens) stops it, ending a preparation command that still runs and undoing the ones that finished, waits up to 30 s for it to let go of the lock, and then acts; a stopped launch that was the whole session answers as done. Moonlight's /cancel does the same for the device's launch. They serialize with launches without blocking a request for minutes. end and close_game wait up to 5 s for the stopped streams, so a handler runs them in spawn_blocking.
| Action | Effect | Game | Virtual display | Radeon changes |
|---|---|---|---|---|
resume |
The client calls the existing /resume, and the host reattaches the suspended session. No native endpoint |
kept | reused | kept |
disconnect |
Stops the owner's transport now instead of waiting for a timeout. State becomes suspended |
kept | kept for the grace period | kept |
end |
Tears down the owner's stream and the owner's kept display (request_stop plus display release). Streams and displays of other devices keep running |
kept running | released | restored |
close_game |
Like end, plus ends the game process (stop_app, with its undo commands and exit timeout) |
ended | released | restored |
When the grace period of a suspended session runs out, the host behaves as for end. A disconnect never ends the game. close_game also works with no session, when game_running is true, for a caller with Launch and host control. That closes a game left behind by End session. Stock Moonlight's /cancel is unchanged: it stops every stream and closes the game with Launch permission alone.
Clients poll /session about every 2 s while a home or detail screen is visible, and not at all while streaming. The overlay knows the stream is up.
Continue here (session.continue_here). With this feature, the Session of a caller with List or View names the other device playing: "playing_on": { "device": "Living room TV", "app": { ... } }, absent when nobody else plays or the game isn't known. POST /session/continue-here (View and Launch, the bits that already let a device replace the running game after confirming) gives that game to the caller. It keeps the launch lock while it:
- writes
moved_tofor each device that loses a plain stream or a kept display, so its ownGET /sessionreads"moved_to": { "device": "Living room TV", "since_unix_ms": 1792303212000 }for two minutes, or until it streams again, presses Continue here itself, the press fails or the game ends. Without List or Viewdeviceis empty: the device learns that its stream moved, not where to, and a client says "another device"; - makes the caller the game's owner, so the displaced device's
/serverinfono longer shows the game as its own and any recovery that device still runs stops at its running-game check; - stops the other devices' plain Stream sessions through the same path as
disconnect: nothing closes the game and no undo command runs; - logs one line naming both devices.
The caller then starts the normal /resume. Nucleus co-op and background sessions, Input-only and Remote Monitor roles and WebRTC guests' seats are never touched. A game that runs as a background session, or no running game at all, answers 409 no_session; a WebRTC stream of another device with guests seated answers 409 host_in_use and changes nothing; a launch the caller could not make (a background mode the running game refuses) answers 409 host_in_use with the reason and changes nothing; a launch in flight answers 409 session_busy. A second device pressing at the same time also gets session_busy, until the winner's stream runs or 15 s pass; a launch still pending from the winner holds the press longer, up to 60 s (CLAIM_LIMIT). The winner pressing again changes nothing and answers as the first press did. A press belongs to its game: when that game has ended, the press ends too. While a press is live, only its winner can close the game: the others get session_busy.
A device that does not own the game may join it with /resume beside the owner. That /resume answers 409 when another device holds a plain WebRTC stream, which a Moonlight stream would end, or when its appuuid names another game than the running one; a request without appuuid, and the owner's own, resolve to the running game. It never starts a game.
If the winner never connects, or its launch fails, which ends the press at once, the game goes back to its previous owner and keeps running, and the moved_to notes go. A game set to close on disconnect keeps running during the press and for a window afterwards, for the previous owner to come back: 60 s, whatever the disconnect grace (display_disconnect_delay) says. A stream that runs closes the window, so leaving it closes the game as usual, and so does that device's End session. A client can tell a failed press from a move that happened: moved_to is gone and "owns_game": true is back. That field says the running game is the caller's, with or without a session; it is absent otherwise, so a note that merely ran out, or a game that ended, does not read as the game coming back. Any other device that press displaced reads "press_failed": true instead, for two minutes, until the press's stream arrives after all, that device starts a stream, or the game ends: nothing moved, and the game is someone else's. If a stream arrives after its press ended and the previous owner has not streamed or launched since, the game becomes that device's and the previous owner reads moved_to.
The display: each displaced device's kept virtual display stays until the new stream runs and is then released at once, instead of waiting out the grace period, also on a layout with a shorter grace of its own; Windows moves the game's windows to the display that remains. Releasing it earlier would flash the monitors twice and change the mode twice. If the press fails the display's grace starts over; if the winner's stream still arrives within the two minutes after that, it releases the display as it would have. The new device's stream gets its own display at its own mode, as any stream does. A displaced Moonlight client just sees its stream end.
A stream beside another device's running game (the prompt's Stream here too, or a plain /resume of that game) shares the virtual display the game is on under virtual_display_mode = per_client; its own display would show an empty desktop. It takes the display in the mode it has and the encoder scales the picture to the stream's size. It never changes that display's mode, HDR or scale, so the game plays on undisturbed. A display slower than the stream asked for, or with other HDR, fails nothing: the stream runs and its mode warnings say display_refresh or display_hdr, which only a client that reads them shows; the host logs a different HDR as well. An HDR stream of an SDR display carries the SDR picture without HDR highlights.
Only asking for the game shares: /resume, or a /launch of a Resume tile. Any other /launch, and Desktop, keep a display of their own, except a device coming back to a display it made that the game is still on, which shares it instead of failing. Two limits leave the second device an empty desktop. A game no stream's virtual display shows, one started from the console or playing on a physical monitor, has no display to share, under exclusive too. And under extended the shared display is the one the owner's stream set up, not where the window really is: a game that opened on a physical monitor gives the second device that display, at the owner's mode, without the game on it.
Launcher prompt (session.launcher). When a launched game does not show up and a Steam, Epic Games, EA app or Ubisoft Connect window is up instead, the owner's Session carries a launcher note:
"launcher": { "launcher": "steam", "kind": "update", "window_title": "Updating Dota 2", "since_unix_ms": 1792303212000 }
kind is update (an update, install or download is in the way), sign_in (a sign in, a verification code or Steam Guard) or prompt (a launcher window in front for more than 20 s with a title that names nothing; a client shows window_title). An unknown kind reads as prompt. The host reads the visible windows every 2 s while the game has not shown up (rust/host/src/launcher_watch.rs, classifier in rust/core/src/launcher_prompt.rs). A note needs two looks in a row, goes when two looks in a row find no launcher window, and goes at once when the game's process or window appears. It is a note, not a state: the session state does not change, and the host never clicks or types into a launcher. Only the owner sees it, and an app that starts no program of its own (a desktop tile) or only opens a launcher (Steam Big Picture, a bare steam.exe) is not watched, because the launcher is the app. A Playnite-started game counts as seen when Playnite reports it running. A windowed game that the host cannot tell from the launcher can leave a note up until the launcher window closes or the watch's 10-minute limit passes, after which the host stops looking. The fixture is client/protocol/native-api/tests/fixtures/session_launcher.json.
Radeon profile (radeon.profile). An app with radeon-profile set (see Radeon settings per game) puts radeon_profile in the owner's Session: profile (competitive, smoothness, quality or custom), state (applying, applied or failed), settings (the ids written, which go back when the session ends) and, when something was left out or failed, message. A failed profile does not stop the launch: the game runs without it, the host log names the setting with ERROR, and the session shows failed with the reason. The profile goes through the same journaled path as POST /radeon/settings and is restored by the same session-end hooks. It needs no host_control on the device: the app's config is the consent.
Guests from other devices (session.guests). Listed while the host's guest_join is not off (Guests from other devices). A paired device that resumes the running game of another device, or launches its app, is that device's guest: its /launch or /resume waits while the owner decides (up to 45 s under ask), then succeeds or fails with the reason as its status_message. The routes below need View or Launch. Every caller reads the list; answering and managing need the owner device or Host control, otherwise 409 not_session_owner.
| Method | Path | Body | Result |
|---|---|---|---|
| GET | /session/guests |
SessionGuests | |
| POST | /session/guests/approve |
{"id", "permission"?, "seconds"?} |
SessionGuests. permission defaults to guest_permission; seconds is 300 to 604800, or absent until the game ends |
| POST | /session/guests/deny |
{"id"} |
SessionGuests |
| POST | /session/guests/kick |
{"id"} |
SessionGuests. Ends the guest's stream; it may ask again |
| POST | /session/guests/revoke |
{"id"} |
SessionGuests. Ends the guest's stream and refuses that device's joins until the game ends |
| POST | /session/guests/permission |
{"id", "permission"} |
SessionGuests |
| POST | /session/guests/keyboard-mouse |
{"id"} or {"id": null} |
SessionGuests. Hands the keyboard and mouse to a guest, or back to the owner |
Invites to play over the internet (session.guest-invites). Listed while Allow pairing (enable_pairing) is on (Invite a friend over the internet). Making, listing and taking back invites needs Approve new devices or Host control, otherwise 403 permission_required.
| Method | Path | Body | Result |
|---|---|---|---|
| GET | /session/guests/invites |
GuestInvites | |
| POST | /session/guests/invites |
{"permission"?, "seconds"?} |
{"id", "link", "expires", "permission"}. permission defaults to guest_permission and is lowered to the input the caller holds; seconds is 300 to 604800, a day without it. 503 temporarily_unavailable while pairing is off; 422 invalid_value for another lifetime or with 8 unused invites |
| POST | /session/guests/invites/revoke |
{"id"} or {"uuid"} |
GuestInvites. Takes back an unused invite, or unpairs a device paired from one |
GuestInvites is {"links": [{"id", "permission", "created", "expires"}], "friends": [{"uuid", "name", "permission", "until"}], "max_links", "default_seconds"}; the link itself is answered only once, when it is made. A device paired from an invite holds List and View plus its permission's input, never Launch; its /launch or /resume may only join a game another device plays, always asks the player, and otherwise fails with "You can only join a game someone is playing on this PC".
SessionGuests is {"policy", "default_permission", "manage", "you", "owner", "max_guests", "version", "keyboard_mouse", "guests": [{"id", "name", "permission", "streaming", "since", "expires"}], "waiting": [{"id", "name", "seconds_left"}]}. A permission is view, controller or controller-keyboard-mouse; any other is 422 invalid_value. you is the caller's own guest id, keyboard_mouse the guest holding them (null: the owner), version changes with every change, and since and expires are Unix seconds. An id no longer there is 404 not_found. Clients poll it about every 2 s while streaming, only while the feature is listed. When the host ends a guest's stream (kick, block, expiry, the game ending), the device's /serverinfo RustHostLastFailure says why, for example "The player removed you from the game".
Couch menu (session.couch_menu). POST /session/couch-menu with {"open": true} opens the menu the host draws into the caller's own live stream, and {"open": false} closes it (Couch menu). It is idempotent and answers {"open"}, whether the menu is open now. The body takes no other field. Without a live stream of its own the caller gets 409 no_session; a stream that can't show the menu (the menu off for it, a stream too small, or its control stream not connected yet) gets 503 temporarily_unavailable with the reason. The feature is listed only to a device with View or Launch whose couch_menu setting, the host's or its own, is on.
Radeon state and writes #
GET /api/native/v1/radeon
{
"revision": 7,
"state": "configurable",
"host_control": true,
"writable_now": true,
"gpus": [
{
"id": 11520,
"name": "AMD Radeon RX 7900 XT",
"driver": "25.9.1",
"settings": [
{ "id": "anti_lag.enabled", "group": "anti_lag", "kind": "toggle",
"state": "configurable", "value": true },
{ "id": "chill.max_fps", "group": "chill", "kind": "integer", "unit": "fps",
"state": "configurable", "value": 144, "range": { "min": 30, "max": 300, "step": 1 },
"restore": { "original": 120, "written": 144 } },
{ "id": "afmf.enabled", "group": "afmf", "kind": "toggle",
"state": "needs_external_setup", "value": false,
"reason": "external_setup", "message": "Turn on AMD Fluid Motion Frames once in AMD Software: Adrenalin Edition." },
{ "id": "rsr.enabled", "group": "rsr", "kind": "toggle", "state": "unsupported" },
{ "id": "image_sharpening.sharpness", "group": "image_sharpening", "kind": "integer", "unit": "%",
"state": "temporarily_unavailable", "reason": "driver_busy", "message": "The driver is busy. Try again in a moment." }
]
}
]
}
The five states. A client draws exactly what the state says and never shows a toggle that does nothing:
state |
value |
Client shows |
|---|---|---|
configurable |
present | An editable control (if writable_now) |
read_only |
present | The value, not editable. The host's driver probe found it readable but not writable on this driver |
needs_external_setup |
optional | The value if present, plus message saying what to do on the PC |
unsupported |
absent | Greyed out with "Not supported on this GPU or driver", or hidden |
temporarily_unavailable |
absent | Greyed out with message. The client re-reads later |
- The top-level
stateapplies the same five states to the whole panel. For example,temporarily_unavailablewithreason: "adlx_unavailable"means ADLX failed to load, andgpusis then empty. - A host that streams with an NVIDIA GPU serves the same endpoints with the NVIDIA driver's settings, whose ids start with
nvidia_(nvidia_low_latency.mode,nvidia_frame_rate_limit.fps,nvidia_vsync.mode,nvidia_power.mode,nvidia_texture_filtering.quality,nvidia_anisotropic_filtering.mode,nvidia_smooth_motion.enabled). It chooses the driver once at start, from the GPU it streams with. Its panel-wide reasons areno_nvidia_gpuandnvapi_unavailable, where a Radeon host saysno_amd_gpuandadlx_unavailable. The built-in presets list both drivers' settings, and the host writes only its own driver's. - A setting appears as
configurableorread_onlyonly if the host's probe of the installed driver proved it (see the hardware matrix). Settings from the catalogue that the probe didn't cover areunsupported. The catalogue ids are<group>.<field>, for exampleanti_lag.enabled,chill.enabled,chill.min_fps,chill.max_fps,boost.enabled,boost.min_resolution,image_sharpening.enabled,image_sharpening.sharpness,enhanced_sync.enabled,frame_rate_target.enabled,frame_rate_target.fps,afmf.enabled,rsr.enabled,rsr.sharpness,vsync.mode. Clients render ids they don't know generically fromkind,range,optionsandunit. kindistoggle(bool value),integer(withrange) orchoice(string value, withoptions: [{"value": "...", "label": "..."}]).gpus[].idis the sameidthat/api/hardware-metricsreports. v1 lists the GPU the host encodes on.host_controlis the caller's flag.writable_nowis true only when the caller has host control and owns astreamingorsuspendedsession. A GPU'sidis the signed ADLX id that/api/hardware-metricsreports, so it can be negative; a write naming an id the host does not list isnot_found. Reads go through the host's ADLX worker thread (thetelemetry.rspattern), are cached for 1 s, and never run on a stream thread.
Writes.
POST /api/native/v1/radeon/settings
{ "gpu": 11520, "changes": [ { "id": "chill.enabled", "value": true }, { "id": "chill.max_fps", "value": 144 } ] }
- The host validates the whole request first: every id exists and is
configurable, every value has the right type and lies within its range and step. Otherwise it changes nothing and answersinvalid_valueornot_writable, naming the setting. - Before a setting changes for the first time in a session, the host writes its original value to the journal on disk and syncs the file. Later writes in the same session keep that first original.
- The host applies the changes in order. If the driver refuses one, the host restores the ones from this request it has already applied and answers
driver_rejectedwith that setting's id. - On success the host re-reads the settings and returns the full Radeon object. The driver's read-back is the truth, so dependent settings the driver changed show up too.
Restore on session end. Writes are global to the driver, and the journal ties them to the session:
- The host restores at End session, Close game, grace expiry, unpair or disable of the owner, host shutdown, on
POST /radeon/restore, and at the next host start if a journal survived a crash. It does not restore at Disconnect: a suspended session keeps its settings through a resume, and they are restored when the session ends. - A journaled setting is restored only if its current value still equals the value the host wrote. If someone changed it on the PC in the meantime, the local change wins, and the host drops the entry and logs it.
- A restore that fails is loud: it goes into the host log with the setting id, the entry stays in the journal, the host retries at the next start, and
GET /radeonkeeps showingrestorewithmessage. - While a change is pending,
restore: { "original", "written" }is present, so the overlay can say "Goes back to 120 fps when you end the session".
Wake targets (wake) #
Status: served since 3.0.0 (design A.2, A.3 and A.6). Types in rubylight_native_api::wake, fixture client/protocol/native-api/tests/fixtures/wake.json.
GET /api/native/v1/wake
{
"revision": 1,
"primary": "02:7C:16:B4:13:4F",
"targets": [
{
"mac": "02:7C:16:B4:13:4F",
"kind": "ethernet",
"connected": true,
"route": true,
"broadcasts": ["192.168.4.255"],
"state": "ready",
"checks": [
{ "id": "wake_enabled", "state": "ok" },
{ "id": "magic_packet", "state": "ok" },
{ "id": "magic_packet_only", "state": "warning" }
]
}
],
"system": {
"sleep": "s3",
"modern_standby": false,
"hibernate": false,
"fast_startup": "inactive",
"shutdown_wake": "firmware_unknown"
},
"idle_sleep": { "state": "off", "minutes": 0, "reason": null }
}
- Any paired device with List, View or Launch can read it. Paired clients already see
<mac>in/serverinfo; this adds the PC's other physical adapters. Virtual and VPN adapters are never listed. primaryis the MAC/serverinforeports to this client, in the sameaa:bb:cc:dd:ee:ffformat, chosen by the host's MAC policy. It isnullwhen no physical adapter is connected (/serverinfothen sends zeros).targetslists every physical adapter, connected or not.kindisethernetorwifi.routeis true for the adapter this request came in through; everyrouteis false when the client came through a VPN or another virtual adapter, which a sleeping PC can't be woken through without a relay on its LAN.broadcastsare the adapter's IPv4 subnet-directed broadcasts.targets[].state:ready,needs_setup(a wake setting is off; an administrator'sPOST /api/power/wake/fixfrom the console changes it),unknown(the settings could not be read, for example because WMI refused access) orexperimental(Wi-Fi).checks[].id:wake_enabled(Allow this device to wake the computer),magic_packet(*WakeOnMagicPacket),magic_packet_only,wake_on_pattern(information only),modern_standby_magic_packet(Modern Standby PCs whose adapter has it) andshutdown_wake(a vendor's wake from shutdown, information only).checks[].state:ok,warning,errororunknown.system.sleepiss3ornone.fast_startupisactive(on, with hibernate available),inactive(on, but hibernate is off, so it has no effect) oroff.shutdown_wakeis alwaysfirmware_unknown: waking from shutdown depends on firmware settings Windows can't read.idle_sleepis the host's own sleep after idle:stateisoff,armed,blockedorunsupported,minutesissleep_after_idle_minutes(0 when off), andreasonsays what blocks it or why it is unsupported (nullotherwise).- Clients send to every target's MAC and every
broadcastsaddress, on top of the serverinfo MAC and their own interfaces' broadcasts. Unknown fields are ignored, and unknownkind,state,sleep,fast_startupandshutdown_wakevalues decode asUnknown. A client shows a check id it doesn't know by itsstate. - The endpoint only reads. NIC settings are changed only with consent, from the installer or the admin console, never through this API.
Away wake relay (wake.relay) #
Status: served since 6.5 (design). Types in rubylight_native_api::wake_relay, fixtures wake_relay.json and wake_relay_enrolled.json. Serverinfo carries <AwayWakeRelayVersion>1</AwayWakeRelayVersion> while it is on; a client offers the relay only with both.
A sleeping PC cannot answer from the internet. An always-on paired device on its network (a relay: Nightjar's desktop client on a mini PC or server) enrolls while the PC is awake, and a paired device that is away asks it over a punched Traverse path to send the PC's magic packets (Play over the internet).
GET /api/native/v1/wake/relay
{ "enabled": true, "target_id": "<the PC's uniqueid>", "epoch": 1,
"relays": [ { "id": "<relay device id>", "name": "Living room NUC", "enrolled_unix": 1795000000, "last_seen_unix": 1795000300 } ],
"bundle": { "target_id": "<the PC's uniqueid>", "epoch": 1, "device": "<caller device id>",
"relays": [ { "id": "<relay device id>", "name": "Living room NUC", "secret": "<64 hex digits>" } ] } }
- A device id is the SHA-256 of the device's certificate (trimmed PEM), in hex.
bundleis there only for a caller with Launch apps. Each relay'ssecretis the caller's own key for that relay (HKDF of the relay's secret, the PC's id, the caller's id and the epoch); the caller signs its wake requests with it, and the relay derives it again. With the feature off the answer is{"enabled": false}with no relays and no bundle.
POST /api/native/v1/wake/relay/enroll
{ "action": "enroll", "name": "Living room NUC" }
{ "assignment": { "target_id": "<the PC's uniqueid>", "target_name": "Desktop", "epoch": 1,
"secret": "<64 hex digits>", "macs": ["10:7B:44:00:00:01"], "broadcasts": ["192.168.4.255"],
"address": "192.168.4.20", "http_port": 47989,
"devices": ["<device id>"], "refresh_seconds": 300 },
"relays": [ ... ] }
actionisenroll(nameoptional, the device's name otherwise),refresh,leave,revoke(relay: a relay id) orrotate_epoch. Every action needs Host control.enrollandrefreshalso need a caller on one of the PC's own private subnets (not through a tunnel);refreshnever enrolls, so a revoked relay gets 404 and stops. Onlyenrollandrefreshreturn anassignment.macsandbroadcastsare the PC's physical adapters' (at most four each, private broadcasts only),addressis the PC's own address on the relay's subnet, anddevicesare the paired devices that are turned on and may launch apps. A relay refreshes everyrefresh_seconds, which is how an unpaired device, a revoked relay or a rotated epoch reaches it.- At most eight relays.
rotate_epochgives every relay a new secret. Each relay takes it, and drops the old device keys, at its nextrefresh(withinrefresh_secondswhile the PC is awake); a device gets its new keys fromGET /wake/relay.
Audio processing (audio.night_mode, audio.headphone_surround) #
Status: served (3.0.0, design B.3, B.4 and B.6); Nightjar's Control Center shows both switches on its Audio page. Types in rubylight_native_api::audio, fixtures audio.json and audio_write.json.
GET /api/native/v1/audio
{
"revision": 3,
"settings": [
{ "id": "audio.night_mode", "group": "sound", "kind": "toggle",
"state": "configurable", "value": true },
{ "id": "audio.headphone_surround", "group": "sound", "kind": "toggle",
"state": "configurable", "value": true,
"reason": "next_stream", "message": "Headphone surround applies from the next stream." }
]
}
- The settings are Radeon
Settingobjects,kind: toggle,group: sound, with the idsaudio.night_modeandaudio.headphone_surround. Each appears only when the host lists its feature. valueis the caller's session choice, resolved highest first: a live change in this session, the session's launch parameter, the app, the device, then the host.revisiongoes up with every change.- A
reasonwithmessage(plain English) is a note on a setting this stream doesn't apply. The owner can still write it, so it staysstate: configurablewithvalue, the choice. Only a setting the caller can't write istemporarily_unavailable, without avalue: in 3.0 that isno_session. The reasons:
reason |
Meaning |
|---|---|
no_session |
The caller has no streaming or suspended session. The setting is temporarily_unavailable with no value |
client_surround |
The client asked for 5.1 or 7.1 and renders its own speakers (headphone surround only) |
game_only_audio |
Capture uses Game only audio, which is stereo (headphone surround only) |
stereo_endpoint |
The PC's playback device is stereo (headphone surround only) |
muted |
Audio isn't being streamed |
next_stream |
Turned on mid-stream without 8-channel capture: it applies from the next stream. Clients show "Applies next stream" |
Clients show a reason they don't know by message.
POST /api/native/v1/audio/settings
{ "changes": [ { "id": "audio.night_mode", "value": false }, { "id": "audio.headphone_surround", "value": true } ] }
- For a device with its own live Stream session (also a second device streaming beside the PC's main session), with View or Launch. Host control isn't needed: the change affects only the caller's own stream. A Remote Monitor or input-only session has no settings here; GET reports them
temporarily_unavailable(no_session) as without a stream. - It applies to this session from the next audio packet and isn't saved. It answers the new Audio object.
- Refusals:
no_sessionwhen the caller has no live Stream session of its own (none, a suspended one, only another device's, or only a monitor or input session);not_foundfor an id the host doesn't list;invalid_valuefor a value that isn't a boolean;invalid_requestfor unknown fields.
Launch parameters. /launch and /resume take audioNightMode=on|off and audioHeadphoneSurround=on|off, the session choice above. A client sends them only when the host lists the feature and the user picked something other than the host setting. Other values are logged and ignored, and hosts without the features ignore the parameters.
Couch Party Audio (audio.party) #
Status: served (7.0.0, design). Types in rubylight_native_api::party_audio, fixture client/protocol/native-api/tests/fixtures/party_audio.json. Clients gate the Party Audio sheet strictly on HostCapabilities (PartyAudioVersion >= 1 in /serverinfo and audio.party in native capabilities).
GET /api/native/v1/audio/party
{
"revision": 12,
"active": true,
"caller_slot_id": 1,
"caller_is_owner": true,
"host_output": {
"mode": "remote_only",
"configurable": true,
"endpoint_name": "Living Room TV (HDMI)",
"reason": null,
"message": null
},
"own_mix": {
"game_volume_pct": 85,
"voice_volume_pct": 120,
"ducking": "subtle",
"muted": false
},
"slots": [
{
"slot_id": 1,
"device_name": "Living Room Handheld",
"is_owner": true,
"is_self": true,
"mic_active": false,
"speaking": false,
"muted_for_me": false,
"volume_pct": 100,
"pan": 0
},
{
"slot_id": 2,
"device_name": "Alex's Phone",
"is_owner": false,
"is_self": false,
"mic_active": true,
"speaking": true,
"muted_for_me": false,
"volume_pct": 100,
"pan": -35
}
]
}
- Requires a paired device with
VieworLaunch(403 permission_requiredotherwise). When no live stream exists for the caller,GETanswers200withactive: falseandreason: "no_session". own_mix:game_volume_pct(0..=100, default100),voice_volume_pct(0..=200, default100),ducking(offdefault,subtle-6 dB,clear-12 dB),muted(defaultfalse).slots: every connected stream participant (1..=8).is_selfmarks the caller's own slot; self slots never expose mute/pan overrides because each listener's own microphone is excluded from their headphone mix.host_output.mode:remote_only(default) orcouch_mirror(mirrors game audio to the host PC's pre-stream physical speakers with a crash-safeparty-audio-recovery.jsonrestore journal).
POST /api/native/v1/audio/party
{
"own_mix": { "game_volume_pct": 80, "ducking": "subtle" },
"slot_updates": [ { "slot_id": 2, "muted_for_me": false, "volume_pct": 125, "pan": -40 } ],
"host_output_mode": "couch_mirror"
}
- Requires a live stream for the caller (
409 no_sessionwhen idle) and rejects unknown fields or out-of-range values with400 invalid_request. - Any live participant may update
own_mixandslot_updatesfor their own stream. - Only the session owner (or a device with Host control) may change
host_output_mode; a guest attempting to sethost_output_modereceives409 not_session_ownerwith zero host speaker side effects. All writes return the updatedPartyAudioStateand broadcast0x554C StateSyncto opted-in streams.
Neural Rendering (neural.frame_generation) #
A game's Neural Rendering switches, as the console's game page has them. Today the host has one, frame_generation: frame generation for a game that offers DLSS frame generation, through a third-party mod the host downloads at the user's request (about 14 MB, pinned by SHA-256) and puts into the game's folder. A client says so in a notice before the first write that turns it on.
GET /api/native/v1/neural?app=6F1D2C3B-4A59-4E2B-9C1D-2B3A4C5D6E7F
{
"app": "6F1D2C3B-4A59-4E2B-9C1D-2B3A4C5D6E7F",
"accepted": true,
"gpu": "AMD Radeon RX 7900 XT",
"switches": [
{ "id": "frame_generation", "state": "needs_external_setup", "on": false,
"why": "choose_program",
"reason": "Choose the game's program in the Rubylight console on the PC." }
],
"replaces_earlier_upscaling": true,
"job": { "action": "install", "phase": "failed", "done": 0, "total": 0,
"error": "Rubylight doesn't know where this game is installed." }
}
appis the id/librarylists. 400invalid_requestwithout one, 404not_foundfor an id the host doesn't have.switcheslists what the host offers for the game; a client draws each id it knows and leaves out the rest.stateisconfigurable,unsupported(none of this PC's GPUs can run it, or the game can't have it;reasonsays why),read_only(the device lacks Host control;reasonsays to turn it on),temporarily_unavailable(a stream runs, or the host is busy with the game) orneeds_external_setup(the host could not tell which program is the game: the user chooses it in the console).onis whether it is in the game's folder.whysays the same asreasonas a code, so a client can say it in its own words:busy,streaming,no_host_control,gpu,runtime(the PC lacks the Microsoft Visual C++ 2015-2022 Redistributable (x64): a client says to install it on the PC),anti_cheat(the game has an anti-cheat),no_frame_generation(the game has no DLSS frame generation),choose_programandgame(something else about the game; onlyreasonsays what). It is absent while the switch can change and from hosts before it; a client showsreasonfor a code it doesn't know. A client shows whether the switch is on beside the reason.- While the switch is off and nothing runs for the game, the host checks the game itself before any write, as turning it on would before its download: its program, a known anti-cheat, Valve Anti-Cheat on Steam and DLSS frame generation. A game that fails shows
unsupportedwith itswhyandreason, so a client says why before the user tries; a game whose program the host can't tell showsneeds_external_setup. The check is held about 2 minutes per game. One check per game runs at a time; a read waits for it a few seconds at most and otherwise answers with the game's last result, however old, or without one before the first, so the switch stays usable; the check's answer serves the next read. While a stream runs no check starts and the last result stands, andstreamingtakes precedence over the game's ownwhyand overno_host_control. The write's answer never waits for it. acceptedis whether the notice was accepted on this host, in the console or on a device.gpunames the PC's GPU that can run it: the streaming GPU when it can, else the first other that can, also when the host can't find the GPU it streams with.gpu_note, whengpuis another GPU than the one the host streams with, says in the host's words that frame generation runs when the game renders on it; a client shows it beside the switch, as the console does. It is absent otherwise and from hosts before it.modeandrelease, only whileon:full(the host's own package) oraddon(only the frame generation add-on, put into an upscaler mod the user installed), and the release in the game's folder. A client shows both, as the console does. Absent from hosts before them.replaces_earlier_upscaling: Rubylight 3.0's neural upscaling is still in the game's folder. Turning the switch on removes it first, in the same job; a client says so before the write. Turning the switch off removes both.jobis what the host is doing for the game, or how it last ended:action(install,remove,updatefor a launch's check),phase(download,place,remove,done,failed),doneandtotalbytes while it downloads or copies, anderrorin words. A removal that finds the game running (outside a stream) fails with anerrorthat says to close the game, with nothing in the game's folder changed. A client readsGET /neuralabout every 1.5 s whilephaseis neitherdonenorfailed.
POST /api/native/v1/neural/settings
{"app": "6F1D2C3B-4A59-4E2B-9C1D-2B3A4C5D6E7F", "switch": "frame_generation", "on": true, "accept_notice": true}
- The write needs View streams and Host control, judged again right before it runs, and answers 202 with the state. It is refused with 409
host_in_usewhile any stream runs, both ways: turning on, the download and the copy would take the stream's network and disk; turning off, the streamed game may hold the mod loaded, so its removal would be left half done. accept_noticerecords that the user accepted the notice on the device just now. Without it, a host where nobody accepted it yet answers 422not_writable.- The body never names a file on the PC, and an unknown field (such as
exe) is 400invalid_request. When the host can't find the game's program, the job fails with the switch inneeds_external_setup; the console's game page picks the program. - The host refuses games with a known anti-cheat, games without DLSS frame generation and a PC none of whose GPUs it can run on, as the console does; the switch's
whyandreasonsay which before the write, and the job'serrorif the game changed since.
Files #
File transfer lets a paired device send files to the PC and fetch them back. It needs the host's file_transfer setting (off by default) and the device's Upload files or Download files bit, which no device has until the console grants it. Both are read on every request and every 250 ms while a transfer runs: turning either off ends a running upload with 403 and deletes its .part file, and ends a running download before its last byte. Files go to and come from file_transfer_dir, or the signed-in user's Downloads\Rubylight when that is empty, and are read and written as that Windows user.
While a stream runs or starts, uploads and downloads together move at file_transfer_stream_mbps (50 Mbit/s by default; 0 for full speed); the rate is read again every 250 ms. Otherwise they run at full speed.
GET /api/native/v1/files
{
"folder": "C:\\Users\\Player\\Downloads\\Rubylight",
"free_bytes": 107374182400,
"max_file_bytes": 4294967296,
"files": [ { "name": "clip (1).mp4", "size": 52428800, "modified_unix_ms": 1792000000000 } ]
}
Only plain files are listed: no folders, links or .part files. free_bytes is what an upload may use: the volume's free space less a reserve of 2 % of the volume, at least 1 GiB and at most 4 GiB, and less what the uploads running still have to write. A device with Upload files but not Download files gets folder, free_bytes and max_file_bytes with an empty files.
POST /api/native/v1/files?name=clip.mp4
Content-Type: application/octet-stream
Content-Length: 52428800
nameis percent-encoded UTF-8 as RFC 3986 has it (+is a plus; a space is%20): a file name without a path, at most 200 UTF-16 units, with nothing Windows refuses (\ / : * ? " < > |, control characters, a trailing dot or space, device names such asCON). Anything else isinvalid_name, and so is a name ending in.part.Content-Lengthis required (length_required), and checked againstmax_file_bytes(file_transfer_max_mb, 4096 MiB by default,too_large) andfree_bytes(insufficient_storage) before a byte is written. The 1 MiB limit of the other HTTPS routes does not apply.- The body goes to
<name>.partand is renamed only once all of it arrived. A taken name gets the next free number, as Explorer numbers copies:clip (1).mp4. The answer is201with{ "name": "clip (1).mp4", "size": 52428800 }, wheresizeis the bytes received. - A body that ends early, sends nothing for 30 s, or after its first 30 s averages less than 64 KiB/s (time spent waiting for the stream rate doesn't count) is
incomplete_upload, and the.partfile is deleted. A longer body than itsContent-Lengthisinvalid_request. - One upload per device at a time: a second one is
transfer_busy. Other devices are not held up. - A refused upload is answered at once with
Connection: close. For a paired device the host then reads and drops up to 8 MiB or 5 s of the rest of the body before it closes, so a client that sends a small body before reading gets the answer, not a reset. A caller that isn't a paired device gets no such grace: the connection closes right after the answer.
GET /api/native/v1/files/content?name=clip%20(1).mp4
The answer is application/octet-stream with the file's exact Content-Length. If the file grows or shrinks while it is sent, or the client takes nothing for 30 s, the host ends the connection before the last byte, so the client never keeps a short or mixed file. A name the folder doesn't hold as a plain file is not_found. A device runs at most two downloads at once and the PC eight; another is transfer_busy, as is a file another program on the PC holds open without sharing it.
Image clipboard #
The image clipboard is type=png on Vibepollo's /actions/clipboard, beside type=text and with its rules: Read the clipboard for GET, Write to the clipboard for POST, View or Launch, a session of this device and no background stream. The host lists the feature clipboard.image while its clipboard_image setting is on, which it is by default; while it is off, type=png is 403 like any type but text. The route is outside /api/native/v1: like its text form it answers with the status alone, so no answer carries an error body or a code.
GET /actions/clipboard?type=pnganswersimage/png, or 404 while the clipboard holds no image. APNGanother program put on the clipboard is passed on as it is; a bitmap (CF_DIBV5orCF_DIB, 24 or 32 bits a pixel) is converted. An image larger than the limit below is 413, one the host can't convert 415.POST /actions/clipboard?type=pngtakesContent-Type: image/png(415 without it) of at mostclipboard_image_max_mb(16 MiB by default, 1 to 64), and is 413 above that: by itsContent-Lengthbefore a byte is read, or once the body passes the limit. The 1 MiB limit of the other routes, text on this one included, doesn't apply to it. The host checks the image's size before it decodes the pixels (at most 16384 a side and 32 megapixels, else 413), then puts them on the clipboard asCF_DIBV5andPNG, re-encoded, so no other chunk of the file reaches the PC's programs. A body that isn't a PNG is 400, one the host can't decode 415.- Image requests take turns across devices, and a device's image request made while another of its own is waiting or running is 429.
Shared folders #
Shared folders let a paired device browse folders of the PC, download from them and, with a write grant, upload to them. The host's shared_folders setting names the folders: a JSON list of {"id": "games", "name": "Games", "path": "D:\\Games"}, where id is 1 to 64 ASCII letters, digits, - or _ and path is a folder on a drive of this PC (no network share, \\?\ or \\.\ path, ., .. or stream name). The host lists the feature folders while it shares at least one; folders.mount (WebDAV) is not served.
A device sees a folder only with a grant for it: "shared_folders": {"<folder id>": "read" | "write"} in its extra map, set in the console. No perm bit or Full control grants a folder, and the File transfer setting isn't needed. permissions.shared_folders is true when the device holds at least one grant; it is missing from older hosts and then false. /api/clients/update refuses any other grant value, and null clears them; a hand-edited grant it would refuse, such as "../x", grants nothing. Taking a grant away, or a write grant back to read, disconnects the device, as removing perm bits does. The setting and the grant are read on every request and every 250 ms while a transfer runs: dropping either, or pointing the folder's id at another path, ends a running upload with 403 and deletes its .part file, and ends a running download before its last byte.
| Method | Path | Needs | Result |
|---|---|---|---|
| GET | /folders |
a grant for a shared folder | FolderList: the device's grants only, in the host's order |
| GET | /folders/{id}/entries?path= |
a grant for id |
FolderEntries |
| GET | /folders/{id}/content?path= |
a grant for id |
The file's bytes |
| PUT | /folders/{id}/content?path= |
a write grant for id |
201 with { "name": ..., "size": ... }, as an upload to /files |
{ "folders": [ { "id": "games", "name": "Games", "access": "read" } ] }
{ "path": "saves", "entries": [ { "name": "slot1.sav", "kind": "file", "size": 4096, "modified_unix_ms": 1792000000000 } ] }
pathis percent-encoded UTF-8, asnameis for/files: names below the folder separated by/, missing or empty for the folder itself. Each name follows the/filesrules (up to 255 UTF-16 units here, and no.partname), and a path has at most 64. An empty name (a leading, trailing or double/),.,..,\, a stream name (:), a device name such asCON, or more than onepathisinvalid_name.- Files are opened as the signed-in Windows user, only below the folder. Each name is checked against what Windows opened, so a link, junction or other reparse point (even one back into the folder) or an 8.3 short name is
not_found, like anything missing; names match in any case, as Windows matches them. A shared folder may itself be reached through a junction. entrieslists folders first, then plain files, each by name. Links,.partfiles and names a path can't hold are skipped.kindisfileordir; an unknownaccessorkinddecodes asUnknown.sizeis 0 for a folder.contentis sent asGET /files/contentsends it: exactContent-Length, ended early if the file changes, the download caps andtransfer_busy.- A PUT's last name is the file, written into its folder, which must exist (
not_found). It followsPOST /files: a.partname isinvalid_name;length_required,too_large(file_transfer_max_mb),insufficient_storage,incomplete_uploadandtransfer_busy(one upload per device, shared with/files); the.partfile renamed once all of it arrived; a taken name numbered; a refused body answered withConnection: close. - Uploads and downloads count against file transfer's caps and move at
file_transfer_stream_mbpswhile a stream runs, together with/files.
| HTTP | code |
When |
|---|---|---|
| 403 | folders_disabled |
The host shares no folders |
| 403 | forbidden |
The device has no grant for the folder (or for any, on GET /folders), or only read for a PUT |
| 403 | folder_unreadable |
Windows denies the signed-in user reading the folder, or a folder or file in it (entries, content) |
| 404 | not_found |
The host no longer shares the granted folder, or the path isn't in it |
The host control permission #
- It is stored per device as
"host_control": truein that client'sextramap in the paired state, likeallow_client_commands. The host readstrueand"true"as on, like the other boolean keys inextra; a missing key or anything else means off. That covers new pairings, migrated Vibepollo or Apollo state and old backups, so the flag is off by default. - Why not a
permbit: bits 24 to 31 are the Apollo-family action group,Permissionis sent to Artemis,/api/clients/updatemaskspermwith0x071f1f00, and test fixtures and imports useperm = u32::MAX. A separate key can't collide with an upstream bit, and an all-ones permission value can't switch it on. - Only the admin console can grant it: Devices → device → Other → "Host control: change graphics driver settings, close games, install a Rubylight update and manage guests from this device".
/api/clients/updateaccepts onlytrue,falseornullfor it. Nothing in the pairing flow or on the streaming port can set it. - It is required for every
POST /radeon/*and forclose_game. Reads never need it. - Revoking it takes effect on the next request and doesn't stop the stream (unlike removing
permbits). Pending Radeon changes are still restored at session end.
Power and update (power.restart, power.shutdown, update) #
Restart and Shut down work as Sleep PC does on /power-actions/v1 (Vibepollo's format, unchanged and not covered here), with their own grant and tokens:
- Restart and shut down PC is its own per-device key,
"allow_restart_shutdown": trueinextra; only a JSONtruecounts. It is off for every device, including the first one and every pairing role (the roles set permission bits only), and only the console grants it (Devices → device → Other). Sleep PC and Host control don't imply it, nor it them.permissions.restart_shutdownin Capabilities reports it. GET /powerhands an allowed device a token for the next 30 s (token_lifetime_s) while the PC is idle: no stream or pending launch from any device, the caller included, no app left running, no stream ending, no browser guest and no controller session. Otherwise both actions say why, naming the devices that stream:"Living room TV is streaming from this PC.". A newGETreplaces the device's earlier token. Unlike Sleep PC, both are offered on Modern Standby PCs.POST /power/restartor/power/shutdownwith{"token": "..."}checks the grant, the same idle gate and then the token, which only an accepted request spends. The 202 saysConnection: close; the host asks Windows only once that answer left, only if the grant is still on, and only if no browser guest or controller session appeared meanwhile (neither waits for the lifecycle gate the request holds). With a user signed in, the service host asks from that user's session (shutdown.exe /r /t 0or/s /t 0): Windows refuses a SYSTEM caller while a user is signed in unless forced. Ifshutdown.exedoesn't answer within 15 s,last_refusalsays the PC may still restart or shut down, andlast_refusal_unconfirmedis true: no refusal, so a client words it as one it can't confirm (older hosts leave the field out). Otherwise it callsInitiateShutdownWwithSHUTDOWN_RESTARTorSHUTDOWN_POWEROFF. Never forced and never hybrid, so an app with unsaved work can still stop it and the PC really powers off. If Windows refuses, or the PC got busy before the call, the device's nextGET /powersays why inlast_refusal: it belongs to that device only, its next accepted request clears it, and it is dropped after 10 minutes. A client readsGET /powerfor a few seconds after the 202 to show it.wake_from_offis true when a wired wake target (GET /wake) isready. Wi-Fi can't wake a PC that is off, and firmware settings Windows can't read may still stop it; a client warns before a shutdown without it.GET /updatereads the host's updater for any paired device.POST /update/installis the console's Install now: it needs Host control, is refused withhost_in_usenaming the device while another device streams or starts a stream, ends the caller's own stream, and answers 202 with the phase. A device's install never ends another device's stream: one that starts streaming afterwards holds the download and install back until it ends, andwaiting_fornames it ("Living room TV is streaming from this PC."; null otherwise, and older hosts leave it out).install_nowis true once the queued update is an Install now rather than one that waits for an idle host, so a client offers Install now again only while it is false and the phase is notinstalling. A second request while the install is already under way raises no secondupdate.started.update_unavailablecarries the updater's reason (no newer release, not an installed service, a check that failed). The client followsphaseuntil the host goes away, then waits for/serverinfoto answer with the new version;phasefailedwith itserrorends the wait, as does a host back on the old version with nothing under way.- Each accepted request is logged and raises the webhook
power.restart,power.shutdownorupdate.started; each refusal is logged with its code and message.
{ "restart": { "available": true, "reason": null },
"shutdown": { "available": true, "reason": null },
"token": "3f9c...64 hex digits", "token_lifetime_s": 30,
"wake_from_off": true, "last_refusal": null, "last_refusal_unconfirmed": false }
Quick Suspend (session.quick_suspend) #
Listed while the host's quick_suspend is manual (off by default). GET /session/suspend reads the running game's state for a device with View or Launch; POST /session/suspend pauses its processes and POST /session/resume resumes them, for the device that owns the session and may launch apps, or one with Host control. The bodies are {} (or empty; an unknown field is invalid_request). Each answer is the state after the request:
state:unavailable(off, no game, or a game without a process the host launched;reasonsays which),ready,suspended,resuming, or, only in a POST's answer,refused, with the state unchanged.reason:none,disabled_for_app,no_owned_process,anti_cheat_detected,protected_process,denylisted_process,guests_active,coop_session,not_owner,session_busy,no_sessionorio_or_os_error, the names of the control message0x554B's reasons;messagesays it in plain English, null withnone.app_title,suspended_count,suspended_since_unix_msandsuspended_by(the device or "the console").
The host pauses the app's verified game processes and every process they started, children first, and nothing else: an anti-cheat in the tree, or one that started with the game anywhere on the PC, refuses the whole suspend, as do a system process, the host, guests and co-op sessions; launchers and console hosts keep running. It writes quick-suspend.json to the profile and starts its watchdog before the first process stops, and resumes what it paused if one refuses. A resume repeats nothing that ran again: a process that exited, or whose id Windows gave to another program, is left alone. The next stream of the game, End session, Close game, the game's stop, the grace period running out and a clean shutdown resume the game first; after a crash the watchdog, or the next host start, does.
{ "state": "suspended", "reason": "none", "message": null,
"app_title": "Hollow Knight", "suspended_count": 2,
"suspended_since_unix_ms": 1763772200000, "suspended_by": "Living room TV" }
Launch curtain (session.launch_curtain) #
Listed while the host's launch_curtain is on (off by default). A launch that sent rlLaunchCurtain=1 has a curtain while its game starts, and GET /session/curtain reads it for a device with View or Launch; POST /session/curtain/dismiss lifts it for the device that launched the game, with Launch (body {} or empty; an unknown field is invalid_request). The same state reaches that device's stream as the control message 0x5548.
revision: grows with every change.active: whether a curtain is up.phase:preparing,starting_app,waiting_window,focusing_window,attention_needed,ready,dismissed,timed_outorfailed(readywithout a launch that asked); an unknown phase means the curtain is down.dismissible: the caller launched the game and the curtain is up.elapsed_ms: since the launch, never progress.prompt, whileattention_needed:launcher(steam,epic,ea,ubisoft,xbox,battlenet,gog,riot,windows),kind(update,sign_in,prompt,uac),window_title(empty for any other device) andsince_unix_ms.reason: why it timed out or failed, in plain English; null otherwise.
{ "revision": 12, "active": true, "phase": "attention_needed", "dismissible": true,
"elapsed_ms": 8420,
"prompt": { "launcher": "steam", "kind": "sign_in",
"window_title": "Steam Guard - Computer Authorization Required",
"since_unix_ms": 1795221890123 },
"reason": null }
Approve a device (pairing.approve) #
A device with Approve new devices or Host control approves a new one from the couch: it reads the waiting devices and types the PIN the new device shows. The Moonlight key comes from the PIN, so the host needs it and one click cannot do; the protocol and PROTOCOL_VERSION stay as they are.
{ "requests": [ { "id": "a1f3", "name": "Living room TV", "address": "192.168.4.116", "age_seconds": 12 } ] }
idnames the request, for the calls below.nameis the device's own choice, so a client showsaddressbeside it. A request lasts 300 s.POST /pairing/approvewaits up to 10 s for the handshake and answers how it ended. The host cannot check a PIN when it receives it, only see the handshake fail, and a Moonlight client that finds a wrong PIN starts over with a new one:- 200
{"name"}: the device has paired. - 422
wrong_pin: the handshake failed, or the device asked again before it ended. Its next try is a new request with a new PIN. - 409
pairing_unconfirmed: nothing came back in 10 s, or the PC could not save the device, which costs the address nothing. Nothing coming back counts as a wrong PIN unless the device still finishes. This is how a wrong PIN usually ends with Moonlight: the/unpairit sends then has no certificate, so anyone at the address could send it, and the host ignores it. - 409
pairing_cooldown: a wrong PIN came from this address in the last 30 s. The request stays listed and can be approved after that. A PIN typed for a look-alike can be worked out from its handshake, and the real device keeps showing it, so the same PIN must not reach the look-alike's next request at once. - 409
pairing_ended: three wrong PINs from this address within 5 minutes, whatever names it used. An IPv6 /64 counts as one address. Its requests leave the list, and only the console can pair from it for those 5 minutes. A right PIN or a pairing from the console clears the count. - 403
permission_required: the approver has no Play permission to hand on, or lost its right to approve during the handshake. Neither counts against the new device. - 404
not_found: the request expired, was denied or was already answered. - 422
invalid_value: not four digits.
- 200
- A browser (WebRTC) request is in the same list. Its PIN is compared at once, so one wrong PIN ends the request. It keeps a browser's default of view only, and an approver without List and View gets 403
permission_required. - What the new device gets: what a PIN typed in the console defaults to, Play (list, view, launch and all input), never more than the approver holds: the host caps
Play & approver's permwhen the handshake ends, and turns Can join co-op games off if the approver lacks it. Host control, Approve new devices and shared folders are never passed on; only the console grants them. The first device paired to a PC can't come this way, since an approver is already paired. - Who approves: a device with Approve new devices or Host control, checked on every request and again when the handshake ends. If the approver lost both meanwhile, the new device doesn't pair. Without either, the three routes answer 403
permission_required. - Approve new devices is stored per device as
"pairing_approve": trueinextra, and only a JSONtruecounts. It allows these three routes and nothing else: every other Host control action still answershost_control_required. The first device with a certificate paired on a host gets it, unless the owner chose Watch only; a browser paired earlier doesn't count, since it can't use these routes. Later devices don't, even with Everything chosen in the console. Devices paired before a host had it stay as they were: an upgrade migrates nothing. The console sets it under Devices → device → Other, and/api/clients/updateaccepts onlytrue,falseornull. - Every approval raises a toast on the PC, a log line and the
pairing.pairedwebhook, each naming the approver and the new device.
USB forwarding #
Feature usb is listed while the host's USB forwarding setting (usb_forwarding, off by default) is on and its USB/IP driver (usbip-win2) is installed. The device needs the usb permission.
usb is a boolean in permissions, missing from older hosts and then false. Like host control, it is not a perm bit, and only the admin console sets it. Unlike host control, turning allow_usb off disconnects the device, as removing perm bits does. It is "allow_usb": true in the device's extra map: only a JSON true, never a string, a number, a perm bit or Full control. /api/clients/update accepts true, false or null for it.
| Method | Path | Needs | Result |
|---|---|---|---|
| GET | /usb/tunnel |
usb, a token |
101, then USB/IP |
- The USB tunnel is a request with
Connection: Upgrade,Upgrade: rubylight-usbip/1andX-Rubylight-Usb-Token(32 hex digits). The token comes from control message0x553A(control messages): it is good once, for 30 s, and only for the device that asked for it. After101 Switching Protocolsthe connection carries standard USB/IP, with the client as the USB/IP server. The host relays it to its driver over 127.0.0.1, checking every message against what the driver asked, so no USB/IP port is reachable from the network and a client can't hand the driver malformed USB/IP. A missing token orUpgradeisinvalid_request, and an unknown, expired, already used or another device's tokennot_found. - An attachment ends with the client's own DETACH, the console's detach (
POST /api/usb/detach), either end closing the tunnel, the stream ending, or the device disconnecting. The client hears why on0x553A, unless it is the one that disconnected.
| HTTP | code |
When |
|---|---|---|
| 403 | usb_disabled |
The host's USB forwarding setting is off, or the device has no usb permission |
| 409 | usb_limit |
The host already forwards as many devices as it allows |
Stream DVR (stream.dvr) #
Instant replay and recording on the host, without re-encoding: while dvr_enabled is on, the host keeps the last dvr_ring_seconds of the stream's encoded video and Opus audio in memory and writes clips as MP4 files to the clips folder (configuration). The same actions travel in the stream as control message 0x554A (control messages); this API serves companions, the console and clients outside a stream. The feature is listed whenever the host has Stream DVR, even with dvr_enabled off, so a client can say why clips are unavailable.
| Method | Path | Needs | Result |
|---|---|---|---|
| GET | /dvr |
View or Launch | DvrStatus |
| POST | /dvr/clip |
Launch, the stream's owner | {} or {"duration_secs": 60}; 200 ClipSaved once the file is written, or 409 dvr_refused |
| POST | /dvr/record |
Launch, the stream's owner | {"action": "start"} or {"action": "stop"}; 200 RecordResult (with clip after a stop), or 409 dvr_refused |
| GET | /dvr/clips?limit=50&cursor= |
View or Launch | ClipList, newest first |
| DELETE | /dvr/clips/{id} |
Host control | 204; 404 not_found for an unknown id |
{ "state": "armed", "reason": "none", "ring_buffered_secs": 58, "ring_capacity_secs": 60,
"recording": false, "recording_elapsed_secs": 0, "quota_used_bytes": 4509715660,
"quota_limit_bytes": 21474836480, "clips_dir_available": true, "container": "mp4" }
state is off (the feature is off: reason disabled; nothing streams: not_streaming), armed, recording, saving, unsupported (pyrowave: PyroWave streams cannot be remuxed; audio_codec_unsupported: the stream's audio is PCM, AC3 or E-AC3 passthrough) or error (disk_full, quota_exceeded, io_error). Clients treat an unknown state as unsupported and an unknown reason as unknown. A clip a client asks for while another is being written is refused with busy, and one asked for before the first keyframe with no_keyframe_yet (the host asks the encoder for one). A clip summary (ClipSummary) has id ([A-Za-z0-9_-]{8,64}), app_title, created_unix_ms, duration_ms, width, height, fps, codec (h264, hevc, av1), hdr, container (mp4), size_bytes, kind (replay or manual) and recovered (kept from a recording the host could not finish). When the quota is full the host deletes the oldest replay clips, never recordings.
Stream Doctor (stream.doctor_v2) #
Which stage of the host lost the caller's stream time, and the remedies the host can try for this stream only. Nightjar fuses it with its own network, decode and display measurements into one plain-language finding; it reads GET /stream/doctor about once a second while its Stream Doctor card is open, and never otherwise. The host computes nothing new for it: host_stages is the stutter report the console shows (stutter), over the last window_seconds (30), and pipeline_rates are the console's frame rates of the last second.
{ "schema_version": 1, "session_active": true, "caller_is_owner": true, "window_seconds": 30,
"encoder": { "backend": "amf", "codec": "hevc", "hdr": false, "width": 2560, "height": 1440,
"fps": 120, "live_bitrate_kbps": 36000, "fec_percent": 20 },
"host_stages": { "pictures": 3560, "late_pictures": 94, "dominant_stage": "encode",
"lost_us": { "capture": 18200, "convert": 11400, "encode": 642500, "packetize": 4100, "send": 22000 },
"pipeline_rates": { "source_mhz": 118400, "capture_mhz": 118400, "submit_mhz": 102100,
"output_mhz": 101800, "repeat_mhz": 1200 } },
"active_trials": [ { "trial_id": "t-3", "remedy": "bitrate_stepdown", "applied_value": 36000,
"previous_value": 45000, "can_undo": true } ],
"eligible_remedies": [ { "id": "bitrate_stepdown", "configurable": false, "target_kbps": null,
"reason": "trial_active", "message": "A lower bitrate is already being tried. Undo it first." } ] }
The caller's stream is the one its device plays or watches; without one, session_active is false and encoder, host_stages and both lists are empty. host_stages is null before the first measured picture, and dominant_stage null when too little time was lost to name a stage. A stage is capture, convert, encode, packetize or send (clients read an unknown one as unknown).
The one remedy is bitrate_stepdown: the stream's live bitrate a fifth lower, never below 500 kbps, capped where a client's /bitrate request would be (max_bitrate, and the codec's runtime cap: 2 Gbps for PyroWave, 500 Mbps otherwise), so target_kbps is what the host applies. The step keeps the launch's FEC share inside the bitrate, so the encoder's own rate moves by the same fifth and an undo gives it back exactly. As a manual change does, the client's bitrate takes over from the host's own bitrate controllers for the rest of the stream, undo included. POST /stream/doctor/apply with {"action": "apply", "remedy": "bitrate_stepdown"} applies it; {"action": "undo", "remedy": "bitrate_stepdown", "trial_id": "t-3"} returns to previous_value. Trials live in the stream and end with it; nothing is saved. A trial whose bitrate something else changed since (the player, or another client request) has can_undo false, and its undo is refused with 422 not_writable so that change stays. An undo the host's limit now holds below previous_value is refused with 422 not_writable (capped) and the trial stays; a bitrate that moved between the host reading and setting it is refused the same way (bitrate_changed), with nothing changed. Only the stream's owner applies a remedy: a guest reads the snapshot with caller_is_owner false and each remedy's reason not_owner, and a device without Launch reads permission_required. Other refusals name at_minimum, trial_active, bitrate_unknown, no_trial (422 invalid_value) and unknown_remedy (422 invalid_value).
Reserved features #
These are defined in rubylight-native-api but no host serves them yet, so none lists their features. Until one does, the routes below answer 404 not_found like any unknown path under /api/native/v1.
| Feature | Listed while | Permission |
|---|---|---|
folders.mount |
as folders, for WebDAV |
shared_folders |
| Method | Path | Needs | Result |
|---|---|---|---|
| any | /folders/{id}/dav/ |
a grant for id |
WebDAV class 1 |
Errors #
Every non-2xx answer has the same body:
{ "error": { "code": "host_control_required",
"message": "Turn on Host control for this device in the Rubylight console.",
"setting": null, "retry_after_ms": null } }
| HTTP | code |
When |
|---|---|---|
| 403 | not_paired |
No TLS client certificate, or the device is unknown or disabled |
| 403 | permission_required |
List, View or Launch missing, or Approve new devices on a /pairing route. message names the permission, as authenticated() does for the Moonlight endpoints |
| 403 | host_control_required |
Radeon write or restore, Close game or Install update without host control |
| 403 | file_transfer_disabled / forbidden |
Files: the host's File transfer setting is off / the device lacks Upload files or Download files |
| 404 | not_found |
Unknown path under /api/native/v1, GPU or setting id, or Radeon controls this host does not have (a restore or write on a host without them) |
| 400 | invalid_request |
Malformed JSON, unknown fields in a write, or a body over 16 KiB |
| 422 | invalid_value / not_writable |
Wrong type, out of range, or the setting is not configurable |
| 409 | no_session / not_session_owner / session_busy |
A write or action needs a session the caller owns. session_busy: a launch or teardown is in progress, retry after retry_after_ms |
| 409 | driver_rejected |
ADLX (or NVAPI on an NVIDIA host) refused a write. setting names it, and the earlier changes of the request were rolled back |
| 400 | invalid_name / incomplete_upload |
Files: a name the host refuses / an upload that ended or stalled before its Content-Length |
| 411 | length_required |
An upload without Content-Length |
| 413 | too_large |
An upload over max_file_bytes |
| 507 | insufficient_storage |
The PC has no room for the upload |
| 409 | no_console_user / transfer_busy |
Files: nobody is signed in to Windows / the device already has an upload or two downloads running, the PC eight downloads, or another program holds the file |
| 409 | pairing_ended / pairing_cooldown / pairing_unconfirmed |
Approving a device: three wrong PINs ended this address's requests / a wrong PIN just came from it / the device did not answer the handshake |
| 422 | wrong_pin |
Approving a device: the handshake failed, and the device starts over with a new PIN |
| 409 | host_in_use / token_expired / update_unavailable |
Power and update: the PC is in use, and message names the device or what runs / the power token expired or was used, so confirm again / no update to install, message says why. Continue here also answers host_in_use |
| 409 | coop_refused |
Co-op: the session is full or ended, or the device was removed from it; message says which |
| 409 | dvr_refused |
Stream DVR: the feature is off, a PyroWave stream or passthrough audio, no keyframe yet, another clip is being written, or the disk or quota is full; message says which, GET /dvr names the reason |
| 409 | revision_conflict |
Host Hub Sync: If-Match did not match the server's profile revision; X-Hub-Current-Revision names the current revision |
| 403 | usb_disabled / 409 usb_limit |
USB forwarding: the setting is off or the device has no usb permission / the host forwards as many devices as it allows |
| 403 | folders_disabled / folder_unreadable |
Shared folders: the host shares none / Windows denies the signed-in user reading it |
| 503 | temporarily_unavailable |
ADLX is busy or reinitialising, with retry_after_ms; Nucleus Co-op cannot run (/coop); the stream can't show the couch menu |
| 500 | internal |
A bug. The message is logged on the host too |
A host may add three optional strings to error, each left out when it has none: title, a short plain-English headline; next_step, what to do when message does not already say it; and technical_detail, codes and error chains (an HRESULT, the driver's words, a redacted error chain) for a bug report. title and next_step never carry codes. Older clients ignore them; a client shows message as before when they are absent, as they are from older hosts. rust/core/session/src/error_catalog.rs fills them by the cause the host knows, else a known failure in technical_detail, else the code:
{ "error": { "code": "driver_rejected",
"message": "wrote 3 and the driver reads back 1",
"setting": "anti_lag.level", "retry_after_ms": null,
"title": "The graphics driver refused the change",
"next_step": "The PC put the earlier values back. Choose another value, or update the graphics driver on the PC.",
"technical_detail": "driver_rejected (anti_lag.level): wrote 3 and the driver reads back 1" } }
not_streaming appears only as an action reason: a disconnect POST on a session that is already suspended is idempotent and returns 200 (with no session at all it is 409 no_session). message is plain English that the client can show as it is. Clients branch on code only. An unknown code decodes as ErrorCode::Unknown, which carries no status, so the client must keep the HTTP status of the response and treat the error by that.
Which actions are allowed (GET /session, and the same rules apply to the POSTs): resume for the owner while suspended or streaming (/resume supersedes the same device's stream, which is the reconnect after a crash); disconnect while streaming; end in any state but idle; close_game as end, or with no session when a game is left running. While preparing or launching, resume, end and close_game are refused with session_busy, because the launch holds launch_transition for as long as it takes. In stopping, end and close_game stay allowed (repeating is safe) and resume is refused with session_busy.
Versioning and compatibility #
- The path carries the major version (
/v1). Within v1, changes are additive only: new fields, features, setting ids, actions, error codes and enum values. Clients ignore unknown fields. They treat an unknown state asunsupported, an unknown session state asidlewith no actions, and hide unknown actions. - Removing or renaming a field, changing a type, or changing an action's meaning needs
/v2. ThenNativeApiVersionreports 2, and the host keeps serving v1 beside it. api_versionin the capabilities response is the version of the path that answered.- Compatibility: stock Moonlight and clients without native API support ignore the field, and
/applist,/canceland the tiles are unchanged for them; Nightjar against a host without the field (Rubylight 2.6.x and other Moonlight hosts) shows the classic grid.
Where the types live #
The API types live in a dependency-light crate inside client/protocol, re-exported by butterpollo-core:
client/protocol/native-api/Cargo.toml: packagerubylight-native-api, a workspace member ofclient/protocol/Cargo.toml. Its only dependency isserdewithderive(serde_jsonfor tests). It inheritsedition("2024"),rust-version("1.91"),licenseand[lints]fromclient/protocol/Cargo.toml(resolver = "3"). The crate has its own version (1.1.0), which follows the API and not the host, sorust/release/bump.py(which only bumpsrust/*/Cargo.toml) leaves it alone.butterpollo-coredepends on it by path and exposes it asbutterpollo_core::native_api(pub use rubylight_native_api as native_api;inrust/core/src/lib.rs).- Why not
butterpollo-coreitself: nightjar-core uses butterpollo-core only as a dev-dependency for interop tests. As a runtime dependency it would pullx509-parser,rcgen,regex,quick-xml,prost,anyhowand anembed-resourcebuild script into the Android library. Why notrubylight-protocol: it isno_stdwithout serde, and JSON doesn't belong there.
Modules (serde shapes as in the examples above, all snake_case; the source is authoritative):
| Module | Types |
|---|---|
| crate root | API_VERSION (1), PREFIX (/api/native/v1), SERVERINFO_FIELD (NativeApiVersion), and feature, the feature strings above |
capabilities |
Capabilities, HostInfo, Permissions |
library |
Library, Game, Store, Artwork |
session |
Session, State, Owner, Action, ActionId, SessionApp, LauncherNotice, LauncherKind, RadeonProfile, ProfileState, PlayingOn, MovedTo, CouchMenuRequest, CouchMenu |
radeon |
Radeon, Gpu, Setting, ControlState, Kind, Value, Range, Choice, Restore, SettingsWrite, Change |
wake |
Wake, Target, AdapterKind, TargetState, Check, CheckState, System, Sleep, FastStartup, ShutdownWake, IdleSleep, IdleSleepState; check ids in wake::check |
wake_relay |
WakeRelayInfo, WakeRelayBundle, RelayCredential, RelayPeer, RelayEnroll, RelayEnrolled, RelayAssignment |
audio |
Audio, AudioWrite (Radeon Setting and Change), the ids NIGHT_MODE and HEADPHONE_SURROUND, GROUP; reasons in audio::reason |
files |
FileList, FileEntry, Uploaded |
folders |
FolderList, SharedFolder, FolderAccess, FolderEntries, FolderEntry, EntryKind |
coop |
Coop, Game, Session, Player, Phase, End, EndReason, JoinRequest, Joined |
dvr |
DvrStatus, DvrState, DvrReason, ClipRequest, ClipSaved, RecordRequest, RecordAction, RecordResult, ClipSummary, ClipKind, ClipList |
power |
Power, Availability, PowerRequest, PowerAccepted, Update |
pairing |
PairingRequests, PairingRequest, PairingApprove, PairingDeny, PairingApproved |
doctor |
DoctorSnapshot, EncoderFacts, HostStages, HostStage, StageTimes, PipelineRates, ActiveTrial, EligibleRemedy, RemedyId, DoctorApplyRequest, DoctorAction |
quick_suspend |
QuickSuspendStatus, SuspendState, QuickSuspendRequest |
curtain |
LaunchCurtainSnapshot, CurtainPhase, CurtainPrompt, CurtainDismissRequest |
hub |
HubSnapshot, HubCapabilitiesSnapshot, CoverEntry, SyncProfile, ProfileScope, NetworkMatcher, StreamProfileSpec, DisplayMatcher, InputDeckSummary, HostOverrideSummary, ProfileWrite, ProfileDeleteResult |
usb |
TUNNEL_PATH, UPGRADE, TOKEN_HEADER, TOKEN_BYTES, TOKEN_TTL_SECS |
error |
ErrorBody, ApiError, ErrorCode with ErrorCode::status(), the table in Errors |
Host Hub Sync (hub.sync) #
GET /api/native/v1/hub/snapshot(list, optional?all_devices=1needinghost_control): returnsHubSnapshotwithETag: "rev:<N>:<digest>"(or304 Not ModifiedonIf-None-Match). Caller identities normalize#screen2viadevice_uuid.PUT /api/native/v1/hub/profiles/{id}(launchown device,host_controlfor shared or other devices; requiredIf-Match: "<rev>","0"to create; up to 64 KiB JSON body, above returning413 too_large; mismatch returning409 revision_conflictwithX-Hub-Current-Revision). Enforces ID^[a-z0-9][a-z0-9_-]{0,63}$, 64 profiles per device, 256 host-wide.DELETE /api/native/v1/hub/profiles/{id}(same ownership +If-MatchCAS): deletes the profile and returnsProfileDeleteResult.GET /api/native/v1/hub/covers/{app_id}(list): streams custom app cover PNG/JPEG/WebP bytes withETag: "sha256:<hex>",Cache-Control: private, max-age=0, must-revalidate, and304 Not ModifiedwhenIf-None-Matchmatches.
Option fields skip serialisation when None, except where the examples show null on purpose (game_id, store, installed, app, setting and retry_after_ms in an error, and primary and idle_sleep.reason in Wake). Response structs don't deny unknown fields, so old clients read newer hosts. In a Radeon response, a setting's value, range or restore of a shape the client doesn't know (a float, an array) reads as absent instead of failing the whole response. Request structs deny unknown fields, so typos fail loudly. The crate carries JSON fixtures (client/protocol/native-api/tests/fixtures/*.json, one per example above) with round-trip tests, and Nightjar's tests reuse them.
Design decisions #
- A running game with no session. The session machine has six states and no extra one for this case. After End session the game keeps running, the host reports
idlewithgame_running: true, Resume becomes a new/launchor/resumeof that game, and Close game works from there. - Radeon writes need an owned session. v1 allows writes only for the owner of a
streamingorsuspendedsession, because the restore is tied to the end of that session. Per-game Radeon profiles cover settings chosen before launch. - One GPU. v1 lists only the GPU that encodes the stream.
- Added games only. v1 lists the games in the host's library; installed games that have not been added are not listed.
- Polling. Clients poll
/sessionand comparerevision; there is no long poll. - Covers only. Artwork is the cover image; hero and logo images are not served.
- Session actions replace Quit. A client that sees
NativeApiVersion >= 1offers the native session actions instead of Moonlight's "Quit app". The host keeps serving/cancelunchanged for stock Moonlight. - A separate types crate. The types live in
rubylight-native-apirather thanbutterpollo-coreorrubylight-protocol, for the reasons in Where the types live. - Probed settings. The host's probe of the installed driver decides which Radeon settings are listed and their ranges.