Treblle SDK for Django - Production-ready API monitoring and intelligence platform
Project description
Treblle - API Intelligence Platform
Website • Documentation • Pricing
Treblle is an API intelligence platfom that helps developers, teams and organizations understand their APIs from a single integration point.
Treblle Django SDK
Requirements
- Python: 3.7 or higher
- Django: 2.2 or higher
- requests: 2.25.0 or higher
Note: Django 5.0+ requires Python 3.10 or higher. If you're using Django 5.x, ensure you have Python 3.10+.
Getting Started
You can install Treblle for django via PyPI.
For the latest stable version:
$ pip install treblle
Don’t forget to load the required python modules in your settings.py like so:
INSTALLED_APPS = [
...
'treblle',
]
MIDDLEWARE = [
...
'treblle.middleware.TreblleMiddleware',
]
Create a FREE account on treblle.com, copy your SDK Token and API Key from the Treblle Dashboard to settings.py like so:
TREBLLE = {
'SDK_TOKEN': os.environ.get('TREBLLE_SDK_TOKEN'),
'API_KEY': os.environ.get('TREBLLE_API_KEY'),
'MASKED_FIELDS': ['custom_field', 'internal_id'], # Optional - additonal fields to mask
'DEBUG': True, # Optional - enables debug logging (default: False)
'EXCLUDED_ROUTES': ['/health/', '/ping', '/admin/*'], # Optional - routes to exclude from tracking
}
Visit the Treblle Dashboard and see requests appear in real-time.
Version 2.0 🚀
Treblle Django SDK v2.0 brings significant performance improvements, better security, and enhanced developer experience. This version has been completely rewritten with production-grade optimizations.
🔄 Migrating from v1 to v2
If you're upgrading from v1, you'll need to make these changes:
1. Configuration Format (REQUIRED)
❌ Old v1 Format:
TREBLLE_INFO = {
'api_key': 'your_sdk_token',
'project_id': 'your_api_key',
'hidden_keys': ['password']
}
✅ New v2 Format:
TREBLLE = {
'SDK_TOKEN': 'your_sdk_token',
'API_KEY': 'your_api_key',
'MASKED_FIELDS': ['password'], # Optional
'DEBUG': False, # Optional
'EXCLUDED_ROUTES': ['/health/', '/ping'], # Optional
}
2. Django Settings Update (REQUIRED)
❌ Old v1 Middleware:
MIDDLEWARE_CLASSES = [ # Deprecated Django setting
'treblle.middleware.TreblleMiddleware',
]
✅ New v2 Middleware:
MIDDLEWARE = [ # Modern Django setting
'treblle.middleware.TreblleMiddleware',
]
Debug Mode
Enable debug mode to get detailed logging about the SDK's operation:
- Configuration errors: Missing or invalid SDK_TOKEN/API_KEY
- Middleware loading: Confirmation that Treblle is active
- API responses: HTTP status codes from Treblle endpoints
- Error handling: 4xx/5xx errors with helpful troubleshooting tips
- Data processing: JSON validation and masking information
TREBLLE = {
'SDK_TOKEN': 'your_sdk_token',
'API_KEY': 'your_api_key',
'DEBUG': True # Enable debug mode
}
Route Exclusion
You can exclude specific routes from being tracked by Treblle. This is useful for health checks, monitoring endpoints, or other routes that generate high-frequency, low-value traffic:
TREBLLE = {
'SDK_TOKEN': 'your_token',
'API_KEY': 'your_key',
'EXCLUDED_ROUTES': [
'/health/', # Exact path match
'/api/health', # Exact path match
'/ping', # Exact path match
'/admin/*', # Wildcard: excludes /admin/login, /admin/users, etc.
'*/metrics', # Wildcard: excludes /api/metrics, /internal/metrics, etc.
'/status/*', # Wildcard: excludes anything under /status/
],
}
Pattern matching:
- Exact matches:
/health/only matches exactly/health/ - Wildcards: Use
*for flexible matching (e.g.,/admin/*matches/admin/login,/admin/users/1) - Debug logging: Enable
DEBUG: Trueto see which routes are being excluded
See the docs for this SDK to learn more.
Getting Help
If you continue to experience issues:
- Enable
debug: trueand check console output - Verify your SDK token and API key are correct in Treblle dashboard
- Test with a simple endpoint first
- Check Treblle documentation for the latest updates
- Contact support at https://treblle.com or email support@treblle.com
Support
If you have problems of any kind feel free to reach out via https://treblle.com or email support@treblle.com and we'll do our best to help you out.
License
Copyright 2025, Treblle Inc. Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file treblle-2.0.5.tar.gz.
File metadata
- Download URL: treblle-2.0.5.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9785d03234d1a48c42d1f09220bcc4379cde61715c42ee01a940c5ce6cdc3fbb
|
|
| MD5 |
6e87eafc83ce9569f3f5f038ee5ac310
|
|
| BLAKE2b-256 |
b97876ac5944d7fff46098415c2e110405db6d88825b7c3c96526d1f0ed51afc
|
File details
Details for the file treblle-2.0.5-py3-none-any.whl.
File metadata
- Download URL: treblle-2.0.5-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4526cc1ae60252ed7d1ff6b8ad94e719802a41e4018e5d00833a444467e76ecc
|
|
| MD5 |
33d060b003fd963affb7fbc10450d905
|
|
| BLAKE2b-256 |
2dba418e715a7bc07303e0855493619b5315d00cbe29850dfef3cbbe91865425
|