minerva-sdk 0.0.3__py3-none-any.whl

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/__init__.py ADDED
@@ -0,0 +1,68 @@
1
+ """minerva-sdk — official Python SDK for the Minerva Data API.
2
+
3
+ from minerva import Minerva
4
+ mc = Minerva() # api_key from MINERVA_API_KEY
5
+ mc.enrich([{"record_id": "1", "linkedin_url": "..."}])
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from ._banner import banner, print_banner
10
+ from .client import Minerva
11
+ from .exceptions import (
12
+ MinervaAPIError,
13
+ MinervaAuthError,
14
+ MinervaConfigError,
15
+ MinervaError,
16
+ MinervaRateLimitError,
17
+ MinervaValidationError,
18
+ MinervaWIPWarning,
19
+ )
20
+ from .models import (
21
+ EnrichRecord,
22
+ EnrichRequest,
23
+ EnrichResponse,
24
+ EnrichResult,
25
+ InferCountryRequest,
26
+ LiContactInfoRequest,
27
+ MatchConditionField,
28
+ ResolveRequest,
29
+ ResolveResponse,
30
+ ResolveResult,
31
+ UsageResponse,
32
+ ValidateEmailsRequest,
33
+ )
34
+
35
+ try:
36
+ from importlib.metadata import PackageNotFoundError, version as _pkg_version
37
+ __version__ = _pkg_version("minerva-sdk")
38
+ except PackageNotFoundError:
39
+ __version__ = "0.0.0+dev"
40
+ del _pkg_version
41
+ del PackageNotFoundError
42
+
43
+ __all__ = [
44
+ "Minerva",
45
+ "banner",
46
+ "print_banner",
47
+ # errors
48
+ "MinervaError",
49
+ "MinervaConfigError",
50
+ "MinervaValidationError",
51
+ "MinervaAuthError",
52
+ "MinervaRateLimitError",
53
+ "MinervaAPIError",
54
+ "MinervaWIPWarning",
55
+ # models
56
+ "EnrichRecord",
57
+ "EnrichRequest",
58
+ "EnrichResponse",
59
+ "EnrichResult",
60
+ "MatchConditionField",
61
+ "ResolveRequest",
62
+ "ResolveResponse",
63
+ "ResolveResult",
64
+ "LiContactInfoRequest",
65
+ "ValidateEmailsRequest",
66
+ "InferCountryRequest",
67
+ "UsageResponse",
68
+ ]
minerva/__main__.py ADDED
@@ -0,0 +1,77 @@
1
+ """``python -m minerva`` — quick reference.
2
+
3
+ Prints the banner, version, a one-paragraph usage summary, and pointers to the
4
+ two real ways to get help:
5
+
6
+ * ``help(minerva.Minerva)`` in a REPL — full class + method docstrings
7
+ * the project README on the upstream repo
8
+
9
+ Supports ``--help`` / ``-h`` (same output) and ``--version`` (version only).
10
+ The SDK itself is a library; this entry point exists so a new user typing
11
+ ``python -m minerva`` doesn't hit silence.
12
+ """
13
+ from __future__ import annotations
14
+
15
+ import argparse
16
+ import sys
17
+
18
+ from . import __version__
19
+ from ._banner import banner
20
+
21
+
22
+ _USAGE = """\
23
+ Quick start
24
+ -----------
25
+
26
+ from minerva import Minerva
27
+
28
+ # Credential comes from a constructor arg OR the env var:
29
+ # MINERVA_API_KEY — x-api-key for the data plane (required)
30
+ mc = Minerva()
31
+
32
+ # Data API (x-api-key):
33
+ mc.api.resolve([{"record_id": "1", "linkedin_url": "..."}])
34
+ mc.api.enrich([{"record_id": "1", "linkedin_url": "..."}]).to_df()
35
+
36
+ # Escape hatch for client-specific / preview endpoints on the Data API:
37
+ mc.api.call("POST", "/v2/acme/lookup", json={"record_id": "abc"})
38
+
39
+ # Per-endpoint usage tallies:
40
+ mc.usage.tallies()
41
+
42
+ Resources (namespaces on the client)
43
+ ------------------------------------
44
+ .api resolve / enrich / get_li_contact_info / validate_emails /
45
+ infer_record_country / call (raw escape hatch)
46
+ .usage per-endpoint usage tallies
47
+
48
+ For full docs:
49
+ >>> import minerva
50
+ >>> help(minerva.Minerva) # class + per-method docstrings
51
+ >>> help(minerva.Minerva.enrich) # one method
52
+ """
53
+
54
+
55
+ def main(argv: list[str] | None = None) -> int:
56
+ parser = argparse.ArgumentParser(
57
+ prog="python -m minerva",
58
+ description="Minerva SDK quick reference (the SDK is a library — this is a help screen).",
59
+ formatter_class=argparse.RawDescriptionHelpFormatter,
60
+ epilog=_USAGE,
61
+ )
62
+ parser.add_argument(
63
+ "--version",
64
+ action="version",
65
+ version=f"minerva-sdk {__version__}",
66
+ help="Print the SDK version and exit.",
67
+ )
68
+ parser.parse_args(argv)
69
+
70
+ # No subcommand: print banner + usage. argparse already handled --help / --version.
71
+ print(banner(), file=sys.stderr)
72
+ print(_USAGE)
73
+ return 0
74
+
75
+
76
+ if __name__ == "__main__":
77
+ raise SystemExit(main())
minerva/_banner.py ADDED
@@ -0,0 +1,37 @@
1
+ """The Minerva ASCII banner. Printed to stderr on CLI startup."""
2
+ from __future__ import annotations
3
+
4
+ import sys
5
+ from typing import Optional, TextIO
6
+
7
+ LOGO = r"""
8
+ ██████████████████████████████████
9
+ ███████████ ███████████
10
+ ██ ████ ████ ██
11
+ ██ ███ ███ ██
12
+ ██ ██████ ██ ██ ██████ ██
13
+ ██ ██ ██████ ██ ██
14
+ ██ █ ████ █ ██
15
+ ████████████████████████████████████
16
+ ██ █ ████ █ ██
17
+ ██ ██ ██████ ██ ██
18
+ ██ ██████ ██ ██ ██████ ██
19
+ ██ ███ ███ ██
20
+ ██ ████ ████ ██
21
+ ███████████ ███████████
22
+ ██████████████████████████████████ Minerva®
23
+ """
24
+
25
+ _RULE = "-" * 77
26
+
27
+
28
+ def banner(version: Optional[str] = None) -> str:
29
+ if version is None:
30
+ from . import __version__
31
+
32
+ version = __version__
33
+ return f"{LOGO}\n{_RULE}\nMINERVA PYTHON SDK\n- v{version}\n{_RULE}"
34
+
35
+
36
+ def print_banner(file: TextIO = sys.stderr, version: Optional[str] = None) -> None:
37
+ print(banner(version), file=file)
minerva/_http.py ADDED
@@ -0,0 +1,73 @@
1
+ """Thin httpx wrapper: one request method, status→exception mapping, JSON out."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Any, Optional
5
+
6
+ import httpx
7
+
8
+ from .exceptions import (
9
+ MinervaAPIError,
10
+ MinervaAuthError,
11
+ MinervaRateLimitError,
12
+ )
13
+
14
+
15
+ class HttpClient:
16
+ def __init__(self, *, timeout: float = 30.0, transport: Optional[httpx.BaseTransport] = None) -> None:
17
+ self._client = httpx.Client(timeout=timeout, transport=transport)
18
+
19
+ def request(
20
+ self,
21
+ method: str,
22
+ url: str,
23
+ *,
24
+ headers: Optional[dict[str, str]] = None,
25
+ json: Any = None,
26
+ params: Optional[dict[str, Any]] = None,
27
+ ) -> Any:
28
+ try:
29
+ resp = self._client.request(method, url, headers=headers, json=json, params=params)
30
+ except httpx.HTTPError as e: # network/timeout
31
+ raise MinervaAPIError(f"request failed: {e}") from e
32
+ return _handle(resp)
33
+
34
+ def stream_to(self, method: str, url: str, dest: str, *, headers=None, params=None) -> None:
35
+ with self._client.stream(method, url, headers=headers, params=params) as resp:
36
+ if resp.status_code >= 400:
37
+ resp.read()
38
+ _handle(resp)
39
+ with open(dest, "wb") as fh:
40
+ for chunk in resp.iter_bytes():
41
+ fh.write(chunk)
42
+
43
+ def close(self) -> None:
44
+ self._client.close()
45
+
46
+
47
+ def _handle(resp: httpx.Response) -> Any:
48
+ if resp.is_success:
49
+ if not resp.content:
50
+ return None
51
+ try:
52
+ return resp.json()
53
+ except ValueError:
54
+ return resp.text
55
+
56
+ body: Any = None
57
+ api_request_id = None
58
+ try:
59
+ body = resp.json()
60
+ if isinstance(body, dict):
61
+ api_request_id = body.get("api_request_id")
62
+ except ValueError:
63
+ body = resp.text
64
+
65
+ msg = f"{resp.status_code} {resp.reason_phrase}: {body}"
66
+ if resp.status_code in (401, 403):
67
+ raise MinervaAuthError(msg)
68
+ if resp.status_code == 429:
69
+ retry = resp.headers.get("retry-after")
70
+ raise MinervaRateLimitError(msg, retry_after=float(retry) if retry else None)
71
+ raise MinervaAPIError(
72
+ msg, status_code=resp.status_code, api_request_id=api_request_id, body=body
73
+ )
minerva/_serialize.py ADDED
@@ -0,0 +1,75 @@
1
+ """Tabular output mixin: every results model can reshape itself.
2
+
3
+ Typing stays intact (you still get the typed object); these are opt-in views.
4
+ ``pandas`` / ``tabulate`` are optional extras and imported lazily.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ import csv
9
+ import io
10
+ import json
11
+ from typing import Any, Optional
12
+
13
+
14
+ class TabularMixin:
15
+ """Mix into a pydantic model to get ``to_dicts``/``to_df``/``to_csv``/``to_table``.
16
+
17
+ Override ``_tabular_rows`` to control flattening (default: the model as one row).
18
+ """
19
+
20
+ def _tabular_rows(self) -> list[dict[str, Any]]:
21
+ return [self.model_dump(mode="json")] # type: ignore[attr-defined]
22
+
23
+ def to_dicts(self) -> list[dict[str, Any]]:
24
+ return self._tabular_rows()
25
+
26
+ def to_df(self): # -> "pandas.DataFrame"
27
+ try:
28
+ import pandas as pd
29
+ except ImportError as e: # pragma: no cover
30
+ raise ImportError(
31
+ "to_df() needs the [pandas] extra: pip install 'minerva-sdk[pandas]'"
32
+ ) from e
33
+ return pd.DataFrame(self._tabular_rows())
34
+
35
+ def to_csv(self, path: Optional[str] = None) -> Optional[str]:
36
+ rows = self._tabular_rows()
37
+ columns = list(dict.fromkeys(k for row in rows for k in row))
38
+ buf = io.StringIO()
39
+ writer = csv.DictWriter(buf, fieldnames=columns)
40
+ writer.writeheader()
41
+ for row in rows:
42
+ writer.writerow(
43
+ {
44
+ k: json.dumps(v) if isinstance(v, (list, dict)) else v
45
+ for k, v in row.items()
46
+ }
47
+ )
48
+ data = buf.getvalue()
49
+ if path is None:
50
+ return data
51
+ with open(path, "w", newline="", encoding="utf-8") as fh:
52
+ fh.write(data)
53
+ return None
54
+
55
+ def to_table(self) -> str:
56
+ try:
57
+ from tabulate import tabulate
58
+ except ImportError as e: # pragma: no cover
59
+ raise ImportError(
60
+ "to_table() needs the [table] extra: pip install 'minerva-sdk[table]'"
61
+ ) from e
62
+ return tabulate(self._tabular_rows(), headers="keys", tablefmt="github")
63
+
64
+
65
+ def as_format(result: TabularMixin, fmt: str):
66
+ """Convenience for the ``format=`` sugar kwarg on list endpoints."""
67
+ if fmt == "models":
68
+ return result
69
+ if fmt == "records":
70
+ return result.to_dicts()
71
+ if fmt == "df":
72
+ return result.to_df()
73
+ if fmt == "csv":
74
+ return result.to_csv()
75
+ raise ValueError(f"unknown format {fmt!r} (expected models|records|df|csv)")
minerva/client.py ADDED
@@ -0,0 +1,122 @@
1
+ """``Minerva`` — the single entry point.
2
+
3
+ Construct it once; branch into ``.api`` / ``.usage``.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import os
8
+ from functools import cached_property
9
+ from typing import Any, Optional
10
+
11
+ from ._http import HttpClient
12
+ from .config import Config
13
+ from .exceptions import MinervaAuthError
14
+
15
+
16
+ class Minerva:
17
+ """Single entry point for the Minerva API. Construct once; reuse for the
18
+ lifetime of the process.
19
+
20
+ Credential resolution order:
21
+
22
+ 1. Explicit ``api_key=`` constructor argument
23
+ 2. ``MINERVA_API_KEY`` environment variable
24
+
25
+ Args:
26
+ api_key: ``x-api-key`` for the Minerva API. Falls back to
27
+ ``MINERVA_API_KEY``.
28
+ timeout: Per-request timeout in seconds. Default 30.
29
+
30
+ Example:
31
+ >>> mc = Minerva(api_key="mk_live_...")
32
+ >>> mc.api.enrich([{"record_id": "1", "linkedin_url": "..."}]).to_df()
33
+
34
+ Or via env var only::
35
+
36
+ >>> mc = Minerva()
37
+ >>> mc.api.resolve([{"record_id": "1", "email": "..."}])
38
+
39
+ As a context manager (closes the HTTP pool on exit)::
40
+
41
+ >>> with Minerva() as mc:
42
+ ... mc.api.enrich([{"record_id": "1", "linkedin_url": "..."}])
43
+
44
+ See also:
45
+ ``python -m minerva`` for a one-screen usage cheat-sheet.
46
+ """
47
+
48
+ _config: Config
49
+ _http: HttpClient
50
+ _api_key: Optional[str]
51
+
52
+ _PROTECTED_ATTRS = frozenset({"_config", "_http", "_api_key"})
53
+
54
+ def __init__(
55
+ self,
56
+ api_key: Optional[str] = None,
57
+ *,
58
+ timeout: float = 30.0,
59
+ http: Optional[HttpClient] = None,
60
+ ) -> None:
61
+ super().__setattr__("_api_key", api_key)
62
+ super().__setattr__("_config", Config())
63
+ super().__setattr__("_http", http or HttpClient(timeout=timeout))
64
+
65
+ def __setattr__(self, name: str, value: Any) -> None:
66
+ """Reject writes to the Minerva instance after construction.
67
+
68
+ Minerva is configured once at construction. Attempting to assign to
69
+ any attribute afterward (including reassigning ``_config`` / ``_http`` /
70
+ ``_api_key``) raises ``AttributeError``. Construct a new ``Minerva()``
71
+ instance if you need different settings.
72
+ """
73
+ if name in type(self)._PROTECTED_ATTRS:
74
+ raise AttributeError(
75
+ f"Minerva.{name} is read-only after construction. Construct a "
76
+ "new Minerva() instance with the values you want."
77
+ )
78
+ raise AttributeError(
79
+ f"Minerva has no attribute {name!r}. Use the public methods "
80
+ "(mc.api.enrich / mc.api.resolve / mc.api.call / mc.usage.tallies / …) "
81
+ "and the api_key= constructor arg."
82
+ )
83
+
84
+ # -------------------------------------------------------------- transport
85
+
86
+ def _request_data(self, method: str, path: str, **kw: Any) -> Any:
87
+ key = self._api_key or os.environ.get("MINERVA_API_KEY")
88
+ if not key:
89
+ raise MinervaAuthError("no API key (set MINERVA_API_KEY or pass api_key=).")
90
+ extra = kw.pop("headers", None) or {}
91
+ headers = {**extra, "x-api-key": key}
92
+ return self._http.request(
93
+ method, self._config.data_base_url + path, headers=headers, **kw
94
+ )
95
+
96
+ # -------------------------------------------------------------- namespaces
97
+
98
+ @cached_property
99
+ def api(self):
100
+ """Data API: resolve / enrich / get_li_contact_info / validate_emails / infer_record_country."""
101
+ from .data.api import APIResource
102
+
103
+ return APIResource(self)
104
+
105
+ @cached_property
106
+ def usage(self):
107
+ """Usage tallies: ``mc.usage.tallies()`` returns per-endpoint API usage."""
108
+ from .data.usage import UsageResource
109
+
110
+ return UsageResource(self)
111
+
112
+ # ----------------------------------------------------------- lifecycle
113
+
114
+ def close(self) -> None:
115
+ """Close the underlying HTTP connection pool."""
116
+ self._http.close()
117
+
118
+ def __enter__(self) -> "Minerva":
119
+ return self
120
+
121
+ def __exit__(self, *exc: Any) -> None:
122
+ self.close()
minerva/config.py ADDED
@@ -0,0 +1,10 @@
1
+ """Base URLs and endpoint paths."""
2
+ from __future__ import annotations
3
+
4
+ from dataclasses import dataclass
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class Config:
9
+ data_base_url: str = "https://api.minerva.io"
10
+ usage_path: str = "/usage"
@@ -0,0 +1,51 @@
1
+ """Resource namespaces.
2
+
3
+ Each resource wraps the owning :class:`~minerva.client.Minerva` and uses its transport.
4
+ The shared :func:`build_request` helper gives every call the same dry-run / validation
5
+ contract: input is validated locally (pydantic) and turned into a typed request model
6
+ *before* any HTTP request, raising :class:`~minerva.exceptions.MinervaValidationError`
7
+ on bad input.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ from typing import TYPE_CHECKING, Type, TypeVar
12
+
13
+ from pydantic import BaseModel
14
+ from pydantic import ValidationError as _PydValidationError
15
+
16
+ from ..exceptions import MinervaValidationError
17
+
18
+ if TYPE_CHECKING:
19
+ from ..client import Minerva
20
+
21
+ _RequestModel = TypeVar("_RequestModel", bound=BaseModel)
22
+
23
+
24
+ def build_request(model_cls: Type[_RequestModel], **fields: object) -> _RequestModel:
25
+ """Validate ``fields`` into ``model_cls``, locally and before any network call.
26
+
27
+ This is the single choke point every input-bearing SDK method routes through, so
28
+ validation behaves identically everywhere (and powers ``dry_run``).
29
+
30
+ Args:
31
+ model_cls: The pydantic request model to validate against.
32
+ **fields: The caller-supplied arguments to validate.
33
+
34
+ Returns:
35
+ The validated request model instance.
36
+
37
+ Raises:
38
+ MinervaValidationError: If ``fields`` fail validation. Wraps the underlying
39
+ ``pydantic.ValidationError`` so callers catch one SDK exception type.
40
+ """
41
+ try:
42
+ return model_cls(**fields)
43
+ except _PydValidationError as exc:
44
+ raise MinervaValidationError(str(exc)) from exc
45
+
46
+
47
+ class _Resource:
48
+ """Base for resource namespaces; holds a reference to the owning client."""
49
+
50
+ def __init__(self, client: "Minerva") -> None:
51
+ self._client = client
minerva/data/api.py ADDED
@@ -0,0 +1,240 @@
1
+ """Data plane (x-api-key) — the public Minerva API.
2
+
3
+ Reached as ``client.api.*`` (with top-level shortcuts like ``client.enrich``).
4
+
5
+ Every input-bearing method validates locally first and accepts ``dry_run``::
6
+
7
+ client.api.enrich(records, dry_run=True) # -> EnrichRequest, no HTTP call
8
+
9
+ ``dry_run=True`` returns the validated request model (the exact payload that would be
10
+ sent) and never touches the network. Invalid input raises ``MinervaValidationError``
11
+ either way — always before any request is made.
12
+ """
13
+ from __future__ import annotations
14
+
15
+ from typing import Any, Optional, Union
16
+
17
+ from . import _Resource, build_request
18
+ from ..models import (
19
+ EnrichRecord,
20
+ EnrichRequest,
21
+ EnrichResponse,
22
+ InferCountryRequest,
23
+ LiContactInfoRequest,
24
+ MatchConditionField,
25
+ ResolveRequest,
26
+ ResolveResponse,
27
+ ValidateEmailsRequest,
28
+ )
29
+
30
+ RecordInput = Union[dict[str, Any], EnrichRecord]
31
+
32
+
33
+ class APIResource(_Resource):
34
+ """resolve / enrich / get_li_contact_info / validate_emails / infer_record_country."""
35
+
36
+ # ----------------------------------------------------------------- enrich
37
+ def enrich(
38
+ self,
39
+ records: list[RecordInput],
40
+ *,
41
+ version: str = "v2",
42
+ match_condition_fields: Optional[list[Union[str, MatchConditionField]]] = None,
43
+ return_fields: Optional[list[str]] = None,
44
+ dry_run: bool = False,
45
+ ) -> Union[EnrichResponse, EnrichRequest]:
46
+ """Enrich up to 500 person records with full profile data.
47
+
48
+ Args:
49
+ records: Records to enrich (dicts or ``EnrichRecord``); each needs a ``record_id``.
50
+ version: API version — ``"v2"`` (default) or ``"v1"``.
51
+ match_condition_fields: Up to 3 fields a match must contain to be returned.
52
+ return_fields: Optional allow-list of fields to return beyond the base set.
53
+ dry_run: If True, validate and return the ``EnrichRequest`` — no HTTP call.
54
+
55
+ Returns:
56
+ ``EnrichResponse`` normally; the validated ``EnrichRequest`` when ``dry_run``.
57
+
58
+ Raises:
59
+ MinervaValidationError: Invalid input (raised before any HTTP call).
60
+ MinervaAuthError: 401/403 (bad key / not entitled).
61
+ MinervaRateLimitError: 429.
62
+ MinervaAPIError: Other non-2xx responses.
63
+
64
+ Example:
65
+ >>> resp = client.enrich([{"record_id": "1", "linkedin_url": "..."}])
66
+ >>> resp.to_df()
67
+ """
68
+ request = build_request(
69
+ EnrichRequest,
70
+ records=records,
71
+ match_condition_fields=match_condition_fields,
72
+ return_fields=return_fields,
73
+ )
74
+ if dry_run:
75
+ return request
76
+ data = self._client._request_data(
77
+ "POST", f"/{version}/enrich", json=request.model_dump(mode="json", exclude_none=True)
78
+ )
79
+ return EnrichResponse.model_validate(data)
80
+
81
+ # ---------------------------------------------------------------- resolve
82
+ def resolve(
83
+ self,
84
+ records: list[RecordInput],
85
+ *,
86
+ version: str = "v2",
87
+ match_condition_fields: Optional[list[str]] = None,
88
+ dry_run: bool = False,
89
+ ) -> Union[ResolveResponse, ResolveRequest]:
90
+ """Match records to Minerva PIDs (identity only, no profile data).
91
+
92
+ Args:
93
+ records: Records to resolve (dicts or ``EnrichRecord``); each needs a ``record_id``.
94
+ version: API version — ``"v2"`` (default) or ``"v1"``.
95
+ match_condition_fields: Up to 3 fields a match must contain (e.g. ``linkedin_url``,
96
+ ``minerva_pid``).
97
+ dry_run: If True, validate and return the ``ResolveRequest`` — no HTTP call.
98
+
99
+ Returns:
100
+ ``ResolveResponse`` normally; the validated ``ResolveRequest`` when ``dry_run``.
101
+
102
+ Raises:
103
+ MinervaValidationError: Invalid input (before any HTTP call).
104
+ MinervaAuthError | MinervaRateLimitError | MinervaAPIError: On API errors.
105
+ """
106
+ request = build_request(
107
+ ResolveRequest, records=records, match_condition_fields=match_condition_fields
108
+ )
109
+ if dry_run:
110
+ return request
111
+ data = self._client._request_data(
112
+ "POST", f"/{version}/resolve", json=request.model_dump(mode="json", exclude_none=True)
113
+ )
114
+ return ResolveResponse.model_validate(data)
115
+
116
+ # ----------------------------------------------------- get_li_contact_info
117
+ def get_li_contact_info(
118
+ self,
119
+ records: list[str],
120
+ *,
121
+ version: str = "v2",
122
+ presence_only: bool = False,
123
+ dry_run: bool = False,
124
+ ) -> Union[dict[str, Any], LiContactInfoRequest]:
125
+ """Look up contact info for LinkedIn member ids.
126
+
127
+ Args:
128
+ records: LinkedIn member-id strings (1–500), e.g. ``["1000000001"]``.
129
+ version: ``"v2"`` (default) or ``"v1"``.
130
+ presence_only: v2 only — return presence flags, not the contact values.
131
+ dry_run: If True, validate and return the request — no HTTP call.
132
+
133
+ Returns:
134
+ The decoded JSON response; the validated ``LiContactInfoRequest`` when ``dry_run``.
135
+
136
+ Raises:
137
+ MinervaValidationError: Invalid input (before any HTTP call).
138
+ MinervaAuthError | MinervaRateLimitError | MinervaAPIError: On API errors.
139
+ """
140
+ request = build_request(LiContactInfoRequest, records=records, presence_only=presence_only)
141
+ if dry_run:
142
+ return request
143
+ payload = request.model_dump(mode="json")
144
+ if version == "v1":
145
+ payload.pop("presence_only", None) # v1 has no presence_only flag
146
+ return self._client._request_data("POST", f"/{version}/get_li_contact_info", json=payload)
147
+
148
+ # ------------------------------------------------------------- validation
149
+ def validate_emails(
150
+ self, records: list[str], *, dry_run: bool = False
151
+ ) -> Union[dict[str, Any], ValidateEmailsRequest]:
152
+ """Verify email addresses against the Minerva database.
153
+
154
+ Args:
155
+ records: Email-address strings (1–500).
156
+ dry_run: If True, validate and return the request — no HTTP call.
157
+
158
+ Raises:
159
+ MinervaValidationError: Invalid input (before any HTTP call).
160
+ MinervaAuthError | MinervaRateLimitError | MinervaAPIError: On API errors.
161
+ """
162
+ request = build_request(ValidateEmailsRequest, records=records)
163
+ if dry_run:
164
+ return request
165
+ return self._client._request_data("POST", "/v2/validate_emails", json=request.model_dump())
166
+
167
+ def infer_record_country(
168
+ self, records: list[dict[str, Any]], *, dry_run: bool = False
169
+ ) -> Union[dict[str, Any], InferCountryRequest]:
170
+ """Infer each record's country from its contact info.
171
+
172
+ Args:
173
+ records: Record objects (1–500), each with ``record_id`` + emails / phones / name.
174
+ dry_run: If True, validate and return the request — no HTTP call.
175
+
176
+ Raises:
177
+ MinervaValidationError: Invalid input (before any HTTP call).
178
+ MinervaAuthError | MinervaRateLimitError | MinervaAPIError: On API errors.
179
+ """
180
+ request = build_request(InferCountryRequest, records=records)
181
+ if dry_run:
182
+ return request
183
+ return self._client._request_data("POST", "/v2/infer_record_country", json=request.model_dump())
184
+
185
+ # --------------------------------------------------- raw escape hatch
186
+ def call(
187
+ self,
188
+ method: str,
189
+ path: str,
190
+ *,
191
+ params: Optional[dict[str, Any]] = None,
192
+ json: Optional[Any] = None,
193
+ headers: Optional[dict[str, str]] = None,
194
+ ) -> Any:
195
+ """Issue an authenticated request to an arbitrary data-API path.
196
+
197
+ Escape hatch for client-specific or preview endpoints that don't
198
+ have a typed wrapper yet. Authentication, error mapping, and
199
+ rate-limit handling work the same as the typed methods.
200
+
201
+ Args:
202
+ method: HTTP verb (``"GET"``, ``"POST"``, ``"PUT"``, ``"DELETE"``, ...).
203
+ path: URL path beginning with ``"/"``, e.g.
204
+ ``"/v2/your-special-endpoint"``.
205
+ params: Optional query-string dict.
206
+ json: Optional JSON body (for POST/PUT/PATCH).
207
+ headers: Optional extra request headers. The ``x-api-key``
208
+ header is set by the SDK and can't be overridden here.
209
+
210
+ Returns:
211
+ The parsed JSON response body. No pydantic validation is
212
+ applied — the SDK doesn't know the schema.
213
+
214
+ Raises:
215
+ MinervaValidationError: ``path`` is missing or doesn't start with ``/``.
216
+ MinervaAuthError: 401/403 — your key isn't entitled to this endpoint.
217
+ MinervaRateLimitError: 429.
218
+ MinervaAPIError: Other non-2xx responses.
219
+
220
+ Example:
221
+ >>> mc.api.call("POST", "/v2/acme/lookup", json={"record_id": "abc"})
222
+ {'matches': [...]}
223
+
224
+ >>> mc.api.call("GET", "/v2/acme/audit", params={"since": "2026-05-01"})
225
+ """
226
+ from ..exceptions import MinervaValidationError
227
+
228
+ if not path or not isinstance(path, str) or not path.startswith("/"):
229
+ raise MinervaValidationError(
230
+ f"path must be a non-empty string starting with '/', got: {path!r}"
231
+ )
232
+ kw: dict[str, Any] = {}
233
+ if params is not None:
234
+ kw["params"] = params
235
+ if json is not None:
236
+ kw["json"] = json
237
+ if headers:
238
+ kw["headers"] = headers
239
+ return self._client._request_data(method.upper(), path, **kw)
240
+
minerva/data/usage.py ADDED
@@ -0,0 +1,23 @@
1
+ """Usage tallies (data plane, x-api-key). ``client.usage.*``."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Any, Optional, Union
5
+
6
+ from . import _Resource
7
+ from .._serialize import as_format
8
+ from ..models import UsageResponse
9
+
10
+
11
+ class UsageResource(_Resource):
12
+ def tallies(
13
+ self,
14
+ *,
15
+ start: Optional[str] = None,
16
+ end: Optional[str] = None,
17
+ format: str = "models",
18
+ ) -> Union[UsageResponse, Any]:
19
+ """Your per-endpoint API usage — data plane, x-api-key (GET /usage)."""
20
+ params = {"start_date": start, "end_date": end}
21
+ params = {k: v for k, v in params.items() if v is not None}
22
+ data = self._client._request_data("GET", self._client._config.usage_path, params=params)
23
+ return as_format(UsageResponse.model_validate(data), format)
minerva/exceptions.py ADDED
@@ -0,0 +1,82 @@
1
+ """Errors raised by the Minerva SDK.
2
+
3
+ Every error inherits from :class:`MinervaError`, so a broad ``except
4
+ MinervaError`` catches anything the SDK raises. Subclasses let callers
5
+ branch on a specific failure mode.
6
+
7
+ Also defines :class:`MinervaWIPWarning` for marking forward-compat
8
+ surface that ships today but isn't fully wired up yet.
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import warnings
13
+ from typing import Any, Optional
14
+
15
+
16
+ class MinervaError(Exception):
17
+ """Base for everything this SDK raises."""
18
+
19
+
20
+ class MinervaConfigError(MinervaError):
21
+ """Misconfiguration (missing required setting, etc.)."""
22
+
23
+
24
+ class MinervaValidationError(MinervaError):
25
+ """Request failed local input validation — never sent."""
26
+
27
+
28
+ class MinervaAuthError(MinervaError):
29
+ """401 / 403 — bad or revoked API key, or not entitled to this endpoint."""
30
+
31
+
32
+ class MinervaRateLimitError(MinervaError):
33
+ """429.
34
+
35
+ Carries:
36
+ retry_after: seconds the server suggested waiting, if any.
37
+ """
38
+
39
+ def __init__(self, message: str, *, retry_after: Optional[float] = None) -> None:
40
+ super().__init__(message)
41
+ self.retry_after = retry_after
42
+
43
+
44
+ class MinervaAPIError(MinervaError):
45
+ """Any other non-2xx response.
46
+
47
+ Carries:
48
+ status_code: HTTP status.
49
+ api_request_id: server-side trace id — quote this when reporting.
50
+ body: parsed response body if available.
51
+ """
52
+
53
+ def __init__(
54
+ self,
55
+ message: str,
56
+ *,
57
+ status_code: Optional[int] = None,
58
+ api_request_id: Optional[str] = None,
59
+ body: Any = None,
60
+ ) -> None:
61
+ super().__init__(message)
62
+ self.status_code = status_code
63
+ self.api_request_id = api_request_id
64
+ self.body = body
65
+
66
+
67
+ # --------------------------------------------------------------------- warnings
68
+
69
+
70
+ class MinervaWIPWarning(UserWarning):
71
+ """Marks SDK surface that works but isn't fully GA yet.
72
+
73
+ Suppress wholesale if it's noisy::
74
+
75
+ import warnings
76
+ from minerva import MinervaWIPWarning
77
+ warnings.filterwarnings("ignore", category=MinervaWIPWarning)
78
+ """
79
+
80
+
81
+ def _wip(message: str, *, stacklevel: int = 3) -> None:
82
+ warnings.warn(message, MinervaWIPWarning, stacklevel=stacklevel)
minerva/models.py ADDED
@@ -0,0 +1,209 @@
1
+ """Pydantic models + enums.
2
+
3
+ Strict on input (``extra="forbid"`` on request models → typos rejected pre-flight),
4
+ lenient on output (``extra="allow"`` on response models → new server fields never break
5
+ an older client).
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from enum import Enum
10
+ from typing import Any, Optional
11
+
12
+ from pydantic import BaseModel, ConfigDict, Field
13
+
14
+ from ._serialize import TabularMixin
15
+
16
+
17
+ class _Out(BaseModel):
18
+ """Base for response models — forward-compatible."""
19
+
20
+ model_config = ConfigDict(extra="allow")
21
+
22
+
23
+ class _In(BaseModel):
24
+ """Base for request models — strict, so client mistakes fail fast."""
25
+
26
+ model_config = ConfigDict(extra="forbid")
27
+
28
+
29
+ # --------------------------------------------------------------------------- enums
30
+
31
+
32
+ class MatchConditionField(str, Enum):
33
+ """A field an enrich/resolve match can be required to contain (max 3 per request)."""
34
+
35
+ LINKEDIN_URL = "linkedin_url"
36
+ GENDER = "gender"
37
+ ESTIMATED_INCOME_RANGE = "estimated_income_range"
38
+ ESTIMATED_WEALTH_RANGE = "estimated_wealth_range"
39
+ EMAIL = "email"
40
+ PERSONAL_EMAIL = "personal_email"
41
+ PROFESSIONAL_EMAIL = "professional_email"
42
+ PHONE = "phone"
43
+ MOBILE_PHONE = "mobile_phone"
44
+ HOME_OWNERSHIP_STATUS = "home_ownership_status"
45
+
46
+
47
+ # --------------------------------------------------------------------------- enrich
48
+
49
+
50
+ class EnrichRecord(_In):
51
+ """One person record to enrich or resolve.
52
+
53
+ ``record_id`` is echoed back on the matching result. Provide a direct key
54
+ (``minerva_pid`` or ``linkedin_url``) for a direct lookup, or name + PII
55
+ (``emails`` / ``phones``) for fuzzy matching.
56
+ """
57
+
58
+ record_id: str
59
+ minerva_pid: Optional[str] = None
60
+ linkedin_url: Optional[str] = None
61
+ first_name: Optional[str] = None
62
+ last_name: Optional[str] = None
63
+ full_name: Optional[str] = None
64
+ middle_name: Optional[str] = None
65
+ name_suffix: Optional[str] = None
66
+ emails: Optional[list[str]] = None
67
+ phones: Optional[list[str]] = None
68
+
69
+
70
+ class EnrichRequest(_In):
71
+ """Validated body for ``POST /v{1,2}/enrich``.
72
+
73
+ Attributes:
74
+ records: 1–500 records to enrich.
75
+ match_condition_fields: Up to 3 fields a match must contain to be returned.
76
+ return_fields: Optional allow-list of fields to return beyond the base set.
77
+ """
78
+
79
+ records: list[EnrichRecord] = Field(min_length=1, max_length=500)
80
+ match_condition_fields: Optional[list[MatchConditionField]] = Field(
81
+ default=None, max_length=3
82
+ )
83
+ return_fields: Optional[list[str]] = None
84
+
85
+
86
+ class EnrichResult(_Out):
87
+ record_id: str
88
+ is_match: bool = False
89
+ minerva_pid: Optional[str] = None
90
+ match_score: Optional[float] = None
91
+ validation_errors: Optional[dict[str, Any]] = None
92
+ personal_information: Optional[dict[str, Any]] = None
93
+ household_information: Optional[dict[str, Any]] = None
94
+ financial_information: Optional[dict[str, Any]] = None
95
+ social_media: Optional[dict[str, Any]] = None
96
+ personal_emails: Optional[list[dict[str, Any]]] = None
97
+ professional_emails: Optional[list[dict[str, Any]]] = None
98
+ phones: Optional[list[dict[str, Any]]] = None
99
+ address_history: Optional[list[dict[str, Any]]] = None
100
+ work_experience: Optional[list[dict[str, Any]]] = None
101
+ education_experience: Optional[list[dict[str, Any]]] = None
102
+ relatives: Optional[list[dict[str, Any]]] = None
103
+
104
+
105
+ _FLATTEN = (
106
+ "personal_information",
107
+ "household_information",
108
+ "financial_information",
109
+ "social_media",
110
+ )
111
+
112
+
113
+ class EnrichResponse(_Out, TabularMixin):
114
+ """Response from ``POST /v{1,2}/enrich``.
115
+
116
+ Supports :meth:`to_df`, :meth:`to_csv`, :meth:`to_dicts`, :meth:`to_table`; the
117
+ tabular views flatten each result's ``*_information`` sections into row columns.
118
+ """
119
+
120
+ api_request_id: Optional[str] = None
121
+ request_completed_at: Optional[str] = None
122
+ results: list[EnrichResult] = Field(default_factory=list)
123
+
124
+ def _tabular_rows(self) -> list[dict[str, Any]]:
125
+ rows = []
126
+ for result in self.results:
127
+ row = result.model_dump(mode="json")
128
+ for section in _FLATTEN:
129
+ nested = row.pop(section, None)
130
+ if isinstance(nested, dict):
131
+ row.update(nested)
132
+ rows.append(row)
133
+ return rows
134
+
135
+
136
+ # -------------------------------------------------------------------------- resolve
137
+
138
+
139
+ class ResolveRequest(_In):
140
+ records: list[EnrichRecord] = Field(min_length=1, max_length=500)
141
+ # resolve permits linkedin_url / minerva_pid / etc. — free strings (max 3), not the
142
+ # enrich enum (which omits minerva_pid).
143
+ match_condition_fields: Optional[list[str]] = Field(default=None, max_length=3)
144
+
145
+
146
+ class ResolveResult(_Out):
147
+ record_id: Optional[str] = None
148
+ is_match: bool = False
149
+ minerva_pid: Optional[str] = None
150
+ match_score: Optional[float] = None
151
+ validation_errors: Optional[dict[str, Any]] = None
152
+
153
+
154
+ class ResolveResponse(_Out, TabularMixin):
155
+ """Response from ``POST /v{1,2}/resolve`` — one match verdict per input record."""
156
+
157
+ api_request_id: Optional[str] = None
158
+ request_completed_at: Optional[str] = None
159
+ results: list[ResolveResult] = Field(default_factory=list)
160
+
161
+ def _tabular_rows(self) -> list[dict[str, Any]]:
162
+ return [r.model_dump(mode="json") for r in self.results]
163
+
164
+
165
+ # -------------------------------------------------------- li / validate / infer
166
+
167
+
168
+ class LiContactInfoRequest(_In):
169
+ """Request for ``get_li_contact_info`` — a list of LinkedIn member-id strings.
170
+
171
+ Attributes:
172
+ records: LinkedIn member ids (e.g. ``"1000000001"``). 1–500 entries.
173
+ presence_only: v2 — return only whether contact info exists, not the values.
174
+ """
175
+
176
+ records: list[str] = Field(min_length=1, max_length=500)
177
+ presence_only: bool = False
178
+
179
+
180
+ class ValidateEmailsRequest(_In):
181
+ """Request for ``validate_emails`` — a list of email-address strings (1–500)."""
182
+
183
+ records: list[str] = Field(min_length=1, max_length=500)
184
+
185
+
186
+ class InferCountryRequest(_In):
187
+ """Request for ``infer_record_country`` — person records to infer a country for.
188
+
189
+ Attributes:
190
+ records: Record objects (each with ``record_id`` + any of emails / phones / name).
191
+ 1–500 entries.
192
+ """
193
+
194
+ records: list[dict[str, Any]] = Field(min_length=1, max_length=500)
195
+
196
+
197
+ # -------------------------------------------------------------------------- usage
198
+
199
+
200
+ class UsageResponse(_Out, TabularMixin):
201
+ """Per-endpoint usage. Shape is server-defined; we surface whatever list is present."""
202
+
203
+ def _tabular_rows(self) -> list[dict[str, Any]]:
204
+ dump = self.model_dump(mode="json")
205
+ for key in ("results", "usage", "data", "endpoints"):
206
+ value = dump.get(key)
207
+ if isinstance(value, list):
208
+ return [v if isinstance(v, dict) else {"value": v} for v in value]
209
+ return [dump]
minerva/py.typed ADDED
File without changes
@@ -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
+ ![Python](https://img.shields.io/badge/python-3.11%E2%80%933.14-blue)
40
+ ![Types](https://img.shields.io/badge/typed-pydantic%20v2-blue)
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,17 @@
1
+ minerva/__init__.py,sha256=ZGR2PaRyRG7exFGJLayuZ0sdFWKJwpv-Ch-NGnyGezg,1587
2
+ minerva/__main__.py,sha256=4lMeqiVapH2Ip0naZZPSwpy27LafZOc-WwbenY5E-8w,2300
3
+ minerva/_banner.py,sha256=htqBmwBj5IggcIUlTkGfFz93an3UEvebzOCYziJH8bo,1946
4
+ minerva/_http.py,sha256=OwtU9HEuJkKTMOqs8cj-m2KZWZM6CP9vJSvp2bmRIJc,2278
5
+ minerva/_serialize.py,sha256=jvK_Kg6ix4kbpNeWEgREMAOQ_KVtrBTN4GBhAohAUsg,2542
6
+ minerva/client.py,sha256=BgQFKmSPaMBYzfZmQ4QPEqcy9S2O1YWdOz3tx5Bsqis,4060
7
+ minerva/config.py,sha256=OreKPhAp15eHjGiRoNC7W7Nr4RVrpR6Owi1yL-XJHzs,227
8
+ minerva/exceptions.py,sha256=ye3sYWQV-2Fbuw8kY8iuLFLbZhdkqDr2N2OmGAjp1oc,2239
9
+ minerva/models.py,sha256=xghJNznigZHexnOiS_zcU3bMcai60wnObnZXgudIHIY,6922
10
+ minerva/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ minerva/data/__init__.py,sha256=ghz-B6RjeXtdh09hzoggdvCpF6wg0KsInUcUMOuAaK8,1763
12
+ minerva/data/api.py,sha256=1oxqVMaPIPeU4eWIHUjgOHrSCIoHqA5VoatqSB18glM,9701
13
+ minerva/data/usage.py,sha256=8XsfBzQ6xbJOBEDzFV1h868p1MuqzjYvG1IYnNVzhrM,824
14
+ minerva_sdk-0.0.3.dist-info/METADATA,sha256=f_t59lzB68Q9EeObaxLChkgzro72FSg6RH5U6AF2lIM,6077
15
+ minerva_sdk-0.0.3.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
16
+ minerva_sdk-0.0.3.dist-info/licenses/LICENSE,sha256=YP24RoWig_0903o46aiNuXmDB27JPeuw93IKlOj21iM,1069
17
+ minerva_sdk-0.0.3.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -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.