Table of Contents
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 | - | When this user was created (internally). Automatically set on creation. |
preferences |
string? | no | Arbitrary preference string, not used or read. |
// The name is stored mainly for easy visual reference/convenience when debugging, and should not be relied on.
Note that the twitch_id and name parameters are best-effort and there are some rare cases where they are unreliable:
-
If a user linked their twitch account to Discord, and then unlinked the twitch account or deleted it, then
twitch_idandnamemay benull. -
If a user linked multiple twitch accounts, then the returned
twitch_idandnamewill only be for one account.- In this rare case, filter parameters will still fetch the correct user. This may lead to technically unexpected behaviour, for example:
- Assume a user with
user_id10has linked twitch account1and later twitch account2. - Then both
GET /users?twitch_id=2andGET /users?twitch_id=1will return{"user_id": 10, "twitch_id": 1}.
- Assume a user with
- In this rare case, filter parameters will still fetch the correct user. This may lead to technically unexpected behaviour, for example:
-
Due to the general ephemeral nature of names, it is not recommended to rely on the
namefield in any way. It is included mainly for ease of debugging and reference. -
Currently there is no way of retrieving all the twitch accounts associated to a user. Is this needed?
-
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
nameandpreferences. - Intended to be extended to update other preference fields in future.
- 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. |