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:
cottongin
2026-03-15 19:16:23 -04:00
parent e9add95efa
commit 3ed3af06ba
5 changed files with 262 additions and 0 deletions

View File

@@ -979,6 +979,46 @@ paths:
"401": { $ref: "#/components/responses/Unauthorized" }
"403": { $ref: "#/components/responses/Forbidden" }
/api/sessions/{id}/votes:
get:
operationId: getSessionVotes
summary: Get per-game vote breakdown for a session
tags: [Sessions]
parameters:
- name: id
in: path
required: true
schema: { type: integer }
description: Session ID
responses:
"200":
description: Per-game vote aggregates for the session
content:
application/json:
schema:
type: object
required: [session_id, votes]
properties:
session_id:
type: integer
votes:
type: array
items:
type: object
properties:
game_id: { type: integer }
title: { type: string }
pack_name: { type: string }
upvotes: { type: integer }
downvotes: { type: integer }
net_score: { type: integer }
total_votes: { type: integer }
"404":
description: Session not found
content:
application/json:
schema: { $ref: "#/components/schemas/Error" }
/api/sessions/{id}/chat-import:
post:
operationId: importSessionChat
@@ -1399,6 +1439,72 @@ paths:
upvotes: { type: integer }
downvotes: { type: integer }
/api/votes:
get:
operationId: listVotes
summary: Paginated vote history with filtering
tags: [Votes]
parameters:
- name: session_id
in: query
schema: { type: integer }
description: Filter by session
- name: game_id
in: query
schema: { type: integer }
description: Filter by game
- name: username
in: query
schema: { type: string }
description: Filter by voter
- name: vote_type
in: query
schema: { type: string, enum: [up, down] }
description: Filter by direction
- name: page
in: query
schema: { type: integer, default: 1 }
description: Page number
- name: limit
in: query
schema: { type: integer, default: 50, maximum: 100 }
description: Results per page (max 100)
responses:
"200":
description: Paginated vote records
content:
application/json:
schema:
type: object
required: [votes, pagination]
properties:
votes:
type: array
items:
type: object
properties:
id: { type: integer }
session_id: { type: integer }
game_id: { type: integer }
game_title: { type: string }
pack_name: { type: string }
username: { type: string }
vote_type: { type: string, enum: [up, down] }
timestamp: { type: string, format: date-time }
created_at: { type: string, format: date-time }
pagination:
type: object
properties:
page: { type: integer }
limit: { type: integer }
total: { type: integer }
total_pages: { type: integer }
"400":
description: Invalid filter parameter
content:
application/json:
schema: { $ref: "#/components/schemas/Error" }
/api/votes/live:
post:
operationId: recordLiveVote