docs: add vote tracking endpoints to API documentation
Update REST endpoint docs (votes.md, sessions.md), WebSocket protocol (websocket.md), OpenAPI spec, and voting guide with the new GET /api/votes, GET /api/sessions/:id/votes, and vote.received event. Made-with: Cursor
This commit is contained in:
@@ -15,6 +15,7 @@ Sessions represent a gaming night. Only one session can be active at a time. Gam
|
||||
| POST | `/api/sessions/{id}/close` | Bearer | Close a session |
|
||||
| DELETE | `/api/sessions/{id}` | Bearer | Delete a closed session |
|
||||
| GET | `/api/sessions/{id}/games` | No | List games in a session |
|
||||
| GET | `/api/sessions/{id}/votes` | No | Get per-game vote breakdown for a session |
|
||||
| POST | `/api/sessions/{id}/games` | Bearer | Add a game to a session |
|
||||
| POST | `/api/sessions/{id}/chat-import` | Bearer | Import chat log for vote processing |
|
||||
| GET | `/api/sessions/{id}/export` | Bearer | Export session (JSON or TXT) |
|
||||
@@ -369,6 +370,57 @@ curl "http://localhost:5000/api/sessions/5/games"
|
||||
|
||||
---
|
||||
|
||||
## GET /api/sessions/{id}/votes
|
||||
|
||||
Get per-game vote breakdown for a session. Aggregates votes from the `live_votes` table by game. Results ordered by `net_score` DESC.
|
||||
|
||||
### Authentication
|
||||
|
||||
None.
|
||||
|
||||
### Path Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|------|------|-------------|
|
||||
| id | integer | Session ID |
|
||||
|
||||
### Response
|
||||
|
||||
**200 OK**
|
||||
|
||||
```json
|
||||
{
|
||||
"session_id": 5,
|
||||
"votes": [
|
||||
{
|
||||
"game_id": 42,
|
||||
"title": "Quiplash 3",
|
||||
"pack_name": "Party Pack 7",
|
||||
"upvotes": 14,
|
||||
"downvotes": 3,
|
||||
"net_score": 11,
|
||||
"total_votes": 17
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Returns 200 with an empty `votes` array when the session has no votes.
|
||||
|
||||
### Error Responses
|
||||
|
||||
| Status | Body | When |
|
||||
|--------|------|------|
|
||||
| 404 | `{ "error": "Session not found" }` | Invalid session ID |
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
curl "http://localhost:5000/api/sessions/5/votes"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## POST /api/sessions/{id}/games
|
||||
|
||||
Add a game to a session. Side effects: increments game `play_count`, sets previous `playing` games to `played` (skipped games stay skipped), triggers `game.added` webhook and WebSocket event, and auto-starts room monitor if `room_code` is provided.
|
||||
|
||||
Reference in New Issue
Block a user