18 KiB
Models
Stamp
Represents a document stamp.
| field | type | required | description |
|---|---|---|---|
stamp_id |
integer | - | UID for this stamp (unique amongst all stamps on all documents) |
document_id |
integer | yes | UID for the Document that this stamp belongs to. |
stamp_type |
string | yes | Stamp type, can be any string |
pos_x |
integer | yes | x coordinate |
pos_y |
integer | yes | y coordinate |
rotation |
float | yes | Rotation in radians |
POST/stamps- Create and return a
Stamp. - Should generally not be used directly. Instead, create the
Stampwith theDocumentor withPOST /documents/{document_id}/stamps
- Create and return a
PUT/stamps- Create and return a list of
Stamps. - Should generally not be used directly. Instead, create the
Stampswith theDocumentor withPUT /documents/{document_id}/stamps
- Create and return a list of
GET/stamps/{stamp_id}- Returns a
Stampwith the givenstamp_id, or raisesNot Foundif no stamp exists.
- Returns a
PATCH/stamps/{stamp_id}- Updates the given
Stamp. - Supports any settable field.
- Updates the given
DELETE/stamps/{stamp_id}- Delete the specified
Stamp.
- Delete the specified
Document
Represents a saved document, i.e. and image with a seal and optionally some stamps.
Will usually be associated with an Event, and event documents should generally be queried through the Event routes.
However, Document also supports CRUD operations separately for storing arbitrary non-event documents.
| field | type | required | description |
|---|---|---|---|
document_id |
integer | - | UID for this document |
document_data |
file | yes | Image data (not sure about the encoding yet) |
seal |
integer | yes | Seal integer |
created_at |
timestamp | no | When this document was created. Automatically set on creation. |
metadata |
string? | no | Optional arbitrary associated metadata. |
stamps |
[Stamp] |
no | List of stamps attached to this document. |
POST/documents- Create and return a
Document. - Stamps may be added to the document by passing a list of
Stamps in thestampsfield.
- Create and return a
GET/documents- Get all
Documents matching the given parameters. If no parameters are given, returns all documents. - Supported filter parameters:
document_idsealcreated_beforecreated_aftermetadatastamp_type- Filter documents by whether they have the given stamp type.
- Get all
GET/documents/{document_id}- Returns a
Documentwith the givendocument_id.
- Returns a
PATCH/documents/{document_id}- Updates the given
Document. - Supports updating
document_data,seal,metadata. - To update the stamps, use
/documents/{document_id}/stamps - Returns the updated
Document.
- Updates the given
DELETE/documents/{document_id}- Delete the given document, and all associated
Stamps. - Does not delete the associated
Eventif one exists. - Returns the deleted
Document.
- Delete the given document, and all associated
*/documents/{document_id}/stamps- Inherits all
/stampsroutes withdocument_idset.
- Inherits all
Event
An Event represents event data for one of the saved events.
This will typically have a Document attached with image data saved from the event.
Events may also be created without documents, in which case the document and document_id fields will be null.
| field | type | required | description |
|---|---|---|---|
event_id |
integer | - | UID for this event |
document_id |
integer? | - | UID of the associated document, if it exists. |
document |
Document? |
no | Associated Document, if it exists. |
user_id |
integer | yes | (Internal) UID of the user which triggered this event. |
user |
User |
no | User which triggered this event. |
user_name |
string | yes | Name of the user when they triggered this event. |
occurred_at |
timestamp | yes | When this event originally occurred. Will typically be earlier than created_at |
created_at |
timestamp | no | When this event was created. Automatically set on creation. |
event_type |
string in EventType |
yes | Type of the event. Must be one of the event types. |
Allowed and possible values for EventType are plain, subscriber, bit, raid.
The event_type must be specified when creating an event.
-
POST/events- Create a return a new
Event. - The
event_typemust be specified, and the additional fields for that event type should be considered. - The
documentshould be specified in the form of aDocument(as inPOST /documets). - The
usermay be specified in the form of aUser(as inPOST /user), in which caseuser_idis not required and will be filled from the createdUser.- Supplying both
user_idanduseris not supported. - If a
useralready exists with the giventwitch_id, then thatuserwill instead be updated with the given fields, and theuser_idof the existing user will be used to create theEvent. This behaviour is distinct to thePOST /userendpoint which will error if the user already exists.
- Supplying both
- Create a return a new
-
GET/events- Returns
eventsmatching the provided filters. - Intended to be the typical way of retrieving events and documents.
- Supported filter parameters:
event_iddocument_iddocument_seal- Filter by document sealuser_iduser_nameoccurred_beforeoccurred_aftercreated_beforecreated_afterevent_type
- Returns
-
GET/events/{event_id}- Returns an
Eventwith the givenevent_id.
- Returns an
-
PATCH/events/{event_id}- Updates and returns the given
Event. - Supports updating all added fields in the relevant event type.
- Does not support updating any of the base event fields.
- Updates and returns the given
-
DELETE/events/{event_id}- Delete and return the given
Event
- Delete and return the given
-
*/events/{event_id}/document- If the action is
POST, will create and return aDocumentfor this event. - Otherwise inherits the
/documents/{document_id}route with the associateddocument_id.- If there is no
documentassociated, will raiseNot Found.
- If there is no
- If the action is
-
*/events/{event_id}/user- Inherits the
/users/{user_id}route with the associateduser_id.
- Inherits the
-
It might make sense to add the subtype fields for filtering as well
PlainEvent
An Event of type plain has the following further fields.
| field | type | required | description |
|---|---|---|---|
message |
string | yes | Message for this event. |
SubEvent
An Event of type subscriber has the following further fields.
| field | type | required | description |
|---|---|---|---|
tier |
integer | yes | Tier of the subscription. |
subscribed_length |
integer | yes | Subscription length (not sure what the unit is?) |
message |
string | no | Subscription message. |
- What is the unit of
subscribed_length? Is it cumulative? Does it make any sense to havesubscription_startfor the start of the current subscription? messagewas not in the original spec, does it make sense to add?
CheerEvent
An Event of type cheer has the following further fields.
| field | type | required | description |
|---|---|---|---|
amount |
integer | yes | Number of bits cheered |
cheer_type |
string | no | Type of cheer |
message |
string | no | Message associated with the bit cheer. |
typewas not in the original spec, does it make sense?messageas well.
RaidEvent
An Event of type raid has the following further fields.
| field | type | required | description |
|---|---|---|---|
viewer_count |
integer | yes | Number of viewers who came with the raid. |
User
Represents a twitch user.
| field | type | required | description |
|---|---|---|---|
user_id |
integer | - | Internal UID of this user. (NOT the twitch userid) |
twitch_id |
string | yes | Twitch user-id for this user. Stored as a string. |
name |
string | yes | Twitch name for this user. May not be up to date. |
created_at |
timestamp | no | When this user was created (internally). Automatically set on creation. |
// The name is stored mainly for easy visual reference/convenience when debugging, and should not be relied on.
POST/users- Create and return a
User
- Create and return a
GET/users- Get all
Users matching the given parameters - Supported filter parameters:
user_idtwitch_idname- Supported, but should not typically be used.created_aftercreated_before
- Get all
GET/users/{user_id}- Get the
UserDetailsfor the given user.
- Get the
PATCH/users/{user_id}- Updates the given
User - Supports updating
twitch_idandname - Returns the updated
User
- Updates the given
DELETE/users/{user_id}- Deletes the given user, and all associated data. This includes:
- All
Events associated to the user (cascading as inDELETE /events/{event_id}) - All
Specimens associated to the user. - All
InventoryItems owned by the user. - All
Transactions made by the user.
- All
- Returns
UserDetailsof the deleted user.
- Deletes the given user, and all associated data. This includes:
*/users/{user_id}/events- Inherits all
/eventsroutes withuser_idset.
- Inherits all
*/users/{user_id}/specimen- If the action is
POST, will create and return aSpecimenfor this user.- Note that this will error if the user already has an active specimen.
- Otherwise inherits the
/specimens/{specimen_id}withspecimen_idset to the user's active specimen.- If the user does not have an active
Specimenthis will raiseNotFound.
- If the user does not have an active
- If the action is
*/user/{user_id}/specimens- Inherits all
/specimensroutes with theowner_idset touser_id.
- Inherits all
GET/users/{user_id}/wallet- Will return the current amount in the user's wallet.
- Not typically used and only included for route consistency.
*/users/{user_id}/transactions- Inherits all routes from the
/transactionsroute, withuser_idset.
- Inherits all routes from the
UserDetails
This is a convenience model presenting the current natural 'state' of the user,
including their current Specimen, their wallet, and their current inventory.
This is the model returned by GET /users.
Note that the specimen, inventory, and wallet fields cannot be set or updated directly,
instead use /users/{user_id}/specimen, /users/{user_id}/inventory, and /users/{user_id}/transactions respectively.
The wallet is viewable from /users/{user_id}/wallet, but does not support direct updates.
(All updates must occur through transactions.)
In addition to the fields from User, this model has the following fields
| field | type | required | description |
|---|---|---|---|
specimen |
Specimen? |
- | Current living specimen for this user if it exists. |
inventory |
[InventoryItem] |
- | List of active inventory items for this user. |
wallet |
integer | - | How much currency the user currently has. |
Specimen
Represents a specimen, remembered or forgotten.
| field | type | required | description |
|---|---|---|---|
specimen_id |
integer | - | UID of this specimen |
owner_id |
integer | yes | (Internal) id of the user who owns this specimen |
owner |
User |
no | User who owns this specimen |
born_at |
timestamp | no | When this specimen came into existence. Will be set to now if not given. |
forgotten_at |
timestamp? | no | When this specimen was forgotten. |
POST/specimens- Create and return a new
Specimen. - The
ownermay be specified in place of theowner_id. In this case it should be in the form of aUser(as inPOST /user).- Supplying both an
owner_idandowneris not supported. - If a
Useralready exists with the giventwitch_id, then thatUserwill instead be updated with the given fields, and theuser_idof the existingUserwill be used as theowner_idof the createdSpecimen.
- Supplying both an
- Create and return a new
GET/specimens- Returns
Specimens matching the provided filters. - Supported filter parameters:
specimen_idowner_idborn_afterborn_beforeforgotten- boolean, filters by whetherforgotten_atis set.forgotten_afterforgotten_before
- Returns
PATCH/specimens/{specimen_id}- Updates the given
Specimen - Supports updating
owner_id - I'm not sure why you would want to do this, but there you go
- This route is intended for future updates where
Specimenhas more metadata.
- Updates the given
DELETE/specimens/{specimen_id}- Deletes and returns the given
Specimen
- Deletes and returns the given
*/specimens/{specimen_id}/owner- Inherits all routes from the
/users/{user_id}route with the associatedowner_id.
- Inherits all routes from the
// Notably, the inheritance allows a lot of cyclic references. You can for example do GET /events/1/user/specimen/owner/specimen/user/... and obtain the expected response. Each level adds the relevant filter parameter or overwrites it if the parameter is already set.
InventoryItem
// TODO // Leaving this for now since I'm not sure how inventories should actually work. // There are a few different models with significant differences. // For example, are there any persistent items which don't need to be owned by a user? i.e. the item can be removed from a user's inventory but still exists and is now possibly useable by another user? Or are all items ephemeral and obtainable in certain quantities by users? Are items purchasable? Are there 'unique' items which can only exist once? Can users trade items or given them to the specimen (req specimen inventory).. etc. // So leaving this for now until there is a better idea of what items and inventories are since the model would probably need a rework anyway
Transaction
Represents a monetary transaction for a particular user.
| field | type | required | description |
|---|---|---|---|
transaction_id |
integer | - | UID for this transaction |
user_id |
integer | yes | (Internal) id of the user making the transaction. |
user |
User |
- | User making the transaction. |
amount |
integer | yes | Amount of currency added to the user's account. May be negative. |
description |
string | yes | Description of this transaction. |
reference |
string? | no | Optional reference string. |
created_at |
timestamp | - | Timestamp at which this transaction was performed. Cannot be set or modified. |
POST/transactions- Create and return a new
Transaction. - Note that unlike other models containing a
User, creation of a newUserwith aTransactionis not supported. Ensure the user exists before creating the transaction.
- Create and return a new
GET/transactions- Get all
Transactionsmatching the given parameters. - Supported filter parameters:
transaction_iduser_idamountdescriptionreferencecreated_beforecreated_after
- Get all
GET/transactions/{transaction_id}- Get the
Transactionfor the giventransaction_id
- Get the
PATCH/transactions/{transaction_id}- Not supported,
Transactionsare considered immutable.
- Not supported,
DELETE/transactions/{transaction_id}- Not supported.
Transactionscannot be individually deleted. - Note that if the
Useris deleted then the all theirTransactionswill also be deleted. - To reset or set a User's balance, submit a
Transactionwhich changes it to the desired value.
- Not supported.
*/transactions/{transaction_id}/user- Inherits all routes from
/users/{user_id}with the associateduser_id.
- Inherits all routes from