Rubylight Download 7.0.3
On this page
  1. Ground rules
  2. Discovery and capabilities
  3. Endpoints
  4. Library
  5. Session
  6. Radeon state and writes
  7. Wake targets (wake)
  8. Away wake relay (wake.relay)
  9. Audio processing (audio.night_mode, audio.headphone_surround)
  10. Couch Party Audio (audio.party)
  11. Neural Rendering (neural.frame_generation)
  12. Files
  13. Image clipboard
  14. Shared folders
  15. The host control permission
  16. Power and update (power.restart, power.shutdown, update)
  17. Quick Suspend (session.quick_suspend)
  18. Launch curtain (session.launch_curtain)
  19. Approve a device (pairing.approve)
  20. USB forwarding
  21. Stream DVR (stream.dvr)
  22. Stream Doctor (stream.doctor_v2)
  23. Reserved features
  24. Errors
  25. Versioning and compatibility
  26. Where the types live
  27. Host Hub Sync (hub.sync)
  28. Design decisions

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 #

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

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

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:

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

Writes.

POST /api/native/v1/radeon/settings
{ "gpu": 11520, "changes": [ { "id": "chill.enabled", "value": true }, { "id": "chill.max_fps", "value": 144 } ] }
  1. 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 answers invalid_value or not_writable, naming the setting.
  2. 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.
  3. 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_rejected with that setting's id.
  4. 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:

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 }
}

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>" } ] } }
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": [ ... ] }

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." }
  ]
}
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 } ] }

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
    }
  ]
}
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"
}

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." }
}
POST /api/native/v1/neural/settings
{"app": "6F1D2C3B-4A59-4E2B-9C1D-2B3A4C5D6E7F", "switch": "frame_generation", "on": true, "accept_notice": true}

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
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.

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 } ] }
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 #

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": { "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:

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": 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 } ] }

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
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 #

Where the types live #

The API types live in a dependency-light crate inside client/protocol, re-exported by butterpollo-core:

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) #

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 #

  1. 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 idle with game_running: true, Resume becomes a new /launch or /resume of that game, and Close game works from there.
  2. Radeon writes need an owned session. v1 allows writes only for the owner of a streaming or suspended session, because the restore is tied to the end of that session. Per-game Radeon profiles cover settings chosen before launch.
  3. One GPU. v1 lists only the GPU that encodes the stream.
  4. Added games only. v1 lists the games in the host's library; installed games that have not been added are not listed.
  5. Polling. Clients poll /session and compare revision; there is no long poll.
  6. Covers only. Artwork is the cover image; hero and logo images are not served.
  7. Session actions replace Quit. A client that sees NativeApiVersion >= 1 offers the native session actions instead of Moonlight's "Quit app". The host keeps serving /cancel unchanged for stock Moonlight.
  8. A separate types crate. The types live in rubylight-native-api rather than butterpollo-core or rubylight-protocol, for the reasons in Where the types live.
  9. Probed settings. The host's probe of the installed driver decides which Radeon settings are listed and their ranges.

View this page on GitHub