databar 0.7.0__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {databar-0.7.0 → databar-2.0.0}/LICENSE +1 -1
- databar-2.0.0/PKG-INFO +393 -0
- databar-2.0.0/README.md +338 -0
- databar-2.0.0/pyproject.toml +58 -0
- databar-2.0.0/setup.cfg +4 -0
- databar-2.0.0/src/databar/__init__.py +96 -0
- databar-2.0.0/src/databar/cli/_auth.py +110 -0
- databar-2.0.0/src/databar/cli/_output.py +147 -0
- databar-2.0.0/src/databar/cli/app.py +50 -0
- databar-2.0.0/src/databar/cli/enrichments.py +187 -0
- databar-2.0.0/src/databar/cli/tables.py +343 -0
- databar-2.0.0/src/databar/cli/tasks.py +60 -0
- databar-2.0.0/src/databar/cli/waterfalls.py +192 -0
- databar-2.0.0/src/databar/client.py +552 -0
- databar-2.0.0/src/databar/exceptions.py +95 -0
- databar-2.0.0/src/databar/models.py +250 -0
- databar-2.0.0/src/databar.egg-info/PKG-INFO +393 -0
- databar-2.0.0/src/databar.egg-info/SOURCES.txt +23 -0
- databar-2.0.0/src/databar.egg-info/entry_points.txt +2 -0
- databar-2.0.0/src/databar.egg-info/requires.txt +10 -0
- databar-2.0.0/tests/test_cli.py +332 -0
- databar-2.0.0/tests/test_client.py +282 -0
- databar-0.7.0/MANIFEST.in +0 -4
- databar-0.7.0/PKG-INFO +0 -38
- databar-0.7.0/README.md +0 -25
- databar-0.7.0/setup.cfg +0 -102
- databar-0.7.0/setup.py +0 -7
- databar-0.7.0/src/databar/__init__.py +0 -5
- databar-0.7.0/src/databar/connection.py +0 -405
- databar-0.7.0/src/databar/helpers.py +0 -87
- databar-0.7.0/src/databar/table.py +0 -266
- databar-0.7.0/src/databar.egg-info/PKG-INFO +0 -38
- databar-0.7.0/src/databar.egg-info/SOURCES.txt +0 -17
- databar-0.7.0/src/databar.egg-info/requires.txt +0 -15
- databar-0.7.0/tests/test_metadata.py +0 -14
- databar-0.7.0/tests/test_table.py +0 -120
- {databar-0.7.0/tests → databar-2.0.0/src/databar/cli}/__init__.py +0 -0
- {databar-0.7.0 → databar-2.0.0}/src/databar.egg-info/dependency_links.txt +0 -0
- {databar-0.7.0 → databar-2.0.0}/src/databar.egg-info/top_level.txt +0 -0
databar-2.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: databar
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Official Databar.ai Python SDK and CLI — connect to enrichments, waterfalls, and tables via api.databar.ai
|
|
5
|
+
Author-email: "Databar.ai Team" <info@databar.ai>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2022-2026 Databar Inc.
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://databar.ai
|
|
29
|
+
Project-URL: Documentation, https://docs.databar.ai
|
|
30
|
+
Project-URL: Repository, https://github.com/databar-ai/databar-python
|
|
31
|
+
Project-URL: Bug Tracker, https://github.com/databar-ai/databar-python/issues
|
|
32
|
+
Keywords: databar,enrichment,data,api,cli,sdk
|
|
33
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
42
|
+
Requires-Python: >=3.9
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
License-File: LICENSE
|
|
45
|
+
Requires-Dist: httpx>=0.27
|
|
46
|
+
Requires-Dist: pydantic>=2.0
|
|
47
|
+
Requires-Dist: typer>=0.12
|
|
48
|
+
Requires-Dist: rich>=13
|
|
49
|
+
Provides-Extra: dev
|
|
50
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
51
|
+
Requires-Dist: pytest-httpx>=0.30; extra == "dev"
|
|
52
|
+
Requires-Dist: pytest-cov>=5; extra == "dev"
|
|
53
|
+
Requires-Dist: respx>=0.21; extra == "dev"
|
|
54
|
+
Dynamic: license-file
|
|
55
|
+
|
|
56
|
+
# Databar Python SDK
|
|
57
|
+
|
|
58
|
+
Official Python SDK and CLI for [Databar.ai](https://databar.ai) — run data enrichments, waterfall lookups, and manage tables via `api.databar.ai/v1`.
|
|
59
|
+
|
|
60
|
+
[](https://pypi.org/project/databar-ai/)
|
|
61
|
+
[](https://pypi.org/project/databar-ai/)
|
|
62
|
+
[](LICENSE)
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install databar
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Requires Python 3.9+.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Authentication
|
|
77
|
+
|
|
78
|
+
Get your API key from [databar.ai](https://databar.ai) → **Integrations**.
|
|
79
|
+
|
|
80
|
+
**Option 1 — CLI (recommended):**
|
|
81
|
+
```bash
|
|
82
|
+
databar login
|
|
83
|
+
```
|
|
84
|
+
Saves your key to `~/.databar/config`.
|
|
85
|
+
|
|
86
|
+
**Option 2 — Environment variable:**
|
|
87
|
+
```bash
|
|
88
|
+
export DATABAR_API_KEY=your-key-here
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Option 3 — In code:**
|
|
92
|
+
```python
|
|
93
|
+
from databar import DatabarClient
|
|
94
|
+
client = DatabarClient(api_key="your-key-here")
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Python SDK
|
|
100
|
+
|
|
101
|
+
### Quick start
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from databar import DatabarClient
|
|
105
|
+
|
|
106
|
+
client = DatabarClient() # reads DATABAR_API_KEY from env
|
|
107
|
+
|
|
108
|
+
# Check your balance
|
|
109
|
+
user = client.get_user()
|
|
110
|
+
print(f"Balance: {user.balance} credits")
|
|
111
|
+
|
|
112
|
+
# Find enrichments
|
|
113
|
+
enrichments = client.list_enrichments(q="linkedin")
|
|
114
|
+
for e in enrichments:
|
|
115
|
+
print(f" [{e.id}] {e.name} — {e.price} credits")
|
|
116
|
+
|
|
117
|
+
# Run a single enrichment (submit + poll in one call)
|
|
118
|
+
result = client.run_enrichment_sync(123, {"email": "alice@example.com"})
|
|
119
|
+
print(result)
|
|
120
|
+
|
|
121
|
+
# Run a waterfall
|
|
122
|
+
result = client.run_waterfall_sync("email_getter", {"linkedin_url": "https://linkedin.com/in/alice"})
|
|
123
|
+
print(result)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Enrichments
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
# List all enrichments
|
|
130
|
+
enrichments = client.list_enrichments()
|
|
131
|
+
|
|
132
|
+
# Search enrichments
|
|
133
|
+
enrichments = client.list_enrichments(q="phone")
|
|
134
|
+
|
|
135
|
+
# Get full details (params, response fields)
|
|
136
|
+
enrichment = client.get_enrichment(123)
|
|
137
|
+
for param in enrichment.params:
|
|
138
|
+
print(f" {param.name} (required={param.is_required}): {param.description}")
|
|
139
|
+
|
|
140
|
+
# Run single enrichment (async — returns task)
|
|
141
|
+
task = client.run_enrichment(123, {"email": "alice@example.com"})
|
|
142
|
+
data = client.poll_task(task.request_id)
|
|
143
|
+
|
|
144
|
+
# Run single enrichment (sync convenience wrapper)
|
|
145
|
+
data = client.run_enrichment_sync(123, {"email": "alice@example.com"})
|
|
146
|
+
|
|
147
|
+
# Bulk run
|
|
148
|
+
data = client.run_enrichment_bulk_sync(123, [
|
|
149
|
+
{"email": "alice@example.com"},
|
|
150
|
+
{"email": "bob@example.com"},
|
|
151
|
+
])
|
|
152
|
+
|
|
153
|
+
# Get choices for a select parameter
|
|
154
|
+
choices = client.get_param_choices(123, "country", q="united")
|
|
155
|
+
for choice in choices.items:
|
|
156
|
+
print(f" {choice.id}: {choice.name}")
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Waterfalls
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
# List waterfalls
|
|
163
|
+
waterfalls = client.list_waterfalls()
|
|
164
|
+
|
|
165
|
+
# Run a waterfall (tries all providers in sequence)
|
|
166
|
+
result = client.run_waterfall_sync(
|
|
167
|
+
"email_getter",
|
|
168
|
+
{"linkedin_url": "https://linkedin.com/in/alice"},
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
# Run with specific providers only
|
|
172
|
+
result = client.run_waterfall_sync(
|
|
173
|
+
"email_getter",
|
|
174
|
+
{"linkedin_url": "https://linkedin.com/in/alice"},
|
|
175
|
+
enrichments=[10, 11], # provider IDs
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
# Bulk waterfall
|
|
179
|
+
results = client.run_waterfall_bulk_sync(
|
|
180
|
+
"email_getter",
|
|
181
|
+
[{"linkedin_url": url} for url in urls],
|
|
182
|
+
)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Tables
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
# List tables
|
|
189
|
+
tables = client.list_tables()
|
|
190
|
+
|
|
191
|
+
# Create a table
|
|
192
|
+
table = client.create_table(name="My Leads", columns=["email", "name", "company"])
|
|
193
|
+
|
|
194
|
+
# Get columns
|
|
195
|
+
columns = client.get_columns(table.identifier)
|
|
196
|
+
|
|
197
|
+
# Get rows (paginated)
|
|
198
|
+
data = client.get_rows(table.identifier, page=1, per_page=500)
|
|
199
|
+
|
|
200
|
+
# Insert rows (auto-batched at 50)
|
|
201
|
+
from databar import InsertRow, InsertOptions, DedupeOptions
|
|
202
|
+
|
|
203
|
+
rows = [InsertRow(fields={"email": e, "name": n}) for e, n in leads]
|
|
204
|
+
response = client.create_rows(
|
|
205
|
+
table.identifier,
|
|
206
|
+
rows,
|
|
207
|
+
options=InsertOptions(
|
|
208
|
+
allow_new_columns=True,
|
|
209
|
+
dedupe=DedupeOptions(enabled=True, keys=["email"]),
|
|
210
|
+
),
|
|
211
|
+
)
|
|
212
|
+
print(f"Created: {len([r for r in response.results if r.action == 'created'])}")
|
|
213
|
+
|
|
214
|
+
# Update rows by UUID
|
|
215
|
+
from databar import BatchUpdateRow
|
|
216
|
+
|
|
217
|
+
rows = [BatchUpdateRow(id=row_id, fields={"name": "Updated Name"})]
|
|
218
|
+
response = client.patch_rows(table.identifier, rows)
|
|
219
|
+
|
|
220
|
+
# Upsert rows by key column
|
|
221
|
+
from databar import UpsertRow
|
|
222
|
+
|
|
223
|
+
rows = [UpsertRow(key={"email": "alice@example.com"}, fields={"name": "Alice"})]
|
|
224
|
+
response = client.upsert_rows(table.identifier, rows)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Error handling
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
from databar import (
|
|
231
|
+
DatabarClient,
|
|
232
|
+
DatabarAuthError,
|
|
233
|
+
DatabarInsufficientCreditsError,
|
|
234
|
+
DatabarNotFoundError,
|
|
235
|
+
DatabarTaskFailedError,
|
|
236
|
+
DatabarTimeoutError,
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
try:
|
|
240
|
+
result = client.run_enrichment_sync(123, {"email": "alice@example.com"})
|
|
241
|
+
except DatabarAuthError:
|
|
242
|
+
print("Invalid API key")
|
|
243
|
+
except DatabarInsufficientCreditsError:
|
|
244
|
+
print("Not enough credits")
|
|
245
|
+
except DatabarNotFoundError:
|
|
246
|
+
print("Enrichment not found")
|
|
247
|
+
except DatabarTaskFailedError as e:
|
|
248
|
+
print(f"Task failed: {e.message}")
|
|
249
|
+
except DatabarTimeoutError as e:
|
|
250
|
+
print(f"Timed out after polling {e.max_attempts} times")
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Context manager
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
with DatabarClient() as client:
|
|
257
|
+
result = client.run_enrichment_sync(123, {"email": "alice@example.com"})
|
|
258
|
+
# connection pool closed automatically
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## CLI
|
|
264
|
+
|
|
265
|
+
After installing, the `databar` command is available in your terminal.
|
|
266
|
+
|
|
267
|
+
### Authentication
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
databar login # save API key interactively
|
|
271
|
+
databar whoami # show name, email, balance, plan
|
|
272
|
+
databar whoami --format json
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Enrichments
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
# List enrichments
|
|
279
|
+
databar enrich list
|
|
280
|
+
databar enrich list --query "linkedin"
|
|
281
|
+
databar enrich list --format json
|
|
282
|
+
|
|
283
|
+
# Get enrichment details
|
|
284
|
+
databar enrich get 123
|
|
285
|
+
|
|
286
|
+
# Run a single enrichment
|
|
287
|
+
databar enrich run 123 --params '{"email": "alice@example.com"}'
|
|
288
|
+
databar enrich run 123 --params '{"email": "alice@example.com"}' --format json
|
|
289
|
+
|
|
290
|
+
# Bulk run from CSV
|
|
291
|
+
databar enrich bulk 123 --input emails.csv --format csv --out results.csv
|
|
292
|
+
|
|
293
|
+
# Get choices for a select parameter
|
|
294
|
+
databar enrich choices 123 country
|
|
295
|
+
databar enrich choices 123 country --query "united"
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Waterfalls
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# List waterfalls
|
|
302
|
+
databar waterfall list
|
|
303
|
+
databar waterfall list --query "email"
|
|
304
|
+
|
|
305
|
+
# Get waterfall details
|
|
306
|
+
databar waterfall get email_getter
|
|
307
|
+
|
|
308
|
+
# Run a waterfall
|
|
309
|
+
databar waterfall run email_getter --params '{"linkedin_url": "https://linkedin.com/in/alice"}'
|
|
310
|
+
|
|
311
|
+
# Bulk run from CSV
|
|
312
|
+
databar waterfall bulk email_getter --input leads.csv --out results.csv
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Tables
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
# List tables
|
|
319
|
+
databar table list
|
|
320
|
+
|
|
321
|
+
# Create a table
|
|
322
|
+
databar table create --name "My Leads"
|
|
323
|
+
databar table create --name "My Leads" --columns "email,name,company"
|
|
324
|
+
|
|
325
|
+
# Inspect a table
|
|
326
|
+
databar table columns <uuid>
|
|
327
|
+
databar table rows <uuid>
|
|
328
|
+
databar table rows <uuid> --page 2 --per-page 500
|
|
329
|
+
databar table rows <uuid> --format csv --out rows.csv
|
|
330
|
+
|
|
331
|
+
# Insert rows
|
|
332
|
+
databar table insert <uuid> --data '[{"email":"alice@example.com","name":"Alice"}]'
|
|
333
|
+
databar table insert <uuid> --input data.csv --allow-new-columns
|
|
334
|
+
databar table insert <uuid> --input data.csv --dedupe-keys email
|
|
335
|
+
|
|
336
|
+
# Update rows by UUID
|
|
337
|
+
databar table patch <uuid> --data '[{"id":"<row-uuid>","email":"new@example.com"}]'
|
|
338
|
+
|
|
339
|
+
# Upsert rows by key column
|
|
340
|
+
databar table upsert <uuid> --key-col email --input data.csv
|
|
341
|
+
|
|
342
|
+
# Enrichments on a table
|
|
343
|
+
databar table enrichments <uuid>
|
|
344
|
+
databar table add-enrichment <uuid> --enrichment-id 123 --mapping '{"email": "email_col"}'
|
|
345
|
+
databar table run-enrichment <uuid> --enrichment-id <table-enrichment-id>
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Tasks
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
# Check a task status
|
|
352
|
+
databar task get <task-id>
|
|
353
|
+
|
|
354
|
+
# Poll until complete
|
|
355
|
+
databar task get <task-id> --poll
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Output formats
|
|
359
|
+
|
|
360
|
+
All commands support `--format table|json|csv` (default: `table`):
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
# Pipe JSON output
|
|
364
|
+
databar table rows <uuid> --format json | jq '.[].email'
|
|
365
|
+
|
|
366
|
+
# Save to CSV
|
|
367
|
+
databar enrich bulk 123 --input input.csv --format csv --out output.csv
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Configuration
|
|
373
|
+
|
|
374
|
+
| Variable | Description |
|
|
375
|
+
|---|---|
|
|
376
|
+
| `DATABAR_API_KEY` | Your Databar API key (overrides `~/.databar/config`) |
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## Development
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
git clone https://github.com/databar-ai/databar-python
|
|
384
|
+
cd databar-python
|
|
385
|
+
pip install -e ".[dev]"
|
|
386
|
+
pytest
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## License
|
|
392
|
+
|
|
393
|
+
MIT — see [LICENSE](LICENSE).
|