A modern, modular, and complete Python SDK for the Darktrace API
Project description
🚀 Darktrace Python SDK
A modern, Pythonic SDK for the Darktrace Threat Visualizer API.
🆕 Latest Updates (v0.8.55)
- Feature: Add 13 missing parameters to devicesummary endpoint - Added support for
device_name,ip_address,end_timestamp,start_timestamp,devicesummary_by,devicesummary_by_value,device_type,network_location,network_location_id,peer_id,source, andstatusparameters to align with Darktrace API specification - Documentation: Update devicesummary documentation - Added examples and parameter descriptions for new filtering options
- Note: devicesummary HTTP 500 limitation confirmed - Documentation updated to clarify that all devicesummary parameters return HTTP 500 with API token authentication (Darktrace backend limitation, not SDK bug)
📝 Previous Updates (v0.8.54)
- Fix: Multi-parameter devicesearch query format (fixes #45) - Changed query parameter joining from explicit ' AND ' to space separation per Darktrace API specification
- Fix: ensure host URL includes protocol (default to https if missing)
✨ Features
- Extensive API Coverage: Most endpoints, parameters, and actions from the official Darktrace API Guide are implemented.
- Modular & Maintainable: Each endpoint group is a separate Python module/class.
- Easy Authentication: Secure HMAC-SHA1 signature generation and token management.
- Async-Ready: Designed for easy extension to async workflows.
- Type Hints & Docstrings: Full typing and documentation for all public methods.
- Comprehensive Documentation: Detailed documentation for every module and endpoint.
📦 Installation
pip install darktrace-sdk
After installation, you'll import it in Python as darktrace:
from darktrace import DarktraceClient
Or clone this repository:
git clone https://github.com/yourusername/darktrace.git
cd darktrace
pip install .
🚦 Quick Start
from darktrace import DarktraceClient
# Initialize the client
client = DarktraceClient(
host="https://your-darktrace-instance",
public_token="YOUR_PUBLIC_TOKEN",
private_token="YOUR_PRIVATE_TOKEN"
)
# Access endpoint groups
devices = client.devices
all_devices = devices.get()
antigena = client.antigena
actions = antigena.get_actions()
# Use Advanced Search with POST requests (Darktrace 6.1+)
advanced_search = client.advanced_search
query = {
"search": "@type:\"ssl\" AND @fields.dest_port:\"443\"",
"fields": [],
"offset": 0,
"timeframe": "3600" # 1 hour
}
results = advanced_search.search(query=query, post_request=True)
print(all_devices)
print(actions)
print(results)
📚 Documentation
Comprehensive documentation is available in the docs directory:
- Main Documentation - Overview and getting started
- Authentication - How authentication works
- Antigena - Managing Antigena actions
- Devices - Working with device information
- Model Breaches - Handling model breach alerts
- Status - System status information
And many more modules covering every aspect of the Darktrace API.
See the EXAMPLES.md file for additional usage examples.
🛡️ Endpoint Coverage
This SDK aims to cover all endpoints in the Darktrace API Guide, including:
/advancedsearch(search, analyze, graph)/aianalyst(incidentevents, groups, acknowledge, pin, comments, stats, investigations, incidents)/antigena(actions, manual, summary)/components,/cves,/details,/deviceinfo,/devices,/devicesearch,/devicesummary/endpointdetails,/enums,/filtertypes,/intelfeed,/mbcomments,/metricdata,/metrics,/models,/modelbreaches,/network,/pcaps,/similardevices,/status,/subnets,/summarystatistics,/tags, and all/agemailendpoints
If you find a missing endpoint, open an issue or PR and it will be added!
⚠️ Known Issues
/devicesummary Endpoint Returns HTTP 500
The /devicesummary endpoint returns a 500 Internal Server Error when accessed with API tokens, even though it works in the browser or with session/cookie authentication. This is a known limitation of the Darktrace API backend and not a bug in the SDK or your code.
Status: Confirmed as Darktrace API backend limitation (tested with SDK v0.8.54 on instance v6.3.18). The SDK implementation is correct and uses the same authentication pattern as other endpoints that work with API tokens.
Workaround: There is currently no programmatic workaround. If you require this endpoint, please contact Darktrace support or use browser-based access where possible.
Status: Tracked as issue #37. If you encounter this, please reference the issue for updates.
📝 Contributing
Contributions are welcome! Please:
- Fork the repo and create your branch.
- Write clear, tested code and clean code principles.
- Add/Update docstrings and type hints.
- Submit a pull request with a detailed description.
📄 License
This project is licensed under the MIT License. See LICENSE for details.
🙏 Acknowledgements
- Inspired by the official Darktrace API Guide
- Community contributions welcome!
Made with ❤️ for the Darktrace community.
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 darktrace_sdk-0.8.55.tar.gz.
File metadata
- Download URL: darktrace_sdk-0.8.55.tar.gz
- Upload date:
- Size: 35.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
badc5c38c4d365715000e500d6642db9b13078da5adad48cd26a5bfeaecf516b
|
|
| MD5 |
d3497353fd61a3237796b3a347701f86
|
|
| BLAKE2b-256 |
062ffd482790237f4340d8d6cc72493d24fa0eab22310058f212469fda480cfd
|
Provenance
The following attestation bundles were made for darktrace_sdk-0.8.55.tar.gz:
Publisher:
python-publish.yml on LegendEvent/darktrace-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
darktrace_sdk-0.8.55.tar.gz -
Subject digest:
badc5c38c4d365715000e500d6642db9b13078da5adad48cd26a5bfeaecf516b - Sigstore transparency entry: 843451447
- Sigstore integration time:
-
Permalink:
LegendEvent/darktrace-sdk@aabc5b4e65b889443f53a4ef4b8a51cfc7245e04 -
Branch / Tag:
refs/tags/v0.8.55 - Owner: https://github.com/LegendEvent
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@aabc5b4e65b889443f53a4ef4b8a51cfc7245e04 -
Trigger Event:
release
-
Statement type:
File details
Details for the file darktrace_sdk-0.8.55-py3-none-any.whl.
File metadata
- Download URL: darktrace_sdk-0.8.55-py3-none-any.whl
- Upload date:
- Size: 48.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbe8739fad3696a0d2b4557ecb638984257c4a05cb866ce901c07c17796b286b
|
|
| MD5 |
703d15933d465be4e19e494932a303d1
|
|
| BLAKE2b-256 |
c6da7f13ad87c61acb5b1dd5138a452b8dec2f3279ffeeef7d12febb8b8cfa8f
|
Provenance
The following attestation bundles were made for darktrace_sdk-0.8.55-py3-none-any.whl:
Publisher:
python-publish.yml on LegendEvent/darktrace-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
darktrace_sdk-0.8.55-py3-none-any.whl -
Subject digest:
cbe8739fad3696a0d2b4557ecb638984257c4a05cb866ce901c07c17796b286b - Sigstore transparency entry: 843451462
- Sigstore integration time:
-
Permalink:
LegendEvent/darktrace-sdk@aabc5b4e65b889443f53a4ef4b8a51cfc7245e04 -
Branch / Tag:
refs/tags/v0.8.55 - Owner: https://github.com/LegendEvent
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@aabc5b4e65b889443f53a4ef4b8a51cfc7245e04 -
Trigger Event:
release
-
Statement type: