Save and retrieve chess practice sessions with complete move history and analysis data.
All endpoints in this API require valid user authentication. Unauthenticated requests will receive 401 Unauthorized.
/api/user/practice-sessionsSaves a new practice session for the authenticated user.
{
"openingId": "string (optional)",
"moves": "string (required)",
"finalFen": "string (required)",
"movesCount": "number (required)"
}const response = await fetch('/api/user/practice-sessions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
openingId: 'clk9x8d4q0001vq2o6q7q8r9s',
moves: 'e4 e5 Nf3 Nc6 Bb5',
finalFen: 'r1bqkbnr/pppp1ppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R',
movesCount: 5
})
});{
"success": true,
"practiceSession": {
"id": "string",
"movesCount": 5,
"createdAt": "2024-01-15T10:30:00.000Z"
}
}{
"error": "Missing required fields",
"details": {
"moves": false,
"finalFen": true,
"movesCount": true
}
}/api/user/practice-sessionsRetrieves a paginated list of the authenticated user's practice sessions.
pagelimit// Fetch practice sessions with pagination
const response = await fetch('/api/user/practice-sessions?page=1&limit=10');
const data = await response.json();
console.log(data.practiceSessions); // Array of session objects
console.log(data.total); // Total number of sessions
console.log(data.page); // Current page number
console.log(data.totalPages); // Total number of pages{
"practiceSessions": [
{
"id": "string",
"userId": "string",
"openingId": "string",
"moves": "string",
"finalFen": "string",
"movesCount": 15,
"createdAt": "2024-01-15T10:30:00.000Z",
"opening": {
"id": "string",
"name": "Ruy Lopez",
"eco": "C60",
"fen": "string",
"pgn": "string",
"totalVisits": 150,
"totalFavorites": 25,
"totalPracticeSessions": 75
}
}
],
"total": 45,
"page": 1,
"totalPages": 3
}