Predictions
Endpoints for managing user predictions on match outcomes.
Create Prediction
Submit a prediction for a match.
Endpoint
POST /api/auth/predictions
Request
json
{
"event_id": 1,
"prediction": "home",
"score_prediction": {
"home": 2,
"away": 1
},
"confidence": 80
}
Fields
prediction
- Required. One of: "home", "draw", "away"score_prediction
- Optional. Exact score predictionconfidence
- Optional. Confidence level (0-100)
Response
json
{
"message": "Prediction created successfully",
"data": {
"id": 123,
"user_id": 1,
"event_id": 1,
"prediction": "home",
"score_prediction": {
"home": 2,
"away": 1
},
"confidence": 80,
"points_earned": null,
"created_at": "2024-01-15T10:00:00Z"
}
}
Error Responses
400
- Event has already started404
- Event not found422
- Invalid prediction data
Get Chat Room Predictions
Get all predictions for a specific chat room.
Endpoint
GET /api/auth/chat-rooms/{chatRoom}/predictions
Response
json
{
"data": [
{
"id": 123,
"user": {
"id": 1,
"username": "user123",
"name": "John Doe"
},
"prediction": "home",
"score_prediction": {
"home": 2,
"away": 1
},
"confidence": 80,
"points_earned": 10,
"created_at": "2024-01-15T10:00:00Z"
},
{
"id": 124,
"user": {
"id": 2,
"username": "user456",
"name": "Jane Smith"
},
"prediction": "draw",
"score_prediction": null,
"confidence": 60,
"points_earned": 5,
"created_at": "2024-01-15T10:30:00Z"
}
],
"meta": {
"total_predictions": 150,
"home_predictions": 80,
"draw_predictions": 30,
"away_predictions": 40
}
}
Get Event Predictions
Get all predictions for a specific event.
Endpoint
GET /api/auth/events/{event}/predictions
Query Parameters
user_id
(optional) - Filter by specific userprediction
(optional) - Filter by prediction type
Response
json
{
"data": [
{
"id": 123,
"user": {
"id": 1,
"username": "user123",
"name": "John Doe"
},
"prediction": "home",
"score_prediction": {
"home": 2,
"away": 1
},
"confidence": 80,
"points_earned": null,
"created_at": "2024-01-15T10:00:00Z"
}
],
"meta": {
"total_predictions": 200,
"prediction_distribution": {
"home": 100,
"draw": 60,
"away": 40
},
"average_confidence": 72.5
}
}
Notes
- Predictions can only be made before event starts
- Points are calculated after event finishes
- Users can update predictions until event starts