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.
There are four types of events ('PlainEvent', 'SubEvent', 'CheerEvent', 'RaidEvent'), identified by their event_type field.
The API will only ever accept or return these four concrete types, and never the abstract Event type. However, the abstraction is useful since multi-value endpoints such as GET /events will return a combination of these concrete types, which we shall just refer to as Events.
Fields
| 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 | - | 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, cheer, raid.
The event_type must be specified when creating an event (you cannot create a base Event, only one of the following four event types).
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. |
Routes
-
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 /documents), however, may be specified as adocument_idinstead to attach to an existing document. - 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 /usersendpoint 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 - Note this will also delete the associated
Document.
- 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