Skip to main content

Contests

Topic

channel.contests

Description

This topic provides real-time contest and prediction events published to Astro for WebSocket delivery. It covers contest state changes, vote/bet updates, and winner announcements.

Usage

Subscribe to this topic to receive notifications about contest activities, allowing you to build real-time prediction displays, betting interfaces, or sync contest state across multiple clients.

Message Structure

{
"id": "01KC4840ZZ1BAMK5R2V9QX9BNA",
"ts": "2025-01-15T14:30:00Z",
"type": "message",
"topic": "channel.contests",
"room": "577c0455f9a31ea72a36b2b3",
"data": {
"event": "state",
"payload": {}
}
}

Parameters

ParameterTypeDescription
roomstringChannel ID
data.eventstringEvent type: update, state, or winner
data.payloadobjectEvent-specific payload data

Events

EventDescription
updateVote/bet placed
stateContest state changed
winnerWinner selected

update

Sent when a user places a vote or bet on a contest option.

{
"event": "update",
"payload": {
"optionId": "507f1f77bcf86cd799439011",
"amount": 100,
"userId": "12345678"
}
}
ParameterTypeDescription
optionIdstringID of the option voted for
amountnumberAmount bet
userIdstringID of the user who placed the bet

state

Sent when the contest state changes.

{
"event": "state",
"payload": {
"state": "running",
"contestId": "507f1f77bcf86cd799439011"
}
}
ParameterTypeDescription
statestringNew state: created, running, ended, completed, refunded, or closed
contestIdstringContest ID (only present on start)

winner

Sent when a winner is selected.

{
"event": "winner",
"payload": {
"winnerId": "507f1f77bcf86cd799439011"
}
}
ParameterTypeDescription
winnerIdstringID of the winning option

State Transitions

created → running → closed → completed
↘ refunded
StateDescription
createdContest created but not started
runningAccepting bets
closedVoting stopped, awaiting winner selection
completedWinner selected, rewards distributed
refundedContest cancelled, bets returned

Data Types

Contest

FieldTypeDescription
channelstringChannel ID
titlestringContest title
descriptionstringContest description
minBetnumberMinimum bet amount
maxBetnumberMaximum bet amount
botResponsesbooleanWhether bot responses are enabled
optionsarrayArray of contest options
totalAmountnumberTotal amount bet across all options
totalUsersnumberTotal number of users who bet
durationnumberContest duration
startedAtstringISO 8601 timestamp when contest started
endedAtstringISO 8601 timestamp when contest ended
activebooleanWhether contest is active
statestringCurrent state: created, running, ended, completed, refunded, or closed

ContestOption

FieldTypeDescription
_idstringOption ID
commandstringCommand to vote for this option
titlestringOption title
totalAmountnumberTotal amount bet on this option
totalUsersnumberNumber of users who bet on this option
winnerbooleanWhether this option won