Court Command device API

Every Court Command controller is a small web server. Its scoring pages drive it through the calls below, and so can anything else on the same network: a tablet app, a streaming overlay, or a script. On a device the base address is http://cc.local/ (or its IP address). On this site the same API runs at /device/ against a simulated board, one per visitor, which is what powers the live demo. Try every command from a page of links.

Conventions

GET /api/score

Without an Action it returns the board. Pages poll it once a second; polling faster than that gains nothing because the device transmits to the scoreboard at 20 Hz and the clock is reported to the millisecond anyway.

{
  "Clock": 472300,            // milliseconds; -1 = blank
  "Running": 1,               // 1 while the clock counts down
  "Suspended": 0,             // 1 while a time-out clock has replaced the game clock
  "Period": 2,                // -1 blank .. 9
  "Home":    { "Score": 15, "Fouls": [ { "Player": "9", "Fouls": 1 }, { "Player": "23", "Fouls": 2 } ], "Posession": 1, "Bonus": 0 },
  "Visitor": { "Score": 11, "Fouls": [], "Posession": 0, "Bonus": 1 },
  "Horn": 0,                  // remaining horn, twentieths of a second
  "HornOnStop": 0             // horn length queued for the next clock stop
}

Posession is spelled with one s in the middle, as the firmware spells it. Team fouls are the sum of the player fouls.

Actions

ActionTeamPlayerValueEffect
Score (s)yespoints to add; -200 clearsScore clamped to -1..199.
Posession (ps)yesToggles the team's possession (or serve) and clears the other team's.
Bonus (b)yesToggles the team's bonus indicator.
Fouls (f)yesjersey numberfouls to addPer-player count 0..9; a player at 0 drops off the list.
Period (q)periods to add; -9 clears-1..9. Volleyball pages use it for the set number.
Clock (c)milliseconds; -1 blanksSets and stops the clock. Max 99:59.
ClockAdjust (ca)milliseconds, signedAdds to the clock and stops it; never below 0.
ClockRun (cr)Starts the clock. It runs on the device; read it back from the board.
ClockStop (cs)Stops the clock and sounds the queued HornOnStop, if any.
ClockClear (cc)Same as Clock with -1.
Horn (h)1..20 (twentieths of a second)Sounds the horn now.
HornOnStop (hs)1..20Queues a horn for the next ClockStop.
Hornscomma-separated clock values (ms)Sounds the horn as the running clock passes each value.
TimeOut (to)millisecondsParks the game clock and runs a time-out clock in its place (Suspended becomes 1); scores stay on the board. When it reaches zero the horn sounds and the game clock comes back, stopped.
TimeIn (ti)Ends a time-out early: the game clock comes back, stopped.

The horn also sounds for BuzzerLength ticks when a running clock reaches zero.

GET /api/game

Game metadata that the board does not show. Action: New (clears the board and starts a log), End, Title, Home, Visitor, Sport, Level, League, Conference, Division, Location, DateTime; Value is the text. Returns the game record.

GET /api/settings

Action names the setting, Value the new value: ClockFastFormat (00:00, 0:00 or 0:0 ), ClockFastTime (seconds, 1..100: below this the board shows tenths), BuzzerLength (1..20 ticks), FoulDisplayLength (seconds, 1..100), DateFormat. Returns all settings.

GET /api/logs

Action: List, Download (Value = name), Delete (Value = name). A log is every command since game?a=New, one line each: "<milliseconds since start> <command>". Replaying a log reproduces a game.

Pages and styles

The device keeps one page per sport, basketball.html and volleyball.html, in its own file system and serves them at its root. A style is a complete, self-contained page file. Court Command offers several, for phones and for tablets, and anyone can write their own: a page only has to call api/score as described above and may include nothing from the network (the device may be on its own access point with no internet).

CallEffect
GET /api/stylesThe catalog of available styles (see it): id, sport, name, device (phone, tablet or any), file, version, description. Published by this site; the device fetches it when it is on a network with internet access.
GET /api/styleWhich style each sport's page currently is.
POST /api/style?sport=basketball&style=tabletCopies that style over the sport's page (the device downloads it first, then copies). The page's address does not change.
GET /api/filesLists the page files on the device.
POST /api/filesUploads your own page over a sport's page (multipart form file). Disabled on this demo.
DELETE /api/files?name=basketball.htmlRemoves an uploaded page; the device falls back to its built-in classic page.

Each style file carries <meta name="cc-style" content="sport/id/version"> so the device can show what is installed and whether the catalog has a newer version.

GameDay Scores

Court Command is the source of truth for the clock and the board. The GameDay Scores scorekeeper tablet drives the board through this same API on the gym's network and reads the clock back from it, so a live stream's score overlay and the published play-by-play stay in step with what the crowd sees. A device setting to report the board to GameDay Scores directly is planned; until then the tablet is the bridge.