Base URL
All leaderboard endpoints are prefixed with/api/game/leaderboard/{leaderboardId}/
.
Authentication
All leaderboard endpoints require a valid JWT token in the Authorization header:Get Leaderboard
Retrieve the current leaderboard rankings for a specific leaderboard. Endpoint:GET /api/game/leaderboard/{leaderboardId}
Headers:
page
(optional): Page number for pagination (default: 1)
Submit Score
Submit a player’s score to the leaderboard. Endpoint:POST /api/game/leaderboard/{leaderboardId}
Headers:
Leaderboard Management
Leaderboards are created and managed through the CrateBytes dashboard. Each leaderboard has a unique ID that you’ll use in the API calls.Error Responses
Unauthorized
Invalid Leaderboard
Invalid Score
Missing Parameters
Best Practices
- Score Format: Scores should be submitted as strings to handle large numbers
- Pagination: Use pagination for large leaderboards to improve performance
- Rate Limiting: Avoid submitting scores too frequently
- Error Handling: Always handle potential errors when submitting scores