Skip to main content

Overview

FootyCollect implements rate limiting to prevent abuse and ensure fair usage of API resources. Rate limiting is enforced at two levels:
  1. DRF Throttling - For internal API endpoints (/api/)
  2. django-ratelimit - For external API proxy endpoints (/fkapi/)
Rate limits apply per IP address for anonymous users and per user account for authenticated users.

DRF API Rate Limits (/api/)

Internal API endpoints use Django REST Framework’s throttling system with configurable rates.

Default Throttle Rates

Throttle Classes

The API uses two throttle classes:
Authenticated users have 5x higher rate limits than anonymous users. Register and authenticate to increase your quota.

Customizing Throttle Rates

You can customize throttle rates using environment variables:

FKAPI Rate Limits (/fkapi/)

External API proxy endpoints use django-ratelimit for IP-based rate limiting.

Rate Limit Configuration

Protected Endpoints

The following endpoints are rate-limited:
  • GET /fkapi/clubs/search/ - Search clubs
  • GET /fkapi/clubs/{club_id}/seasons/ - Get club seasons
  • GET /fkapi/clubs/{club_id}/seasons/{season_id}/kits/ - Get kits
  • GET /fkapi/kits/search/ - Search kits
  • GET /fkapi/kits/{kit_id}/ - Get kit details
  • GET /fkapi/brands/search/ - Search brands
  • GET /fkapi/competitions/search/ - Search competitions
  • GET /fkapi/seasons/search/ - Search seasons
  • GET /fkapi/filters/ - Get filter options

Implementation

Rate limiting is implemented using the @ratelimit decorator:
FKAPI rate limits are IP-based and apply regardless of authentication status. All users from the same IP share the same quota.

Rate Limit Headers

When rate limits are exceeded, the API returns custom headers to help you track your usage.

FKAPI Response Headers

Example Rate Limit Response

HTTP Status Codes

429 Too Many Requests

When you exceed the rate limit, you’ll receive a 429 Too Many Requests response. DRF API Response:
FKAPI Response:

Handling Rate Limits

Exponential Backoff

Implement exponential backoff to handle rate limit errors gracefully:

Rate Limit Monitoring

Track your rate limit usage to avoid hitting limits:

Best Practices

Anonymous users are limited to 20 requests/hour on DRF endpoints. Authenticate to get 100 requests/hour.
Cache API responses to reduce the number of requests:
Instead of making multiple individual requests, batch operations where supported:
Always implement retry logic with exponential backoff:
Track API usage to avoid unexpected rate limiting:
  • Log all API requests with timestamps
  • Monitor rate limit headers in responses
  • Set up alerts before hitting limits
  • Review usage patterns to optimize requests

Rate Limit Configuration

Environment Variables

Configure rate limits using environment variables in production:

Custom Throttle Rates

For custom deployments, you can modify throttle rates in config/settings/base.py:

Exception Handling

FootyCollect uses a custom DRF exception handler:
This ensures consistent error responses across all API endpoints.

Requesting Higher Limits

If you need higher rate limits for production use:
  1. Contact support via GitHub Issues
  2. Describe your use case and required limits
  3. Provide details about your application
Higher rate limits are evaluated on a case-by-case basis for legitimate production use cases.

Summary

Next Steps