A Django app that automatically tracks API endpoint usage and helps manage endpoint deprecation.
- Middleware to track API endpoint usage
- Web interface to view API usage statistics
- Automatic deprecation marking for unused endpoints
- OpenAPI/Swagger integration via DRF Spectacular
- Configurable deprecation thresholds
- Install the package:
pip install api-usage-tracker- Add to
INSTALLED_APPS:
INSTALLED_APPS = [
...
'api_usage_tracker',
'rest_framework',
'drf_spectacular',
]- Add middleware:
MIDDLEWARE = [
...
'api_usage_tracker.middleware.APIUsageMiddleware',
]- Configure settings:
# Optional settings with defaults
API_USAGE_TRACKER = {
'DEPRECATION_DAYS': 90, # Mark as deprecated after 90 days of no usage
}The app automatically tracks API endpoint usage. Access the usage dashboard at /api-usage/.
- Overview of all API endpoints
- Usage statistics and trends
- Deprecated endpoint highlighting
- Last usage timestamps
- Total call counts
The app automatically marks deprecated endpoints in your OpenAPI/Swagger documentation when using DRF Spectacular.
- Clone the repository:
git clone https://github.com/yourusername/api-usage-tracker.git
cd api-usage-tracker- Install development dependencies:
pip install -e ".[dev]"pytest tests/pylint api_usage_tracker tests- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.