Skip to content

Commit 252e420

Browse files
authored
Merge pull request #7 from securitybunker/readme-quickstart
Add demo-mode quickstart to README, bump to 0.1.6
2 parents 14355de + 6d83b38 commit 252e420

3 files changed

Lines changed: 98 additions & 24 deletions

File tree

README.md

Lines changed: 96 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,111 @@ pip install git+https://github.com/securitybunker/databunkerpro-python.git
1818

1919
## Quick Start
2020

21+
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:
22+
23+
```bash
24+
docker run -p 3000:3000 -d --rm --name databunkerpro securitybunker/databunkerpro demo
25+
```
26+
27+
Check that it came up:
28+
29+
```bash
30+
docker logs databunkerpro
31+
```
32+
33+
```
34+
Databunker Pro demo is ready
35+
Web UI: http://localhost:3000/
36+
Root access token: DEMO
37+
Database: in-memory, erased on restart
38+
```
39+
40+
The root access token in demo mode is the fixed string `DEMO`. Save this as `quickstart.py`:
41+
2142
```python
43+
import base64
44+
2245
from databunkerpro import DatabunkerproAPI
2346

24-
# Initialize the client
25-
api = DatabunkerproAPI(
26-
base_url="https://pro.databunker.org",
27-
x_bunker_token="your-api-token",
28-
x_bunker_tenant="your-tenant-name"
29-
)
47+
api = DatabunkerproAPI("http://localhost:3000", "DEMO")
3048

31-
# Create a new user
32-
user_data = {
33-
"email": "user@example.com",
49+
# Create a user record. The vault encrypts the profile and returns a user token.
50+
created = api.create_user({
51+
"email": "john@pythontest.com",
3452
"name": "John Doe",
35-
"phone": "+1234567890"
36-
}
37-
result = api.create_user(user_data)
38-
print(f"Created user with token: {result['token']}")
53+
"phone": "+15551234567",
54+
})
55+
print("User token:", created["token"])
56+
57+
# Read the record back by any indexed field: token, login, email, phone, custom.
58+
user = api.get_user("email", "john@pythontest.com")
59+
print("Profile:", user["profile"])
60+
61+
# Store an encrypted file against that user, tagged by document type.
62+
filedata = base64.b64encode(b"fake passport scan bytes").decode()
63+
file = api.create_file(
64+
"email",
65+
"john@pythontest.com",
66+
"passport.jpg",
67+
filedata,
68+
{"tags": ["passport", "kyc"]},
69+
)
70+
print("File uuid:", file["fileuuid"], "| tags:", file["tags"])
71+
72+
# List the user's files, filtered by tag.
73+
listing = api.list_user_files("email", "john@pythontest.com", "kyc")
74+
print("Files tagged kyc:", [f["filename"] for f in listing["files"]])
75+
76+
# Fetch the file back. Content returns base64-encoded in filedata.
77+
fetched = api.get_file("email", "john@pythontest.com", fileuuid=file["fileuuid"])
78+
print("Decrypted:", base64.b64decode(fetched["filedata"]).decode())
79+
80+
# Delete user record.
81+
api.delete_user("email", "john@pythontest.com")
82+
print("User deleted")
83+
```
84+
85+
```bash
86+
python quickstart.py
87+
```
88+
89+
```
90+
User token: c6688d6a-a87e-d332-2086-31c69fef4564
91+
Profile: {'email': 'john@pythontest.com', 'name': 'John Doe', 'phone': '+15551234567'}
92+
File uuid: c8517c4c-14f9-2e9d-2413-610b982065e8 | tags: ['kyc', 'passport']
93+
Files tagged kyc: ['passport.jpg']
94+
Decrypted: fake passport scan bytes
95+
User deleted
96+
```
97+
98+
Tags are lowercased, de-duplicated and sorted on write, which is why they come back in a different order than they were sent.
99+
100+
When you are done, stop the instance. It was started with `--rm`, so the container and its in-memory database are discarded:
101+
102+
```bash
103+
docker stop databunkerpro
104+
```
105+
106+
> **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).
107+
108+
### Connecting to your own instance
109+
110+
```python
111+
from databunkerpro import DatabunkerproAPI
39112

40-
# Get user information
41-
user = api.get_user("email", "user@example.com")
42-
print(f"User profile: {user['profile']}")
113+
api = DatabunkerproAPI(
114+
base_url="https://your-databunker-instance.com",
115+
x_bunker_token="your-api-token",
116+
x_bunker_tenant="your-tenant-name", # multi-tenant deployments only
117+
)
43118

44119
# Update user information
45-
update_data = {
120+
api.update_user("email", "john@pythontest.com", {
46121
"name": "John Updated",
47-
"phone": "+0987654321"
48-
}
49-
api.update_user("email", "user@example.com", update_data)
122+
"phone": "+0987654321",
123+
})
50124

51-
# Create a token for sensitive data
125+
# Tokenize sensitive data
52126
token_result = api.create_token("creditcard", "4111111111111111")
53127
print(f"Created token in base format (credit card): {token_result['tokenbase']}")
54128
print(f"Created token in uuid format: {token_result['tokenuuid']}")
@@ -124,4 +198,4 @@ If you encounter any issues or have questions, please [open an issue](https://gi
124198

125199
## API Documentation
126200

127-
For detailed API documentation, please visit the [DatabunkerPro API Documentation](https://databunker.org/databunker-pro-docs/introduction/).
201+
For detailed API documentation, please visit the [DatabunkerPro API Documentation](https://docs.databunker.org/pro/get-started/overview).

databunkerpro/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
from .api import DatabunkerproAPI
77

8-
__version__ = "0.1.5"
8+
__version__ = "0.1.6"
99
__all__ = ["DatabunkerproAPI"]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="databunkerpro",
8-
version="0.1.5",
8+
version="0.1.6",
99
author="Databunker team",
1010
author_email="hello@databunker.org",
1111
description="Python client library for DatabunkerPro API",

0 commit comments

Comments
 (0)