Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 96 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,111 @@ 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:

```bash
docker run -p 3000:3000 -d --rm --name databunkerpro securitybunker/databunkerpro demo
```

Check that it came up:

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

```python
import base64

from databunkerpro import DatabunkerproAPI

# Initialize the client
api = DatabunkerproAPI(
base_url="https://pro.databunker.org",
x_bunker_token="your-api-token",
x_bunker_tenant="your-tenant-name"
)
api = DatabunkerproAPI("http://localhost:3000", "DEMO")

# Create a new user
user_data = {
"email": "user@example.com",
# 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": "+1234567890"
}
result = api.create_user(user_data)
print(f"Created user with token: {result['token']}")
"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())

# Delete user record.
api.delete_user("email", "john@pythontest.com")
print("User deleted")
```

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

```bash
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](https://docs.databunker.org/pro/installation/docker-compose).

### Connecting to your own instance

```python
from databunkerpro import DatabunkerproAPI

# Get user information
user = api.get_user("email", "user@example.com")
print(f"User profile: {user['profile']}")
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
update_data = {
api.update_user("email", "john@pythontest.com", {
"name": "John Updated",
"phone": "+0987654321"
}
api.update_user("email", "user@example.com", update_data)
"phone": "+0987654321",
})

# Create a token for sensitive data
# 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']}")
Expand Down Expand Up @@ -124,4 +198,4 @@ If you encounter any issues or have questions, please [open an issue](https://gi

## API Documentation

For detailed API documentation, please visit the [DatabunkerPro API Documentation](https://databunker.org/databunker-pro-docs/introduction/).
For detailed API documentation, please visit the [DatabunkerPro API Documentation](https://docs.databunker.org/pro/get-started/overview).
2 changes: 1 addition & 1 deletion databunkerpro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

from .api import DatabunkerproAPI

__version__ = "0.1.5"
__version__ = "0.1.6"
__all__ = ["DatabunkerproAPI"]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="databunkerpro",
version="0.1.5",
version="0.1.6",
author="Databunker team",
author_email="hello@databunker.org",
description="Python client library for DatabunkerPro API",
Expand Down
Loading