-
Notifications
You must be signed in to change notification settings - Fork 0
Formation API
Liam Boudadi edited this page Feb 10, 2025
·
19 revisions
This documentation provides details about all available endpoints related to formations, quizzes, videos, and badges. Endpoints are grouped into the following categories:
Note: The user's email is extracted from the JWT, so there is no need to supply it via a header.
GET /formation/formations (gets all in-memory formations details)
None
HTTP Code Content-Type Response 200json[{"id": int, "name": "string", "description": "string", ...}, ...]
curl -L -X GET 'http://localhost:8080/formation/formations' \ -H 'Authorization: Bearer {jwt}'
GET /formation/{formationId} (gets details about the formation requested)
Name Type Data Type Description formationId required int The specific formation id
HTTP Code Content-Type Response 200json{"id": int, "name": "string", "description": "string", ...}404stringFormation not found
curl -L -X GET 'http://localhost:8080/formation/{formationId}' \ -H 'Authorization: Bearer {jwt}'
GET /formation/quizzes (gets all in-memory quizzes details)
None
HTTP Code Content-Type Response 200json[{"id": int, "json": "string", ...}, ...]
curl -L -X GET 'http://localhost:8080/formation/quizzes' \ -H 'Authorization: Bearer {jwt}'
GET /formation/quiz/{quizId} (gets details about the quiz requested)
Name Type Data Type Description quizId required int The specific quiz id
HTTP Code Content-Type Response 200json{"id": int, "json": "string", ...}404stringQuiz not found
curl -L -X GET 'http://localhost:8080/formation/quiz/{quizId}' \ -H 'Authorization: Bearer {jwt}'
POST /formation/quiz/score (save user score for a quiz)
The request body must be a JSON object containing:
Name Type Data Type Description userEmail required string The email of the user (extracted from JWT) quizId required int The id of the quiz score required float The score (must be between 0 and 1)
HTTP Code Content-Type Response 200stringScore saved successfully400stringInvalid requestorScore must be between 0 and 1500stringError saving score
curl -L -X POST 'http://localhost:8080/formation/quiz/score' \ -H 'Authorization: Bearer {jwt}' \ -H 'Content-Type: application/json' \ --data-raw '{"userEmail": "email.test@gmail.com", "quizId": 1, "score": 0.8}'
GET /formation/quizzes/scores (gets all the quiz scores of the connected user)
None (User email is extracted from the JWT)
HTTP Code Content-Type Response 200json[{"userEmail": "string", "quizId": int, "score": float}, ...]404N/A Not Found (if no scores exist)
curl -L -X GET 'http://localhost:8080/formation/quizzes/scores' \ -H 'Authorization: Bearer {jwt}'
GET /formation/quiz/score/{quiz_id} (gets the selected quiz score of the connected user)
Name Type Data Type Description quiz_id required int The specific quiz id
HTTP Code Content-Type Response 200jsonThe score as a float 404stringScore not found
curl -L -X GET 'http://localhost:8080/formation/quiz/score/{quiz_id}' \ -H 'Authorization: Bearer {jwt}'
GET /formation/videos (gets all in-memory videos details)
None
HTTP Code Content-Type Response 200json[{"id": int, "title": "string", "description": "string", "url": "string", ...}, ...]
curl -L -X GET 'http://localhost:8080/formation/videos' \ -H 'Authorization: Bearer {jwt}'
POST /formation/video/watched/{videoId} (marks a video as watched for the connected user)
Name Type Data Type Description videoId required int The specific video id
HTTP Code Content-Type Response 200stringVideo watched404stringVideo not found
curl -L -X POST 'http://localhost:8080/formation/video/watched/1' \ -H 'Authorization: Bearer {jwt}'
GET /formation/videos/watched (gets all videos watched by the connected user)
None (User email is extracted from the JWT)
HTTP Code Content-Type Response 200json[{"id": int, "title": "string", "description": "string", "url": "string", ...}, ...]
curl -L -X GET 'http://localhost:8080/formation/videos/watched' \ -H 'Authorization: Bearer {jwt}'
POST /formation/badge/claim/{badgeId} (claim a badge for the connected user)
Name Type Data Type Description badgeId required int The specific badge id
HTTP Code Content-Type Response 200jsonJSON representation of the claimed badge 404stringBadge not found
curl -L -X POST 'http://localhost:8080/formation/badge/claim/1' \ -H 'Authorization: Bearer {jwt}'
GET /formation/badge/all (gets all badges for the connected user)
None (User email is extracted from the JWT)
HTTP Code Content-Type Response 200json[{"id": int, "name": "string", "description": "string", ...}, ...]
curl -L -X GET 'http://localhost:8080/formation/badge/all' \ -H 'Authorization: Bearer {jwt}'
GET /formation/badge/{badgeId} (gets details about the badge requested)
Name Type Data Type Description badgeId required int The specific badge id
HTTP Code Content-Type Response 200json{"id": int, "name": "string", "description": "string", ...}404stringBadge not found
curl -L -X GET 'http://localhost:8080/formation/badge/1' \ -H 'Authorization: Bearer {jwt}'