HTTP Status Codes
The LoL Tracker API uses standard HTTP status codes to indicate the success or failure of requests.Success Responses
| Status Code | Description | When It Occurs |
|---|---|---|
200 OK | Successful request | Data retrieved successfully from both player and match history endpoints |
Error Responses
| Status Code | Description | When It Occurs |
|---|---|---|
500 Internal Server Error | Server-side error | Issues communicating with Riot API, invalid player name/tag, or API key problems |
The API currently uses a catch-all 500 error response for all failure scenarios. This simplifies error handling but means you’ll need to check the error message for specific details.
Response Formats
Success Response Structure
When a request succeeds, you’ll receive a200 status code with a JSON response body.
Player endpoint (/api/jugador/:nombre/:tag):
/api/historial/:nombre/:tag):
Error Response Structure
When a request fails, you’ll receive a500 status code with this JSON structure:
Common Error Scenarios
1. Invalid Player Name or Tag
Cause: The player name/tag combination doesn’t exist in Riot’s database. What happens in the code:- The initial Riot API call fails at
index.js:26-29(player endpoint) orindex.js:76-83(match history endpoint) - Error is caught and returns 500 status
2. Invalid or Expired API Key
Cause: TheRIOT_API_KEY environment variable is missing, invalid, or expired.
What happens in the code:
- Riot API rejects the request due to authentication failure
- Error caught at
index.js:65-67orindex.js:201-203
- Verify your
.envfile contains a validRIOT_API_KEY - Ensure the API key hasn’t expired (Riot development keys expire after 24 hours)
- Check the server console for detailed Riot API error messages
3. Riot API Service Issues
Cause: Riot’s API is experiencing downtime or rate limiting. What happens in the code:- Any of the multiple
axios.get()calls to Riot API fail - Error propagates to catch block
- Implement retry logic with exponential backoff
- Check Riot API Status page
- Monitor rate limits (see Rate Limits page)
4. Match History Errors
Cause: Invalid pagination parameters or issues fetching match details. What happens in the code:- The loop at
index.js:102-196makes multiple API calls - If any single match detail fetch fails, the entire request fails
- Invalid
inicioorcantidadquery parameters - Match data temporarily unavailable
- Rate limit exceeded during the loop
Why does the match history endpoint fail more often?
Why does the match history endpoint fail more often?
The match history endpoint makes multiple sequential API calls to Riot:
- One call to get the player’s PUUID (
index.js:76-83) - One call to get match IDs (
index.js:89-96) - One call per match to get detailed match data (
index.js:104-107)
Debugging Errors
The backend logs detailed error information to the console that isn’t exposed to the client.Server-Side Logging
When the match history endpoint fails, check the server console for:index.js:202) includes:
- The full Riot API error response (
error.response?.data) - Or the error message if the response isn’t available
Request Tracking
Every player search logs this to the console:index.js:23 and helps you track which requests are being processed.
Best Practices
Always implement client-side error handling for all API requests, even if you expect them to succeed.
-
Check response status codes
-
Implement timeouts
- Match history requests can take several seconds due to multiple API calls
- Set appropriate timeout values (recommended: 30+ seconds)
-
Validate input before sending
- Ensure player names and tags are properly formatted
- Validate
inicioandcantidadparameters are positive integers
-
Cache successful responses
- Player stats don’t change instantly
- Match history is immutable once games complete
- Reduces errors from rate limiting
-
Monitor server logs
- The generic client error message hides important details
- Server console shows the actual Riot API error responses
Error Response Examples
Player Not Found
Request:API Key Error
Request:Rate Limit Exceeded
Request:Related Resources
- Rate Limits - Understanding API rate limits and how to stay within them
- Player Endpoint - Using the player stats endpoint
- Match History Endpoint - Using the match history endpoint with pagination