trustregistry 0.1.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.
- trustregistry-0.1.0/PKG-INFO +28 -0
- trustregistry-0.1.0/README.md +21 -0
- trustregistry-0.1.0/pyproject.toml +13 -0
- trustregistry-0.1.0/setup.cfg +4 -0
- trustregistry-0.1.0/src/trustregistry/__init__.py +4 -0
- trustregistry-0.1.0/src/trustregistry/client.py +84 -0
- trustregistry-0.1.0/src/trustregistry.egg-info/PKG-INFO +28 -0
- trustregistry-0.1.0/src/trustregistry.egg-info/SOURCES.txt +8 -0
- trustregistry-0.1.0/src/trustregistry.egg-info/dependency_links.txt +1 -0
- trustregistry-0.1.0/src/trustregistry.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: trustregistry
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: TrustRegistry Business Verification API client
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# TrustRegistry Python SDK
|
|
9
|
+
|
|
10
|
+
Internal release candidate for Python 3.10+ with no runtime dependencies. It supports Texas Business Verification via `POST /api/v1/verify`.
|
|
11
|
+
|
|
12
|
+
To install the local package candidate from this directory, run `python -m pip install .`.
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
import os
|
|
16
|
+
from trustregistry import TrustRegistry
|
|
17
|
+
|
|
18
|
+
client = TrustRegistry(
|
|
19
|
+
api_key=os.environ["TR_API_KEY"],
|
|
20
|
+
base_url=os.environ["TR_API_BASE_URL"],
|
|
21
|
+
)
|
|
22
|
+
result = client.verify_business("Example LLC", jurisdiction="TX", limit=5)
|
|
23
|
+
print(result["count"], result["request_id"])
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Use the authorized deployment origin and keep API keys in server-side secrets. An empty results list is a successful no-match. API errors surface as `TrustRegistryError` with status, code and request ID. Network errors propagate to the caller. The client does not follow redirects or automatically retry requests.
|
|
27
|
+
|
|
28
|
+
SDK installation will be free. Your TrustRegistry plan governs API feature access and usage. The release still requires an authenticated environment check, usage-ledger reconciliation, and verified control of the package name. This candidate has not been published to PyPI.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# TrustRegistry Python SDK
|
|
2
|
+
|
|
3
|
+
Internal release candidate for Python 3.10+ with no runtime dependencies. It supports Texas Business Verification via `POST /api/v1/verify`.
|
|
4
|
+
|
|
5
|
+
To install the local package candidate from this directory, run `python -m pip install .`.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
import os
|
|
9
|
+
from trustregistry import TrustRegistry
|
|
10
|
+
|
|
11
|
+
client = TrustRegistry(
|
|
12
|
+
api_key=os.environ["TR_API_KEY"],
|
|
13
|
+
base_url=os.environ["TR_API_BASE_URL"],
|
|
14
|
+
)
|
|
15
|
+
result = client.verify_business("Example LLC", jurisdiction="TX", limit=5)
|
|
16
|
+
print(result["count"], result["request_id"])
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Use the authorized deployment origin and keep API keys in server-side secrets. An empty results list is a successful no-match. API errors surface as `TrustRegistryError` with status, code and request ID. Network errors propagate to the caller. The client does not follow redirects or automatically retry requests.
|
|
20
|
+
|
|
21
|
+
SDK installation will be free. Your TrustRegistry plan governs API feature access and usage. The release still requires an authenticated environment check, usage-ledger reconciliation, and verified control of the package name. This candidate has not been published to PyPI.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "trustregistry"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "TrustRegistry Business Verification API client"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
|
|
12
|
+
[tool.setuptools.packages.find]
|
|
13
|
+
where = ["src"]
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""Client for POST /api/v1/verify."""
|
|
2
|
+
import json
|
|
3
|
+
import math
|
|
4
|
+
from urllib.error import HTTPError
|
|
5
|
+
from urllib.parse import urlsplit
|
|
6
|
+
from urllib.request import HTTPRedirectHandler, Request, build_opener
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TrustRegistryError(Exception):
|
|
10
|
+
def __init__(self, status: int, code: str, message: str, request_id: str | None):
|
|
11
|
+
super().__init__(message)
|
|
12
|
+
self.status = status
|
|
13
|
+
self.code = code
|
|
14
|
+
self.request_id = request_id
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class _RejectRedirects(HTTPRedirectHandler):
|
|
18
|
+
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
|
19
|
+
return None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _read_json(response):
|
|
23
|
+
try:
|
|
24
|
+
value = json.load(response)
|
|
25
|
+
except (ValueError, UnicodeError):
|
|
26
|
+
return {}
|
|
27
|
+
return value if isinstance(value, dict) else {}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class TrustRegistry:
|
|
31
|
+
def __init__(self, *, api_key: str, base_url: str, timeout: float = 15):
|
|
32
|
+
if not api_key or not api_key.strip():
|
|
33
|
+
raise ValueError("A TrustRegistry API key is required.")
|
|
34
|
+
if not math.isfinite(timeout) or timeout <= 0:
|
|
35
|
+
raise ValueError("Timeout must be positive and finite.")
|
|
36
|
+
origin = urlsplit(base_url)
|
|
37
|
+
if origin.scheme != "https" or not origin.hostname or origin.username is not None:
|
|
38
|
+
raise ValueError("Use a trusted HTTPS API base URL.")
|
|
39
|
+
self._endpoint = f"https://{origin.netloc}/api/v1/verify"
|
|
40
|
+
self._key = api_key.strip()
|
|
41
|
+
self._timeout = timeout
|
|
42
|
+
self._opener = build_opener(_RejectRedirects())
|
|
43
|
+
|
|
44
|
+
def verify_business(
|
|
45
|
+
self, query: str, *, jurisdiction: str | None = None, limit: int | None = None
|
|
46
|
+
) -> dict:
|
|
47
|
+
payload = {"query": query}
|
|
48
|
+
if jurisdiction is not None:
|
|
49
|
+
payload["jurisdiction"] = jurisdiction
|
|
50
|
+
if limit is not None:
|
|
51
|
+
payload["limit"] = limit
|
|
52
|
+
request = Request(
|
|
53
|
+
self._endpoint,
|
|
54
|
+
data=json.dumps(payload).encode("utf-8"),
|
|
55
|
+
headers={
|
|
56
|
+
"Authorization": f"Bearer {self._key}",
|
|
57
|
+
"Content-Type": "application/json",
|
|
58
|
+
"Accept": "application/json",
|
|
59
|
+
},
|
|
60
|
+
method="POST",
|
|
61
|
+
)
|
|
62
|
+
try:
|
|
63
|
+
with self._opener.open(request, timeout=self._timeout) as response:
|
|
64
|
+
data = _read_json(response)
|
|
65
|
+
status = response.status
|
|
66
|
+
request_id = response.headers.get("x-request-id")
|
|
67
|
+
except HTTPError as exc:
|
|
68
|
+
with exc:
|
|
69
|
+
data = _read_json(exc)
|
|
70
|
+
error = data.get("error")
|
|
71
|
+
error = error if isinstance(error, dict) else {}
|
|
72
|
+
raise TrustRegistryError(
|
|
73
|
+
exc.code,
|
|
74
|
+
error.get("code") or "HTTP_ERROR",
|
|
75
|
+
error.get("message") or "Business verification failed.",
|
|
76
|
+
data.get("request_id") or exc.headers.get("x-request-id"),
|
|
77
|
+
) from None
|
|
78
|
+
|
|
79
|
+
if data.get("object") != "verification.search" or not isinstance(data.get("results"), list):
|
|
80
|
+
raise TrustRegistryError(
|
|
81
|
+
status, "INVALID_RESPONSE",
|
|
82
|
+
"The API returned an unexpected business verification response.", request_id,
|
|
83
|
+
)
|
|
84
|
+
return data
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: trustregistry
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: TrustRegistry Business Verification API client
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# TrustRegistry Python SDK
|
|
9
|
+
|
|
10
|
+
Internal release candidate for Python 3.10+ with no runtime dependencies. It supports Texas Business Verification via `POST /api/v1/verify`.
|
|
11
|
+
|
|
12
|
+
To install the local package candidate from this directory, run `python -m pip install .`.
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
import os
|
|
16
|
+
from trustregistry import TrustRegistry
|
|
17
|
+
|
|
18
|
+
client = TrustRegistry(
|
|
19
|
+
api_key=os.environ["TR_API_KEY"],
|
|
20
|
+
base_url=os.environ["TR_API_BASE_URL"],
|
|
21
|
+
)
|
|
22
|
+
result = client.verify_business("Example LLC", jurisdiction="TX", limit=5)
|
|
23
|
+
print(result["count"], result["request_id"])
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Use the authorized deployment origin and keep API keys in server-side secrets. An empty results list is a successful no-match. API errors surface as `TrustRegistryError` with status, code and request ID. Network errors propagate to the caller. The client does not follow redirects or automatically retry requests.
|
|
27
|
+
|
|
28
|
+
SDK installation will be free. Your TrustRegistry plan governs API feature access and usage. The release still requires an authenticated environment check, usage-ledger reconciliation, and verified control of the package name. This candidate has not been published to PyPI.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
trustregistry
|