oxint 1.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.
- oxint-1.0.0/PKG-INFO +30 -0
- oxint-1.0.0/README.md +23 -0
- oxint-1.0.0/oxint/__init__.py +47 -0
- oxint-1.0.0/oxint.egg-info/PKG-INFO +30 -0
- oxint-1.0.0/oxint.egg-info/SOURCES.txt +8 -0
- oxint-1.0.0/oxint.egg-info/dependency_links.txt +1 -0
- oxint-1.0.0/oxint.egg-info/top_level.txt +2 -0
- oxint-1.0.0/pyproject.toml +11 -0
- oxint-1.0.0/setup.cfg +4 -0
- oxint-1.0.0/tests/test_client.py +32 -0
oxint-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: oxint
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: OXINT API v1 Python client
|
|
5
|
+
Requires-Python: >=3.9
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# OXINT Python SDK
|
|
9
|
+
|
|
10
|
+
A Python client for the OXINT API v1. Requires Python 3.9 or later.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
pip install oxint
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
import os
|
|
18
|
+
from oxint import Oxint
|
|
19
|
+
|
|
20
|
+
client = Oxint(os.environ['OXINT_API_KEY'])
|
|
21
|
+
print(client.account())
|
|
22
|
+
print(client.enrich({'type': 'ssl', 'value': 'example.org'}))
|
|
23
|
+
print(client.tools({'action': 'address', 'country': 'IN', 'count': 1}))
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The default API base is `https://oxint.vercel.app/api/v1`; specify `base_url` if your OXINT deployment uses a different URL. The SSL and expanded address features require an OXINT server version that supports them.
|
|
27
|
+
|
|
28
|
+
Available methods: `account`, `health`, `usage`, `estimate`, `search`, `enrich`, and `tools`. Billable calls accept an optional idempotency key. The SDK does not automatically retry. Keep your API key secret. Live search, enrichment and tool calls may incur charges; check your key's pricing and limits before sending requests. Synthetic addresses are testing fixtures, not verified delivery addresses.
|
|
29
|
+
|
|
30
|
+
[OXINT API documentation](https://oxint.vercel.app/api-docs)
|
oxint-1.0.0/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# OXINT Python SDK
|
|
2
|
+
|
|
3
|
+
A Python client for the OXINT API v1. Requires Python 3.9 or later.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pip install oxint
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
import os
|
|
11
|
+
from oxint import Oxint
|
|
12
|
+
|
|
13
|
+
client = Oxint(os.environ['OXINT_API_KEY'])
|
|
14
|
+
print(client.account())
|
|
15
|
+
print(client.enrich({'type': 'ssl', 'value': 'example.org'}))
|
|
16
|
+
print(client.tools({'action': 'address', 'country': 'IN', 'count': 1}))
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The default API base is `https://oxint.vercel.app/api/v1`; specify `base_url` if your OXINT deployment uses a different URL. The SSL and expanded address features require an OXINT server version that supports them.
|
|
20
|
+
|
|
21
|
+
Available methods: `account`, `health`, `usage`, `estimate`, `search`, `enrich`, and `tools`. Billable calls accept an optional idempotency key. The SDK does not automatically retry. Keep your API key secret. Live search, enrichment and tool calls may incur charges; check your key's pricing and limits before sending requests. Synthetic addresses are testing fixtures, not verified delivery addresses.
|
|
22
|
+
|
|
23
|
+
[OXINT API documentation](https://oxint.vercel.app/api-docs)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""OXINT API v1 client. All API keys must be stored securely."""
|
|
2
|
+
import json
|
|
3
|
+
from urllib.error import HTTPError, URLError
|
|
4
|
+
from urllib.parse import urlencode, urlsplit
|
|
5
|
+
from urllib.request import Request, build_opener, HTTPRedirectHandler
|
|
6
|
+
|
|
7
|
+
class _NoRedirect(HTTPRedirectHandler):
|
|
8
|
+
def redirect_request(self, req, fp, code, msg, headers, newurl): return None
|
|
9
|
+
|
|
10
|
+
class OxintError(Exception):
|
|
11
|
+
def __init__(self, message, status=None, code=None, request_id=None):
|
|
12
|
+
super().__init__(message)
|
|
13
|
+
self.status, self.code, self.request_id = status, code, request_id
|
|
14
|
+
|
|
15
|
+
class Oxint:
|
|
16
|
+
def __init__(self, api_key, base_url="https://oxint.vercel.app/api/v1", timeout=65):
|
|
17
|
+
if not api_key or not isinstance(api_key, str):
|
|
18
|
+
raise ValueError("An API key is required")
|
|
19
|
+
parts = urlsplit(base_url)
|
|
20
|
+
if parts.scheme != "https" and not (parts.scheme == "http" and parts.hostname in ("localhost", "127.0.0.1", "::1")):
|
|
21
|
+
raise ValueError("Use HTTPS, except for a local test server")
|
|
22
|
+
if not parts.hostname or parts.username or parts.password or parts.query or parts.fragment:
|
|
23
|
+
raise ValueError("Invalid API base URL")
|
|
24
|
+
self._key, self.base_url, self.timeout = api_key, base_url.rstrip("/"), timeout
|
|
25
|
+
|
|
26
|
+
def _request(self, endpoint, body=None, params=None, idempotency_key=None):
|
|
27
|
+
url = self.base_url + "/" + endpoint + ("?" + urlencode(params) if params else "")
|
|
28
|
+
headers = {"Authorization": "Bearer " + self._key, "Accept": "application/json"}
|
|
29
|
+
payload = None if body is None else json.dumps(body).encode("utf-8")
|
|
30
|
+
if payload is not None: headers["Content-Type"] = "application/json"
|
|
31
|
+
if idempotency_key: headers["Idempotency-Key"] = idempotency_key
|
|
32
|
+
req = Request(url, data=payload, headers=headers)
|
|
33
|
+
try:
|
|
34
|
+
with build_opener(_NoRedirect).open(req, timeout=self.timeout) as response: return json.loads(response.read())
|
|
35
|
+
except HTTPError as exc:
|
|
36
|
+
try: details = json.loads(exc.read())
|
|
37
|
+
except Exception: details = {}
|
|
38
|
+
raise OxintError(details.get("error", "OXINT request failed"), exc.code, details.get("code"), details.get("requestId")) from None
|
|
39
|
+
except (URLError, TimeoutError, OSError, ValueError) as exc:
|
|
40
|
+
raise OxintError("Could not read an OXINT response") from None
|
|
41
|
+
def account(self): return self._request("account")
|
|
42
|
+
def health(self): return self._request("health")
|
|
43
|
+
def usage(self, limit=25, cursor=None): return self._request("usage", params={k:v for k,v in {"limit":limit,"cursor":cursor}.items() if v is not None})
|
|
44
|
+
def estimate(self, payload): return self._request("estimate", body=payload)
|
|
45
|
+
def search(self, payload, idempotency_key=None): return self._request("search", body=payload, idempotency_key=idempotency_key)
|
|
46
|
+
def enrich(self, payload, idempotency_key=None): return self._request("enrich", body=payload, idempotency_key=idempotency_key)
|
|
47
|
+
def tools(self, payload, idempotency_key=None): return self._request("tools", body=payload, idempotency_key=idempotency_key)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: oxint
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: OXINT API v1 Python client
|
|
5
|
+
Requires-Python: >=3.9
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# OXINT Python SDK
|
|
9
|
+
|
|
10
|
+
A Python client for the OXINT API v1. Requires Python 3.9 or later.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
pip install oxint
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
import os
|
|
18
|
+
from oxint import Oxint
|
|
19
|
+
|
|
20
|
+
client = Oxint(os.environ['OXINT_API_KEY'])
|
|
21
|
+
print(client.account())
|
|
22
|
+
print(client.enrich({'type': 'ssl', 'value': 'example.org'}))
|
|
23
|
+
print(client.tools({'action': 'address', 'country': 'IN', 'count': 1}))
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The default API base is `https://oxint.vercel.app/api/v1`; specify `base_url` if your OXINT deployment uses a different URL. The SSL and expanded address features require an OXINT server version that supports them.
|
|
27
|
+
|
|
28
|
+
Available methods: `account`, `health`, `usage`, `estimate`, `search`, `enrich`, and `tools`. Billable calls accept an optional idempotency key. The SDK does not automatically retry. Keep your API key secret. Live search, enrichment and tool calls may incur charges; check your key's pricing and limits before sending requests. Synthetic addresses are testing fixtures, not verified delivery addresses.
|
|
29
|
+
|
|
30
|
+
[OXINT API documentation](https://oxint.vercel.app/api-docs)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
[project]
|
|
5
|
+
name = "oxint"
|
|
6
|
+
version = "1.0.0"
|
|
7
|
+
description = "OXINT API v1 Python client"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.9"
|
|
10
|
+
[tool.setuptools.packages.find]
|
|
11
|
+
where = ["."]
|
oxint-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import threading
|
|
3
|
+
import unittest
|
|
4
|
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
5
|
+
from oxint import Oxint, OxintError
|
|
6
|
+
|
|
7
|
+
seen = []
|
|
8
|
+
class Handler(BaseHTTPRequestHandler):
|
|
9
|
+
def log_message(self, *args): pass
|
|
10
|
+
def handle_request(self):
|
|
11
|
+
body = self.rfile.read(int(self.headers.get('Content-Length', '0')))
|
|
12
|
+
seen.append((self.path, self.headers.get('Authorization'), self.headers.get('Idempotency-Key'), json.loads(body) if body else None))
|
|
13
|
+
status = 401 if self.path == '/v1/health' else 200
|
|
14
|
+
data = {'ok': True} if status == 200 else {'error': 'Invalid key', 'code': 'INVALID_API_KEY'}
|
|
15
|
+
encoded = json.dumps(data).encode(); self.send_response(status); self.send_header('Content-Length', str(len(encoded))); self.end_headers(); self.wfile.write(encoded)
|
|
16
|
+
do_GET = handle_request
|
|
17
|
+
do_POST = handle_request
|
|
18
|
+
class ClientTest(unittest.TestCase):
|
|
19
|
+
def test_api(self):
|
|
20
|
+
server = ThreadingHTTPServer(('127.0.0.1', 0), Handler)
|
|
21
|
+
thread = threading.Thread(target=server.serve_forever, daemon=True); thread.start()
|
|
22
|
+
try:
|
|
23
|
+
c = Oxint('mock-key', f'http://127.0.0.1:{server.server_port}/v1')
|
|
24
|
+
c.account()
|
|
25
|
+
with self.assertRaises(OxintError) as error: c.health()
|
|
26
|
+
self.assertEqual(error.exception.status, 401)
|
|
27
|
+
c.usage(10, 'next'); c.estimate({'query': 'sample'}); c.search({'query': 'sample'}, 'idem-1'); c.enrich({'type': 'ssl', 'value': 'example.org'}); c.tools({'action': 'address', 'country': 'IN'})
|
|
28
|
+
self.assertEqual(seen[4][2], 'idem-1')
|
|
29
|
+
self.assertTrue(all(row[1] == 'Bearer mock-key' for row in seen))
|
|
30
|
+
with self.assertRaises(ValueError): Oxint('mock-key', 'http://example.org/v1')
|
|
31
|
+
finally: server.shutdown(); server.server_close()
|
|
32
|
+
if __name__ == '__main__': unittest.main()
|