Docs Releases Log in

API

Datastores

Endpoint Methods
/api/gm/<game_id>/datastores/ GET
/api/ds/<datastore_id>/ GET
/api/ds/<datastore_id>/rules/ PUT
/api/ds/<datastore_id>/records/ GET POST
/api/ds/<datastore_id>/records/<key>/ GET PATCH DELETE

Objects

Shapes that more than one endpoint answers with. Fields marked as the tenant's appear only in answers to your own server's calls.

Datastore

Datastore {
  id: string,
  name: string,
  game: string,                 // the game's id
  rules: { [rule]: level },     // a level for each of read, create and contribute
  records: int,                 // how many it holds
  max_records: int,
  player_max_records: int,      // what one player may own in it
  max_record_bytes: int,        // the largest one record's data may be, as JSON
}

Record

Record {
  key: string,
  owner: string | null,         // the player who made it; null for the tenant
  data: object,                 // whatever the game keeps in it
  exposed: { [field]: object }, // the fields others may change, and how; each is
                                // { op: "incr" | "set", level: "player" | "registered",
                                //   once_per_player: bool, amount: [int, int] (incr only) }
  created: string,              // ISO datetime
  updated: string,              // ISO datetime
}

/api/gm/<game_id>/datastores/

Method What it does Permission Game client
GET The game's datastores. gm:<game_id>:datastores Yes

GET

Answers:

{ datastores: [{ id: string, name: string }] }

/api/ds/<datastore_id>/

Method What it does Permission Game client
GET The datastore's rules and limits. ds:<datastore_id>:details Yes

GET

Answers a Datastore.

/api/ds/<datastore_id>/rules/

Method What it does Permission Game client
PUT {rules} Replace the datastore's rules. ds:<datastore_id>:configure No

rules names a level for each of read, create and contribute.

PUT

Answers the Datastore, with its new rules.

/api/ds/<datastore_id>/records/

Method What it does Permission Game client
GET ?order=&owner=&prefix=&limit=&offset= List records. ds:<datastore_id>:records Yes
POST {key, data, exposed} Make one. ds:<datastore_id>:records Yes

order is key (the default), created, updated or the name of a field of the data, with - in front to reverse it: -plays puts the most played first. Records without the field come last. owner is a player id, or me; prefix keeps the records whose key starts with it.

Whoever makes a record owns it. exposed says which of its fields others may change; see Record.

GET

Answers:

{
  records: [Record],
  count: int,                   // how many match, across all pages
  offset: int,
  limit: int,
}

POST

Answers 201 with the new Record.

/api/ds/<datastore_id>/records/<key>/

Method What it does Permission Game client
GET One record. ds:<datastore_id>:records Yes
PATCH {set, unset, incr, exposed} Change it. ds:<datastore_id>:records Yes
DELETE Remove it. ds:<datastore_id>:records Yes

A change is applied all together or not at all. set is an object of fields and their new values, unset a list of fields to remove, incr an object of fields and the numbers to add to them, and exposed replaces the record's exposure. The owner may do all of it; anybody else may only set and incr the fields the owner has exposed for that, within the amounts allowed. An incr on an exposed field follows its limits even for the owner, who can set it instead.

A once-per-player field that this player has already changed is left as it is and named in skipped; it is not an error. Only the owner may delete a record.

GET

Answers the Record.

PATCH

Answers:

Record & {
  skipped: [string],            // once-per-player fields this player had already changed
}

DELETE

Answers:

{ deleted: string }             // the record's key

This page is generated from Scoreboat's source code, so it always matches the version you are reading it on.