Databunker Pro Python Client
A Python client library for interacting with the DatabunkerPro API. This library provides a simple and intuitive interface for managing user data, tokens, and other DatabunkerPro features.
Installation
You can install the package using pip:
pip install databunkerpro
Or install directly from GitHub:
pip install git+https://github.com/securitybunker/databunkerpro-python.git
Quick Start
You need a Databunker Pro instance to talk to. Demo mode gives you one in a single command — no database, no configuration, everything held in memory:
docker run -p 3000:3000 -d --rm --name databunkerpro securitybunker/databunkerpro demo
Check that it came up:
docker logs databunkerpro
Databunker Pro demo is ready
Web UI: http://localhost:3000/
Root access token: DEMO
Database: in-memory, erased on restart
The root access token in demo mode is the fixed string DEMO. Save this as quickstart.py:
import base64
from databunkerpro import DatabunkerproAPI
api = DatabunkerproAPI("http://localhost:3000", "DEMO")
# Create a user record. The vault encrypts the profile and returns a user token.
created = api.create_user({
"email": "john@pythontest.com",
"name": "John Doe",
"phone": "+15551234567",
})
print("User token:", created["token"])
# Read the record back by any indexed field: token, login, email, phone, custom.
user = api.get_user("email", "john@pythontest.com")
print("Profile:", user["profile"])
# Store an encrypted file against that user, tagged by document type.
filedata = base64.b64encode(b"fake passport scan bytes").decode()
file = api.create_file(
"email",
"john@pythontest.com",
"passport.jpg",
filedata,
{"tags": ["passport", "kyc"]},
)
print("File uuid:", file["fileuuid"], "| tags:", file["tags"])
# List the user's files, filtered by tag.
listing = api.list_user_files("email", "john@pythontest.com", "kyc")
print("Files tagged kyc:", [f["filename"] for f in listing["files"]])
# Fetch the file back. Content returns base64-encoded in filedata.
fetched = api.get_file("email", "john@pythontest.com", fileuuid=file["fileuuid"])
print("Decrypted:", base64.b64decode(fetched["filedata"]).decode())
# Or download the decrypted bytes directly.
content = api.download_file("email", "john@pythontest.com", file["fileuuid"])
# Delete user record.
api.delete_user("email", "john@pythontest.com")
print("User deleted")
python quickstart.py
User token: c6688d6a-a87e-d332-2086-31c69fef4564
Profile: {'email': 'john@pythontest.com', 'name': 'John Doe', 'phone': '+15551234567'}
File uuid: c8517c4c-14f9-2e9d-2413-610b982065e8 | tags: ['kyc', 'passport']
Files tagged kyc: ['passport.jpg']
Decrypted: fake passport scan bytes
User deleted
Tags are lowercased, de-duplicated and sorted on write, which is why they come back in a different order than they were sent.
When you are done, stop the instance. It was started with --rm, so the container and its in-memory database are discarded:
docker stop databunkerpro
Demo mode is for evaluation only. The database is in memory, the wrapping key is a fixed public value, and the root token is the well-known string
DEMO. Never point it at real personal data. For a real deployment see the installation guide.
Connecting to your own instance
from databunkerpro import DatabunkerproAPI
api = DatabunkerproAPI(
base_url="https://your-databunker-instance.com",
x_bunker_token="your-api-token",
x_bunker_tenant="your-tenant-name", # multi-tenant deployments only
)
# Update user information
api.update_user("email", "john@pythontest.com", {
"name": "John Updated",
"phone": "+0987654321",
})
# Tokenize sensitive data
token_result = api.create_token("creditcard", "4111111111111111")
print(f"Created token in base format (credit card): {token_result['tokenbase']}")
print(f"Created token in uuid format: {token_result['tokenuuid']}")
File storage
Files are attached to a user and can carry tags for later lookup:
# Change some of a file's tags
api.rename_file_tag("email", "john@pythontest.com", file["fileuuid"], "pending-review", "archived")
api.delete_file("email", "john@pythontest.com", file["fileuuid"])
Files can also be listed by tag across every user in the tenant, which needs a bulk-unlock uuid first:
unlock = api.bulk_list_unlock()
tagged = api.bulk_list_files_by_tag(unlock["unlockuuid"], "archived", 0, 100)
Errors and timeouts
Calls do not raise on API errors. They return {"status": "error", "message": ...}, and when the server
answered, httpcode holds its HTTP status, so you can tell cases apart without matching message text. The
error reference lists the status codes and common messages.
result = api.get_user("email", "nobody@example.com")
if result["status"] == "error":
if result.get("httpcode") == 404:
... # no such user
else:
raise RuntimeError(result["message"]) # 403 bad token, 5xx, or no httpcode: no response at all
Every request has a timeout: 10 seconds to connect and 300 seconds to read by default. A call that times out
returns an error without httpcode. Pass timeout to change it, as seconds or a (connect, read) pair;
None waits forever:
api = DatabunkerproAPI(base_url, x_bunker_token=token, timeout=(5, 60))
Features
- User Management
- App Data Management
- File Storage
- Tokenization
- Legal Basis & Agreement Management
- Processing Activity Management
- Group Management
- Role & Policy Management
- Session Management
- Shared Records
- Bulk Operations
- Audit Management
- Tenant Management
- Authentication & Access Tokens
- System Operations
Python-specific:
- Type hints and comprehensive documentation
- Error handling and validation
- Continuous security scanning (Semgrep SAST, pinned CI actions)
Development
To set up the development environment:
- Clone the repository:
git clone https://github.com/securitybunker/databunkerpro-python.git
cd databunkerpro-python
- Install development dependencies:
pip install -e ".[dev]"
- Run tests:
pytest
Local stress testing
The stress-test scripts live in stress-test/. Run them from that directory, and only against a local instance:
bulk_user_creator.pycreates 1,000,000 users (250 batches of 4,000, each with 119 profile fields) and appends 10 sample tokens per batch touser_tokens.txt.bulk_user_fetcher.pyfetches every token inuser_tokens.txtconcurrently, in batches of 100.random_user_fetcher.pyrepeatedly fetches random users fromuser_tokens.txt.
They read DATABUNKER_API_URL (default http://localhost), DATABUNKER_API_TOKEN and DATABUNKER_TENANT_NAME. Never point them at a shared or production server.
Security
This library is scanned on every push and pull request, with a weekly scheduled sweep to catch drift:
- SAST (Semgrep): static analysis using the
p/python,p/secrets,p/security-audit, andp/owasp-top-tenrulesets. A finding fails the check, and results are published to the repository's Code Scanning tab. See.github/workflows/semgrep.yml. - Supply-chain hardening: every GitHub Action is pinned to a full commit SHA, so a mutable tag (
@v4) cannot be silently repointed to malicious code.
Reproduce the SAST scan locally:
pip install semgrep
semgrep scan \
--config p/python \
--config p/secrets \
--config p/security-audit \
--config p/owasp-top-ten
To report a security vulnerability, please email hello@databunker.org rather than opening a public issue.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- 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
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions, please open an issue on GitHub.
API Documentation
For detailed API documentation, please visit the DatabunkerPro API Documentation.
Metadata
Release files for databunkerpro 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| databunkerpro-0.2.0.tar.gz | 28.7 kB | Without provenance | Details for databunkerpro-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| databunkerpro-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for databunkerpro-0.2.0-py3-none-any.whl |
Total release size: 43.6 kB
Release files / databunkerpro-0.2.0.tar.gz
| Download URL | databunkerpro-0.2.0.tar.gz |
|---|---|
| Size | 28.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfef6f1186d0eaa918e2d911c9eb680ce5678030f167a94979625051293b79c5
|
|
BLAKE2b-256 checksum How to use checksums |
cc2159b07d3cba4629b1e9c35ae45de5a33bd65b156b13428001c5a40477d94f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Release files / databunkerpro-0.2.0-py3-none-any.whl
| Download URL | databunkerpro-0.2.0-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
331ef50f816d5d4d28e2404a072e910429e36d52824e7c21e2fb8441a4dae329
|
|
BLAKE2b-256 checksum How to use checksums |
89bfe71725a4ec3353332f759648f5311e90eae2298c65cb5ed82b1a62656a35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Security for databunkerpro 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.