treblle


Nametreblle JSON
Version 2.0.3 PyPI version JSON
download
home_pagehttps://github.com/Treblle/treblle-python
SummaryTreblle SDK for Django - Production-ready API monitoring and intelligence platform
upload_time2025-08-10 13:21:30
maintainerNone
docs_urlNone
authorTreblle
requires_python>=3.7
licenseNone
keywords treblle api monitoring django middleware observability analytics intelligence devops production thread-safe
VCS
bugtrack_url
requirements requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Treblle - API Intelligence Platform

[![Treblle API Intelligence](https://github.com/user-attachments/assets/b268ae9e-7c8a-4ade-95da-b4ac6fce6eea)](https://treblle.com)

[Website](http://treblle.com/) β€’ [Documentation](https://docs.treblle.com/) β€’ [Pricing](https://treblle.com/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:**
```sh
$ pip install treblle
```

Don’t forget to load the required python modules in your `settings.py` like so:

```python
INSTALLED_APPS = [
...
'treblle',
]
```

```python
MIDDLEWARE = [
    ...
    'treblle.middleware.TreblleMiddleware',
]
```

Create a FREE account on [treblle.com](https://treblle.com/), copy your SDK Token and API Key from the Treblle Dashboard to `settings.py` like so:

```python
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](https://platform.treblle.com/) 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:**
```python
TREBLLE_INFO = {
    'api_key': 'your_sdk_token',
    'project_id': 'your_api_key',
    'hidden_keys': ['password']
}
```

**βœ… New v2 Format:**
```python
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:**
```python
MIDDLEWARE_CLASSES = [  # Deprecated Django setting
    'treblle.middleware.TreblleMiddleware',
]
```

**βœ… New v2 Middleware:**
```python
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

```python
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:

```python
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: True` to see which routes are being excluded

> See the [docs](https://docs.treblle.com/en/integrations/django) for this SDK to learn more.

### Getting Help

If you continue to experience issues:

1. Enable `debug: true` and check console output
2. Verify your SDK token and API key are correct in Treblle dashboard
3. Test with a simple endpoint first
4. Check [Treblle documentation](https://docs.treblle.com) for the latest updates
5. 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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Treblle/treblle-python",
    "name": "treblle",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Treblle <support@treblle.com>",
    "keywords": "treblle, api, monitoring, django, middleware, observability, analytics, intelligence, devops, production, thread-safe",
    "author": "Treblle",
    "author_email": "Treblle <support@treblle.com>",
    "download_url": "https://files.pythonhosted.org/packages/3b/18/28b25cf44e6181d704b909262dd501353f2894f45b1e76bc9c0709b2c550/treblle-2.0.3.tar.gz",
    "platform": null,
    "description": "# Treblle - API Intelligence Platform\n\n[![Treblle API Intelligence](https://github.com/user-attachments/assets/b268ae9e-7c8a-4ade-95da-b4ac6fce6eea)](https://treblle.com)\n\n[Website](http://treblle.com/) \u2022 [Documentation](https://docs.treblle.com/) \u2022 [Pricing](https://treblle.com/pricing)\n\n\nTreblle is an API intelligence platfom that helps developers, teams and organizations understand their APIs from a single integration point.\n\n***\n\n## Treblle Django SDK\n\n### Requirements\n\n- **Python**: 3.7 or higher\n- **Django**: 2.2 or higher  \n- **requests**: 2.25.0 or higher\n\n> **Note**: Django 5.0+ requires Python 3.10 or higher. If you're using Django 5.x, ensure you have Python 3.10+.\n\n### Getting Started\n\nYou can install Treblle for django via PyPI. \n\n**For the latest stable version:**\n```sh\n$ pip install treblle\n```\n\nDon\u2019t forget to load the required python modules in your `settings.py` like so:\n\n```python\nINSTALLED_APPS = [\n...\n'treblle',\n]\n```\n\n```python\nMIDDLEWARE = [\n    ...\n    'treblle.middleware.TreblleMiddleware',\n]\n```\n\nCreate a FREE account on [treblle.com](https://treblle.com/), copy your SDK Token and API Key from the Treblle Dashboard to `settings.py` like so:\n\n```python\nTREBLLE = {\n    'SDK_TOKEN': os.environ.get('TREBLLE_SDK_TOKEN'),\n    'API_KEY': os.environ.get('TREBLLE_API_KEY'),\n    'MASKED_FIELDS': ['custom_field', 'internal_id'],  # Optional - additonal fields to mask\n    'DEBUG': True,  # Optional - enables debug logging (default: False)\n    'EXCLUDED_ROUTES': ['/health/', '/ping', '/admin/*'],  # Optional - routes to exclude from tracking\n}\n```\n\nVisit the [Treblle Dashboard](https://platform.treblle.com/) and see requests appear in real-time.\n\n## Version 2.0 \ud83d\ude80\n\n**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.\n\n### \ud83d\udd04 Migrating from v1 to v2\n\nIf you're upgrading from v1, you'll need to make these changes:\n\n#### 1. **Configuration Format (REQUIRED)**\n\n**\u274c Old v1 Format:**\n```python\nTREBLLE_INFO = {\n    'api_key': 'your_sdk_token',\n    'project_id': 'your_api_key',\n    'hidden_keys': ['password']\n}\n```\n\n**\u2705 New v2 Format:**\n```python\nTREBLLE = {\n    'SDK_TOKEN': 'your_sdk_token',\n    'API_KEY': 'your_api_key',\n    'MASKED_FIELDS': ['password'], # Optional\n    'DEBUG': False, # Optional\n    'EXCLUDED_ROUTES': ['/health/', '/ping'], # Optional\n}\n```\n\n#### 2. **Django Settings Update (REQUIRED)**\n\n**\u274c Old v1 Middleware:**\n```python\nMIDDLEWARE_CLASSES = [  # Deprecated Django setting\n    'treblle.middleware.TreblleMiddleware',\n]\n```\n\n**\u2705 New v2 Middleware:**\n```python\nMIDDLEWARE = [  # Modern Django setting\n    'treblle.middleware.TreblleMiddleware',\n]\n```\n\n---\n\n### Debug Mode\n\nEnable debug mode to get detailed logging about the SDK's operation:\n\n- **Configuration errors**: Missing or invalid SDK_TOKEN/API_KEY\n- **Middleware loading**: Confirmation that Treblle is active\n- **API responses**: HTTP status codes from Treblle endpoints\n- **Error handling**: 4xx/5xx errors with helpful troubleshooting tips\n- **Data processing**: JSON validation and masking information\n\n```python\nTREBLLE = {\n    'SDK_TOKEN': 'your_sdk_token',\n    'API_KEY': 'your_api_key', \n    'DEBUG': True  # Enable debug mode\n}\n```\n\n### Route Exclusion\n\nYou 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:\n\n```python\nTREBLLE = {\n    'SDK_TOKEN': 'your_token',\n    'API_KEY': 'your_key',\n    'EXCLUDED_ROUTES': [\n        '/health/',           # Exact path match\n        '/api/health',        # Exact path match  \n        '/ping',              # Exact path match\n        '/admin/*',           # Wildcard: excludes /admin/login, /admin/users, etc.\n        '*/metrics',          # Wildcard: excludes /api/metrics, /internal/metrics, etc.\n        '/status/*',          # Wildcard: excludes anything under /status/\n    ],\n}\n```\n\n**Pattern matching:**\n- **Exact matches**: `/health/` only matches exactly `/health/`\n- **Wildcards**: Use `*` for flexible matching (e.g., `/admin/*` matches `/admin/login`, `/admin/users/1`)\n- **Debug logging**: Enable `DEBUG: True` to see which routes are being excluded\n\n> See the [docs](https://docs.treblle.com/en/integrations/django) for this SDK to learn more.\n\n### Getting Help\n\nIf you continue to experience issues:\n\n1. Enable `debug: true` and check console output\n2. Verify your SDK token and API key are correct in Treblle dashboard\n3. Test with a simple endpoint first\n4. Check [Treblle documentation](https://docs.treblle.com) for the latest updates\n5. Contact support at <https://treblle.com> or email support@treblle.com\n\n## Support\n\nIf 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.\n\n## License\n\nCopyright 2025, Treblle Inc. Licensed under the MIT license:\nhttp://www.opensource.org/licenses/mit-license.php\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Treblle SDK for Django - Production-ready API monitoring and intelligence platform",
    "version": "2.0.3",
    "project_urls": {
        "Bug Reports": "https://github.com/Treblle/treblle-python/issues",
        "Changelog": "https://github.com/Treblle/treblle-python/releases",
        "Documentation": "https://docs.treblle.com/en/integrations/django",
        "Homepage": "https://treblle.com",
        "Repository": "https://github.com/Treblle/treblle-python"
    },
    "split_keywords": [
        "treblle",
        " api",
        " monitoring",
        " django",
        " middleware",
        " observability",
        " analytics",
        " intelligence",
        " devops",
        " production",
        " thread-safe"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f6d59fc1e42d300c8e0ccb5fabd54e2bc7df3c4636582d409ffad00ac91c086a",
                "md5": "ef09f2f81b494b18ce864aa93985f0d5",
                "sha256": "bb9e39b720b30d5aaccd9979347fa5c4fc9ec3abae6a98c5cd6db0609e5a51c8"
            },
            "downloads": -1,
            "filename": "treblle-2.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ef09f2f81b494b18ce864aa93985f0d5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 12620,
            "upload_time": "2025-08-10T13:21:29",
            "upload_time_iso_8601": "2025-08-10T13:21:29.390308Z",
            "url": "https://files.pythonhosted.org/packages/f6/d5/9fc1e42d300c8e0ccb5fabd54e2bc7df3c4636582d409ffad00ac91c086a/treblle-2.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3b1828b25cf44e6181d704b909262dd501353f2894f45b1e76bc9c0709b2c550",
                "md5": "535097d6e02d7ac0e51dec8451e28e11",
                "sha256": "67cc4f33c4b39402d8635a4b74a3e2569ae6fb6f15cd12567a43fd10dd6b84eb"
            },
            "downloads": -1,
            "filename": "treblle-2.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "535097d6e02d7ac0e51dec8451e28e11",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 14876,
            "upload_time": "2025-08-10T13:21:30",
            "upload_time_iso_8601": "2025-08-10T13:21:30.705726Z",
            "url": "https://files.pythonhosted.org/packages/3b/18/28b25cf44e6181d704b909262dd501353f2894f45b1e76bc9c0709b2c550/treblle-2.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-10 13:21:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Treblle",
    "github_project": "treblle-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.27.1"
                ]
            ]
        }
    ],
    "lcname": "treblle"
}
        
Elapsed time: 1.08479s