minerva-sdk 0.0.3__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.
- minerva_sdk-0.0.3/.gitignore +217 -0
- minerva_sdk-0.0.3/LICENSE +21 -0
- minerva_sdk-0.0.3/PKG-INFO +201 -0
- minerva_sdk-0.0.3/README.md +169 -0
- minerva_sdk-0.0.3/pyproject.toml +68 -0
- minerva_sdk-0.0.3/src/minerva/__init__.py +68 -0
- minerva_sdk-0.0.3/src/minerva/__main__.py +77 -0
- minerva_sdk-0.0.3/src/minerva/_banner.py +37 -0
- minerva_sdk-0.0.3/src/minerva/_http.py +73 -0
- minerva_sdk-0.0.3/src/minerva/_serialize.py +75 -0
- minerva_sdk-0.0.3/src/minerva/client.py +122 -0
- minerva_sdk-0.0.3/src/minerva/config.py +10 -0
- minerva_sdk-0.0.3/src/minerva/data/__init__.py +51 -0
- minerva_sdk-0.0.3/src/minerva/data/api.py +240 -0
- minerva_sdk-0.0.3/src/minerva/data/usage.py +23 -0
- minerva_sdk-0.0.3/src/minerva/exceptions.py +82 -0
- minerva_sdk-0.0.3/src/minerva/models.py +209 -0
- minerva_sdk-0.0.3/src/minerva/py.typed +0 -0
- minerva_sdk-0.0.3/tests/__init__.py +0 -0
- minerva_sdk-0.0.3/tests/test_sdk.py +390 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
|
|
209
|
+
# Node / JavaScript
|
|
210
|
+
node_modules/
|
|
211
|
+
|
|
212
|
+
# IDE
|
|
213
|
+
.idea/
|
|
214
|
+
.vscode/
|
|
215
|
+
*.swp
|
|
216
|
+
*.swo
|
|
217
|
+
.DS_Store
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Minerva Data
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: minerva-sdk
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: Official Python SDK for the Minerva Data API — resolve, enrich, validate, usage.
|
|
5
|
+
Author: Minerva Data
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: enrichment,identity-resolution,minerva
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Typing :: Typed
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Requires-Dist: httpx<1,>=0.27
|
|
17
|
+
Requires-Dist: pydantic<3,>=2.6
|
|
18
|
+
Provides-Extra: all
|
|
19
|
+
Requires-Dist: pandas>=2; extra == 'all'
|
|
20
|
+
Requires-Dist: tabulate>=0.9; extra == 'all'
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
25
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
27
|
+
Provides-Extra: pandas
|
|
28
|
+
Requires-Dist: pandas>=2; extra == 'pandas'
|
|
29
|
+
Provides-Extra: table
|
|
30
|
+
Requires-Dist: tabulate>=0.9; extra == 'table'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# Minerva SDK
|
|
34
|
+
|
|
35
|
+
The official Python SDK for the Minerva Data API —
|
|
36
|
+
identity **resolution**, person **enrichment**, and validation, with one client, typed responses,
|
|
37
|
+
and input validation baked in.
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from minerva import Minerva
|
|
44
|
+
|
|
45
|
+
mc = Minerva() # reads MINERVA_API_KEY from the environment
|
|
46
|
+
|
|
47
|
+
results = mc.api.enrich([{"record_id": "1", "linkedin_url": "https://www.linkedin.com/in/example"}])
|
|
48
|
+
df = results.to_df() # straight to a DataFrame
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> **Early access.** Data API surface — resolve, enrich, LinkedIn lookup, email validation,
|
|
52
|
+
> country inference, and usage tallies — is wired and tested.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install minerva-sdk
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Optional extras:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install "minerva-sdk[pandas]" # results.to_df()
|
|
66
|
+
pip install "minerva-sdk[table]" # results.to_table()
|
|
67
|
+
pip install "minerva-sdk[all]" # everything
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Requires **Python 3.11+** (tested through 3.14).
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Authentication
|
|
75
|
+
|
|
76
|
+
`Minerva` is the single entry point. The only credential you need is your **API key**:
|
|
77
|
+
|
|
78
|
+
| Variable | Used for |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `MINERVA_API_KEY` | every call the SDK makes |
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
mc = Minerva() # api_key from MINERVA_API_KEY
|
|
84
|
+
mc = Minerva(api_key="mk_live_...") # explicit
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The SDK sends the API key as the `x-api-key` header on every request. The server-side authorizer
|
|
88
|
+
decides what your key is entitled to.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Quickstart
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from minerva import Minerva
|
|
96
|
+
|
|
97
|
+
mc = Minerva(api_key="mk_live_...")
|
|
98
|
+
|
|
99
|
+
# Resolve — match records to a Minerva PID
|
|
100
|
+
mc.api.resolve([{"record_id": "1", "first_name": "Jane", "last_name": "Doe",
|
|
101
|
+
"emails": ["jane.doe@example.com"]}])
|
|
102
|
+
|
|
103
|
+
# Enrich — full profiles (up to 500 records per call)
|
|
104
|
+
resp = mc.api.enrich(
|
|
105
|
+
[{"record_id": "1", "linkedin_url": "https://www.linkedin.com/in/example"}],
|
|
106
|
+
match_condition_fields=["linkedin_url"], # only count it a match if a LinkedIn URL is on file
|
|
107
|
+
)
|
|
108
|
+
for r in resp.results:
|
|
109
|
+
print(r.record_id, r.is_match, r.minerva_pid, r.match_score)
|
|
110
|
+
|
|
111
|
+
# Tabular output
|
|
112
|
+
resp.to_df() # pandas DataFrame (needs [pandas])
|
|
113
|
+
resp.to_csv("out.csv") # write a CSV
|
|
114
|
+
resp.to_dicts() # list[dict]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Validate before you call — `dry_run`
|
|
120
|
+
|
|
121
|
+
Every input-bearing method takes `dry_run=True`. It validates your input **locally** and returns
|
|
122
|
+
the exact request that *would* be sent — **without touching the network**. Invalid input raises
|
|
123
|
+
`MinervaValidationError` immediately, with a precise field message.
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from minerva import Minerva, MinervaValidationError
|
|
127
|
+
|
|
128
|
+
mc = Minerva()
|
|
129
|
+
|
|
130
|
+
req = mc.api.enrich(records, match_condition_fields=["linkedin_url"], dry_run=True)
|
|
131
|
+
# -> EnrichRequest (nothing sent). Inspect req.model_dump() to see the payload.
|
|
132
|
+
|
|
133
|
+
try:
|
|
134
|
+
mc.api.enrich([], dry_run=True) # 0 records — must be at least 1
|
|
135
|
+
except MinervaValidationError as e:
|
|
136
|
+
print("caught before any API call:", e)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Great for checking a batch is well-formed (record limits, allowed `match_condition_fields`,
|
|
140
|
+
record shape, …) before spending a call.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## What you can do
|
|
145
|
+
|
|
146
|
+
| Namespace | Highlights |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `mc.api` | `resolve`, `enrich`, `get_li_contact_info`, `validate_emails`, `infer_record_country`, `call` |
|
|
149
|
+
| `mc.usage` | `tallies()` — your per-endpoint API usage |
|
|
150
|
+
|
|
151
|
+
Every response is a typed model with IDE autocomplete, and the list-shaped ones support
|
|
152
|
+
`.to_df()` / `.to_csv()` / `.to_dicts()` / `.to_table()`.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Custom / tailored endpoints — `mc.api.call`
|
|
157
|
+
|
|
158
|
+
For client-specific routes (preview endpoints, partner integrations, paths Minerva built just
|
|
159
|
+
for your org) on the Data API, use the generic `mc.api.call`:
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
result = mc.api.call("POST", "/v2/acme/lookup", json={"record_id": "abc"})
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Same `x-api-key` auth, same error mapping, same rate-limit handling as the typed methods — the
|
|
166
|
+
difference is the SDK doesn't know the response schema, so you get back the raw parsed JSON.
|
|
167
|
+
The server enforces entitlement; callers without it see a 403 → `MinervaAuthError`.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Error handling
|
|
172
|
+
|
|
173
|
+
All errors derive from `MinervaError`:
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from minerva import (
|
|
177
|
+
MinervaValidationError, # bad input — raised locally, before the call
|
|
178
|
+
MinervaAuthError, # 401/403 — bad key, not entitled
|
|
179
|
+
MinervaRateLimitError, # 429 — has .retry_after
|
|
180
|
+
MinervaAPIError, # other 4xx/5xx — has .status_code and .api_request_id
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
try:
|
|
184
|
+
mc.api.enrich(records)
|
|
185
|
+
except MinervaRateLimitError as e:
|
|
186
|
+
time.sleep(e.retry_after or 1)
|
|
187
|
+
except MinervaAPIError as e:
|
|
188
|
+
print("request failed:", e.api_request_id) # quote this to support
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Responses are forward-compatible: new fields the API adds won't break an older client.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Python support
|
|
196
|
+
|
|
197
|
+
3.11, 3.12, 3.13, 3.14. Fully type-annotated (ships `py.typed`).
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
[MIT](LICENSE) © Minerva Data.
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Minerva SDK
|
|
2
|
+
|
|
3
|
+
The official Python SDK for the Minerva Data API —
|
|
4
|
+
identity **resolution**, person **enrichment**, and validation, with one client, typed responses,
|
|
5
|
+
and input validation baked in.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
from minerva import Minerva
|
|
12
|
+
|
|
13
|
+
mc = Minerva() # reads MINERVA_API_KEY from the environment
|
|
14
|
+
|
|
15
|
+
results = mc.api.enrich([{"record_id": "1", "linkedin_url": "https://www.linkedin.com/in/example"}])
|
|
16
|
+
df = results.to_df() # straight to a DataFrame
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
> **Early access.** Data API surface — resolve, enrich, LinkedIn lookup, email validation,
|
|
20
|
+
> country inference, and usage tallies — is wired and tested.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install minerva-sdk
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Optional extras:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install "minerva-sdk[pandas]" # results.to_df()
|
|
34
|
+
pip install "minerva-sdk[table]" # results.to_table()
|
|
35
|
+
pip install "minerva-sdk[all]" # everything
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Requires **Python 3.11+** (tested through 3.14).
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Authentication
|
|
43
|
+
|
|
44
|
+
`Minerva` is the single entry point. The only credential you need is your **API key**:
|
|
45
|
+
|
|
46
|
+
| Variable | Used for |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `MINERVA_API_KEY` | every call the SDK makes |
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
mc = Minerva() # api_key from MINERVA_API_KEY
|
|
52
|
+
mc = Minerva(api_key="mk_live_...") # explicit
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The SDK sends the API key as the `x-api-key` header on every request. The server-side authorizer
|
|
56
|
+
decides what your key is entitled to.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Quickstart
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from minerva import Minerva
|
|
64
|
+
|
|
65
|
+
mc = Minerva(api_key="mk_live_...")
|
|
66
|
+
|
|
67
|
+
# Resolve — match records to a Minerva PID
|
|
68
|
+
mc.api.resolve([{"record_id": "1", "first_name": "Jane", "last_name": "Doe",
|
|
69
|
+
"emails": ["jane.doe@example.com"]}])
|
|
70
|
+
|
|
71
|
+
# Enrich — full profiles (up to 500 records per call)
|
|
72
|
+
resp = mc.api.enrich(
|
|
73
|
+
[{"record_id": "1", "linkedin_url": "https://www.linkedin.com/in/example"}],
|
|
74
|
+
match_condition_fields=["linkedin_url"], # only count it a match if a LinkedIn URL is on file
|
|
75
|
+
)
|
|
76
|
+
for r in resp.results:
|
|
77
|
+
print(r.record_id, r.is_match, r.minerva_pid, r.match_score)
|
|
78
|
+
|
|
79
|
+
# Tabular output
|
|
80
|
+
resp.to_df() # pandas DataFrame (needs [pandas])
|
|
81
|
+
resp.to_csv("out.csv") # write a CSV
|
|
82
|
+
resp.to_dicts() # list[dict]
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Validate before you call — `dry_run`
|
|
88
|
+
|
|
89
|
+
Every input-bearing method takes `dry_run=True`. It validates your input **locally** and returns
|
|
90
|
+
the exact request that *would* be sent — **without touching the network**. Invalid input raises
|
|
91
|
+
`MinervaValidationError` immediately, with a precise field message.
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from minerva import Minerva, MinervaValidationError
|
|
95
|
+
|
|
96
|
+
mc = Minerva()
|
|
97
|
+
|
|
98
|
+
req = mc.api.enrich(records, match_condition_fields=["linkedin_url"], dry_run=True)
|
|
99
|
+
# -> EnrichRequest (nothing sent). Inspect req.model_dump() to see the payload.
|
|
100
|
+
|
|
101
|
+
try:
|
|
102
|
+
mc.api.enrich([], dry_run=True) # 0 records — must be at least 1
|
|
103
|
+
except MinervaValidationError as e:
|
|
104
|
+
print("caught before any API call:", e)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Great for checking a batch is well-formed (record limits, allowed `match_condition_fields`,
|
|
108
|
+
record shape, …) before spending a call.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## What you can do
|
|
113
|
+
|
|
114
|
+
| Namespace | Highlights |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `mc.api` | `resolve`, `enrich`, `get_li_contact_info`, `validate_emails`, `infer_record_country`, `call` |
|
|
117
|
+
| `mc.usage` | `tallies()` — your per-endpoint API usage |
|
|
118
|
+
|
|
119
|
+
Every response is a typed model with IDE autocomplete, and the list-shaped ones support
|
|
120
|
+
`.to_df()` / `.to_csv()` / `.to_dicts()` / `.to_table()`.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Custom / tailored endpoints — `mc.api.call`
|
|
125
|
+
|
|
126
|
+
For client-specific routes (preview endpoints, partner integrations, paths Minerva built just
|
|
127
|
+
for your org) on the Data API, use the generic `mc.api.call`:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
result = mc.api.call("POST", "/v2/acme/lookup", json={"record_id": "abc"})
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Same `x-api-key` auth, same error mapping, same rate-limit handling as the typed methods — the
|
|
134
|
+
difference is the SDK doesn't know the response schema, so you get back the raw parsed JSON.
|
|
135
|
+
The server enforces entitlement; callers without it see a 403 → `MinervaAuthError`.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Error handling
|
|
140
|
+
|
|
141
|
+
All errors derive from `MinervaError`:
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from minerva import (
|
|
145
|
+
MinervaValidationError, # bad input — raised locally, before the call
|
|
146
|
+
MinervaAuthError, # 401/403 — bad key, not entitled
|
|
147
|
+
MinervaRateLimitError, # 429 — has .retry_after
|
|
148
|
+
MinervaAPIError, # other 4xx/5xx — has .status_code and .api_request_id
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
try:
|
|
152
|
+
mc.api.enrich(records)
|
|
153
|
+
except MinervaRateLimitError as e:
|
|
154
|
+
time.sleep(e.retry_after or 1)
|
|
155
|
+
except MinervaAPIError as e:
|
|
156
|
+
print("request failed:", e.api_request_id) # quote this to support
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Responses are forward-compatible: new fields the API adds won't break an older client.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Python support
|
|
164
|
+
|
|
165
|
+
3.11, 3.12, 3.13, 3.14. Fully type-annotated (ships `py.typed`).
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
[MIT](LICENSE) © Minerva Data.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "minerva-sdk"
|
|
7
|
+
version = "0.0.3"
|
|
8
|
+
description = "Official Python SDK for the Minerva Data API — resolve, enrich, validate, usage."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Minerva Data" }]
|
|
13
|
+
keywords = ["minerva", "identity-resolution", "enrichment"]
|
|
14
|
+
|
|
15
|
+
# Core runtime: HTTP client + validation. Everything else is an extra, so
|
|
16
|
+
# `pip install minerva-sdk` stays small.
|
|
17
|
+
dependencies = [
|
|
18
|
+
"httpx>=0.27,<1",
|
|
19
|
+
"pydantic>=2.6,<3",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
classifiers = [
|
|
23
|
+
"License :: OSI Approved :: MIT License",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Programming Language :: Python :: 3.14",
|
|
28
|
+
"Typing :: Typed",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
# results.to_df() — `[pandas]`
|
|
33
|
+
pandas = ["pandas>=2"]
|
|
34
|
+
# results.to_table() pretty terminal output — `[table]`
|
|
35
|
+
table = ["tabulate>=0.9"]
|
|
36
|
+
all = ["minerva-sdk[pandas,table]"]
|
|
37
|
+
|
|
38
|
+
dev = [
|
|
39
|
+
"pytest>=8",
|
|
40
|
+
"pytest-asyncio>=0.23",
|
|
41
|
+
"respx>=0.21", # httpx mocking
|
|
42
|
+
"mypy>=1.10",
|
|
43
|
+
"ruff>=0.5",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[tool.hatch.build.targets.wheel]
|
|
47
|
+
packages = ["src/minerva"]
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.targets.sdist]
|
|
50
|
+
include = ["/src", "/tests", "/README.md", "/LICENSE", "/pyproject.toml"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff]
|
|
53
|
+
target-version = "py311"
|
|
54
|
+
line-length = 100
|
|
55
|
+
|
|
56
|
+
[tool.mypy]
|
|
57
|
+
python_version = "3.11"
|
|
58
|
+
# Pragmatic baseline for a lazy-namespace SDK with optional extras; tighten over time.
|
|
59
|
+
warn_redundant_casts = true
|
|
60
|
+
warn_unused_ignores = true
|
|
61
|
+
|
|
62
|
+
[[tool.mypy.overrides]]
|
|
63
|
+
# Optional extras — not installed in the default / CI env.
|
|
64
|
+
module = ["pandas", "tabulate"]
|
|
65
|
+
ignore_missing_imports = true
|
|
66
|
+
|
|
67
|
+
[tool.pytest.ini_options]
|
|
68
|
+
asyncio_mode = "auto"
|