Skip to main content

Overview

The Football Kit Archive API uses standard HTTP status codes and returns consistent error responses in JSON format. All errors include a detail field with a human-readable error message.

Error Response Format

All error responses follow this structure:
From fkapi/api.py:178-183:

HTTP Status Codes

200 OK

Request succeeded. Returns the requested resource(s).
Response:

400 Bad Request

Invalid request parameters or validation errors.

Invalid Parameters

Response:

Invalid Color

From fkapi/api.py:834-836:
Response:

Invalid Design

From fkapi/api.py:858-861:
Response:

Invalid Season

From core/exceptions.py:57-70:
Response:

Bulk Kit Errors

From fkapi/api.py:1358-1361:
Response:
or

401 Unauthorized

Missing or invalid API key (only when authentication is enabled).
Response:
Solution: Include a valid API key in the request header:

403 Forbidden

Rate limit exceeded. From core/middleware.py:70-71:
Response:
Solution: Wait until the rate limit window resets (1 hour) or implement exponential backoff:

404 Not Found

Requested resource does not exist.

Kit Not Found

From core/exceptions.py:25-38:
Error handler from fkapi/api.py:236-250:
Response:

Club Not Found

From core/exceptions.py:41-54:
Response:

500 Internal Server Error

Unexpected server error. From fkapi/api.py:253-264:
Production Response:
Development Response (DEBUG=True):

503 Service Unavailable

Database or cache connection failed. From fkapi/api.py:301-308:
Response:

Exception Classes

From core/exceptions.py:

ScrapingError (Base Exception)

KitNotFoundError

Status Code: 404

ClubNotFoundError

Status Code: 404

InvalidSeasonError

Status Code: 400

RateLimitExceededError

Status Code: 403

ValidationError

Status Code: 400

Error Handling Examples

Python

JavaScript

Best Practices

1. Always Check Status Codes

2. Implement Retry Logic

3. Handle Rate Limits Gracefully

4. Log Errors

5. Provide User-Friendly Messages

Debugging Errors

Enable Debug Mode

In development, set DEBUG=True to get detailed error messages:
This will include stack traces in 500 error responses.

Check Server Logs

Test Error Handling

Rate Limiting

Learn about rate limits and 403 errors

Authentication

Understand 401 authentication errors