All pages

The API

Everything the page does, it does through the API under /api/v1/, and so can any other program: a script, a monitoring system, a client of your own. The Desktop App is one.

The promise

  • Within v1, requests, fields, states, codes and words are added. None is taken away or given another meaning.
  • A program leaves out what it does not know: an answer with more in it than expected is not wrong.
  • A change that would break a program gets /api/v2/, beside v1. v1 is then served on for at least twelve months and two minor releases, whichever is longer, with Deprecation and Sunset headers.
  • qkvm/api_v1.json, in every installed copy, lists each promised request: who may ask, what it takes and answers, its refusal codes, and since which version it is promised.
  • Other requests under /api/v1/ are the page's own and change with it.

The promised requests are listed on API requests.

Three ways in

WhoHowRoles
A personPOST /api/v1/login, then the qkvm_session cookie; every request that changes something also carries X-QKVM: 1viewer, operator, admin
A scriptAuthorization: Bearer qkvm_... with every request, no cookieviewer or operator, never admin
A wall screenPOST /api/v1/display with the key from its linkviewer

Bodies are JSON with a Content-Length, 64 KiB at the most, but for the two that carry a file. A field that is wrong is answered 422 invalid, and the message names the field, never its value.

Errors

Every refusal is {"code": "...", "message": "..."}. code is one word, for a program; message is a sentence fit to show a person.

StatusCommon codesMeans
401unauthorizedsign in again; do not loop
403forbidden, not_allowedthe header is missing, or the role does not allow it
404not_found, no_picturenot there, or not given to this account
409busy, machine_changedsomething else is under way, or the tile now points at another machine
422invalida field is wrong
429rate_limitedwait the seconds Retry-After says
502unreachable, auth_failed, action_failedthe device's
503locked, no_streamthe wall cannot reach its devices yet, or ask again shortly
504timeoutthe device did not answer

After an action, unreachable means nothing was sent. timeout and dropped mean it may have been done: never offer a blind retry of a power button.

The right machine

  • Send the machine's target, from GET /api/v1/wall, with an action. Where an admin has pointed the tile at another machine since, the action is refused with 409 machine_changed and nothing is sent.
  • On a KVM with several inputs, send input (the status's ports.active) with keys and text. Where another input is on screen, they are refused with 409 input_changed.

What a machine can do

Each machine's can lists what it can be asked: screen, keys, text, power, reset, live, control, media and more. Build buttons from can, never from the kind of device. A word you have not met was added since: leave it out.

Manners

  • Ask for the status, and for a tile's picture, no more often than the wall's interval.
  • Do not ask in the background for a window nobody sees.
  • Ask before power, a reset, a restart, and anything sent to several machines, as the page does.

Full reference