osintverse 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.
- osintverse-0.1.0/.github/workflows/ci.yml +24 -0
- osintverse-0.1.0/.github/workflows/publish.yml +25 -0
- osintverse-0.1.0/.gitignore +14 -0
- osintverse-0.1.0/LICENSE +21 -0
- osintverse-0.1.0/PKG-INFO +134 -0
- osintverse-0.1.0/README.md +102 -0
- osintverse-0.1.0/pyproject.toml +59 -0
- osintverse-0.1.0/src/osintverse/__init__.py +57 -0
- osintverse-0.1.0/src/osintverse/_async_client.py +90 -0
- osintverse-0.1.0/src/osintverse/_async_search.py +150 -0
- osintverse-0.1.0/src/osintverse/_client.py +98 -0
- osintverse-0.1.0/src/osintverse/_constants.py +9 -0
- osintverse-0.1.0/src/osintverse/_exceptions.py +67 -0
- osintverse-0.1.0/src/osintverse/_http.py +71 -0
- osintverse-0.1.0/src/osintverse/_models.py +104 -0
- osintverse-0.1.0/src/osintverse/_search.py +170 -0
- osintverse-0.1.0/src/osintverse/py.typed +0 -0
- osintverse-0.1.0/tests/__init__.py +0 -0
- osintverse-0.1.0/tests/fixtures.py +61 -0
- osintverse-0.1.0/tests/test_async_client.py +88 -0
- osintverse-0.1.0/tests/test_client.py +253 -0
- osintverse-0.1.0/uv.lock +450 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python-version }}
|
|
19
|
+
- name: Install
|
|
20
|
+
run: pip install -e ".[dev]"
|
|
21
|
+
- name: Lint
|
|
22
|
+
run: ruff check src tests
|
|
23
|
+
- name: Test
|
|
24
|
+
run: pytest
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
pypi:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.12"
|
|
20
|
+
- name: Build
|
|
21
|
+
run: |
|
|
22
|
+
pip install build
|
|
23
|
+
python -m build
|
|
24
|
+
- name: Publish to PyPI
|
|
25
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
osintverse-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OSINTverse
|
|
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,134 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: osintverse
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python client for the OSINTverse SearchIn API
|
|
5
|
+
Project-URL: Homepage, https://osintverse.com
|
|
6
|
+
Project-URL: Documentation, https://osintverse.com/docs/python
|
|
7
|
+
Project-URL: Repository, https://github.com/dheerajydv19/osintverse-pythonsdk
|
|
8
|
+
Project-URL: Issues, https://github.com/dheerajydv19/osintverse-pythonsdk/issues
|
|
9
|
+
Author-email: OSINTverse <hi@osintverse.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: api,osint,osintverse,searchin
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: httpx>=0.27.0
|
|
25
|
+
Requires-Dist: pydantic>=2.0.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: respx>=0.22.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.8.0; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# Official Python client for the OSINTverse SearchIn API (osintverse.com).
|
|
34
|
+
|
|
35
|
+
This is the **official** client for [OSINTverse](https://osintverse.com) SearchIn: one REST API for LeakRadar, OSINT Industries, Facecheck.id, SecurityTrails, and every other SearchIn provider.
|
|
36
|
+
|
|
37
|
+
It talks to **`https://apiv1.osintverse.com`**. It is not affiliated with other products that reuse the OSINTverse name.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install osintverse
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Create an API key at [Dashboard → API keys](https://osintverse.com/dashboard/api). Keys use the `ov_` prefix and are shown only once.
|
|
46
|
+
|
|
47
|
+
## Quick start
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from osintverse import OSINTverse
|
|
51
|
+
|
|
52
|
+
client = OSINTverse() # reads OSINTVERSE_API_KEY, or pass api_key="ov_…"
|
|
53
|
+
|
|
54
|
+
providers = client.providers.list()
|
|
55
|
+
search = client.search.create(
|
|
56
|
+
provider="leakradar-lite",
|
|
57
|
+
input_type="email",
|
|
58
|
+
query="user@example.com",
|
|
59
|
+
wait=True, # poll GET /v1/search/{id} every ~2s when status is running
|
|
60
|
+
)
|
|
61
|
+
print(search.status, search.cost_usd, len(search.result.matches if search.result else []))
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Async:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from osintverse import AsyncOSINTverse
|
|
68
|
+
|
|
69
|
+
async with AsyncOSINTverse() as client:
|
|
70
|
+
search = await client.search.create(
|
|
71
|
+
provider="leakradar-lite",
|
|
72
|
+
input_type="email",
|
|
73
|
+
query="user@example.com",
|
|
74
|
+
wait=True,
|
|
75
|
+
)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Auth
|
|
79
|
+
|
|
80
|
+
- Header: `x-api-key` (the SDK sets this for you)
|
|
81
|
+
- Env: `OSINTVERSE_API_KEY`
|
|
82
|
+
- Docs: [https://osintverse.com/docs/python](https://osintverse.com/docs/python)
|
|
83
|
+
|
|
84
|
+
`GET /health` and `GET /v1/providers` do not require a key. Search routes do.
|
|
85
|
+
|
|
86
|
+
## Methods
|
|
87
|
+
|
|
88
|
+
| SDK | HTTP |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| `client.health()` | `GET /health` |
|
|
91
|
+
| `client.providers.list()` | `GET /v1/providers` |
|
|
92
|
+
| `client.search.create(...)` | `POST /v1/search` |
|
|
93
|
+
| `client.search.bulk(...)` | `POST /v1/search/bulk` |
|
|
94
|
+
| `client.search.retrieve(id)` | `GET /v1/search/{id}` |
|
|
95
|
+
| `client.search.unlock(id)` | `POST /v1/search/{id}/unlock` |
|
|
96
|
+
| `client.search.premium(id)` | `POST /v1/search/{id}/premium` |
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
batch = client.search.bulk(
|
|
100
|
+
input_type="email",
|
|
101
|
+
queries=["alice@example.com", "bob@example.com"],
|
|
102
|
+
providers=["leakradar-lite", "dehashed"],
|
|
103
|
+
wait=True,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
client.search.unlock(search.id) # LeakRadar leftover credentials
|
|
107
|
+
client.search.premium(search.id) # OSINT Industries premium modules
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`wait=True` on **create** raises `SearchFailedError` / `SearchRefundedError` if the job ends in `failed` or `refunded`. Bulk wait polls running jobs and returns the batch — inspect `summary` for partial success.
|
|
111
|
+
|
|
112
|
+
## Errors
|
|
113
|
+
|
|
114
|
+
HTTP `{ "detail": "…" }` maps to `AuthenticationError` (401), `PaymentRequiredError` (402), `ForbiddenError` (403), `NotFoundError` (404), `ValidationError` (422), and `APIError` (5xx).
|
|
115
|
+
|
|
116
|
+
## Development
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pip install -e ".[dev]"
|
|
120
|
+
pytest
|
|
121
|
+
ruff check src tests
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
MIT
|
|
127
|
+
|
|
128
|
+
## Publishing
|
|
129
|
+
|
|
130
|
+
CI runs lint and tests on every push. PyPI publishes from `.github/workflows/publish.yml` on `v*` tags using [Trusted Publishing](https://docs.pypi.org/trusted-publishers/).
|
|
131
|
+
|
|
132
|
+
1. On PyPI, add a pending trusted publisher for project **osintverse**: GitHub owner `dheerajydv19`, repo `osintverse-pythonsdk`, workflow `publish.yml`, environment blank.
|
|
133
|
+
2. Tag a release: `git tag v0.1.0 && git push origin v0.1.0`.
|
|
134
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Official Python client for the OSINTverse SearchIn API (osintverse.com).
|
|
2
|
+
|
|
3
|
+
This is the **official** client for [OSINTverse](https://osintverse.com) SearchIn: one REST API for LeakRadar, OSINT Industries, Facecheck.id, SecurityTrails, and every other SearchIn provider.
|
|
4
|
+
|
|
5
|
+
It talks to **`https://apiv1.osintverse.com`**. It is not affiliated with other products that reuse the OSINTverse name.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install osintverse
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Create an API key at [Dashboard → API keys](https://osintverse.com/dashboard/api). Keys use the `ov_` prefix and are shown only once.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from osintverse import OSINTverse
|
|
19
|
+
|
|
20
|
+
client = OSINTverse() # reads OSINTVERSE_API_KEY, or pass api_key="ov_…"
|
|
21
|
+
|
|
22
|
+
providers = client.providers.list()
|
|
23
|
+
search = client.search.create(
|
|
24
|
+
provider="leakradar-lite",
|
|
25
|
+
input_type="email",
|
|
26
|
+
query="user@example.com",
|
|
27
|
+
wait=True, # poll GET /v1/search/{id} every ~2s when status is running
|
|
28
|
+
)
|
|
29
|
+
print(search.status, search.cost_usd, len(search.result.matches if search.result else []))
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Async:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from osintverse import AsyncOSINTverse
|
|
36
|
+
|
|
37
|
+
async with AsyncOSINTverse() as client:
|
|
38
|
+
search = await client.search.create(
|
|
39
|
+
provider="leakradar-lite",
|
|
40
|
+
input_type="email",
|
|
41
|
+
query="user@example.com",
|
|
42
|
+
wait=True,
|
|
43
|
+
)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Auth
|
|
47
|
+
|
|
48
|
+
- Header: `x-api-key` (the SDK sets this for you)
|
|
49
|
+
- Env: `OSINTVERSE_API_KEY`
|
|
50
|
+
- Docs: [https://osintverse.com/docs/python](https://osintverse.com/docs/python)
|
|
51
|
+
|
|
52
|
+
`GET /health` and `GET /v1/providers` do not require a key. Search routes do.
|
|
53
|
+
|
|
54
|
+
## Methods
|
|
55
|
+
|
|
56
|
+
| SDK | HTTP |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `client.health()` | `GET /health` |
|
|
59
|
+
| `client.providers.list()` | `GET /v1/providers` |
|
|
60
|
+
| `client.search.create(...)` | `POST /v1/search` |
|
|
61
|
+
| `client.search.bulk(...)` | `POST /v1/search/bulk` |
|
|
62
|
+
| `client.search.retrieve(id)` | `GET /v1/search/{id}` |
|
|
63
|
+
| `client.search.unlock(id)` | `POST /v1/search/{id}/unlock` |
|
|
64
|
+
| `client.search.premium(id)` | `POST /v1/search/{id}/premium` |
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
batch = client.search.bulk(
|
|
68
|
+
input_type="email",
|
|
69
|
+
queries=["alice@example.com", "bob@example.com"],
|
|
70
|
+
providers=["leakradar-lite", "dehashed"],
|
|
71
|
+
wait=True,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
client.search.unlock(search.id) # LeakRadar leftover credentials
|
|
75
|
+
client.search.premium(search.id) # OSINT Industries premium modules
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`wait=True` on **create** raises `SearchFailedError` / `SearchRefundedError` if the job ends in `failed` or `refunded`. Bulk wait polls running jobs and returns the batch — inspect `summary` for partial success.
|
|
79
|
+
|
|
80
|
+
## Errors
|
|
81
|
+
|
|
82
|
+
HTTP `{ "detail": "…" }` maps to `AuthenticationError` (401), `PaymentRequiredError` (402), `ForbiddenError` (403), `NotFoundError` (404), `ValidationError` (422), and `APIError` (5xx).
|
|
83
|
+
|
|
84
|
+
## Development
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install -e ".[dev]"
|
|
88
|
+
pytest
|
|
89
|
+
ruff check src tests
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT
|
|
95
|
+
|
|
96
|
+
## Publishing
|
|
97
|
+
|
|
98
|
+
CI runs lint and tests on every push. PyPI publishes from `.github/workflows/publish.yml` on `v*` tags using [Trusted Publishing](https://docs.pypi.org/trusted-publishers/).
|
|
99
|
+
|
|
100
|
+
1. On PyPI, add a pending trusted publisher for project **osintverse**: GitHub owner `dheerajydv19`, repo `osintverse-pythonsdk`, workflow `publish.yml`, environment blank.
|
|
101
|
+
2. Tag a release: `git tag v0.1.0 && git push origin v0.1.0`.
|
|
102
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "osintverse"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Official Python client for the OSINTverse SearchIn API"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
requires-python = ">=3.10"
|
|
8
|
+
authors = [{ name = "OSINTverse", email = "hi@osintverse.com" }]
|
|
9
|
+
keywords = ["osint", "searchin", "osintverse", "api"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 4 - Beta",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.10",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Topic :: Security",
|
|
20
|
+
"Typing :: Typed",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"httpx>=0.27.0",
|
|
24
|
+
"pydantic>=2.0.0",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://osintverse.com"
|
|
29
|
+
Documentation = "https://osintverse.com/docs/python"
|
|
30
|
+
Repository = "https://github.com/dheerajydv19/osintverse-pythonsdk"
|
|
31
|
+
Issues = "https://github.com/dheerajydv19/osintverse-pythonsdk/issues"
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = [
|
|
35
|
+
"pytest>=8.0.0",
|
|
36
|
+
"pytest-asyncio>=0.24.0",
|
|
37
|
+
"respx>=0.22.0",
|
|
38
|
+
"ruff>=0.8.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[build-system]
|
|
42
|
+
requires = ["hatchling"]
|
|
43
|
+
build-backend = "hatchling.build"
|
|
44
|
+
|
|
45
|
+
[tool.ruff]
|
|
46
|
+
line-length = 100
|
|
47
|
+
target-version = "py310"
|
|
48
|
+
src = ["src", "tests"]
|
|
49
|
+
|
|
50
|
+
[tool.ruff.lint]
|
|
51
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
52
|
+
|
|
53
|
+
[tool.pytest.ini_options]
|
|
54
|
+
asyncio_mode = "auto"
|
|
55
|
+
testpaths = ["tests"]
|
|
56
|
+
pythonpath = ["."]
|
|
57
|
+
|
|
58
|
+
[tool.ruff.lint.isort]
|
|
59
|
+
known-first-party = ["osintverse"]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Official Python client for the OSINTverse SearchIn API.
|
|
2
|
+
|
|
3
|
+
This package talks to ``https://apiv1.osintverse.com`` (osintverse.com). It is
|
|
4
|
+
not affiliated with other products that reuse the OSINTverse name.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from osintverse._async_client import AsyncOSINTverse
|
|
8
|
+
from osintverse._client import OSINTverse
|
|
9
|
+
from osintverse._constants import VERSION as __version__
|
|
10
|
+
from osintverse._exceptions import (
|
|
11
|
+
APIError,
|
|
12
|
+
AuthenticationError,
|
|
13
|
+
ForbiddenError,
|
|
14
|
+
NotFoundError,
|
|
15
|
+
OSINTverseError,
|
|
16
|
+
PaymentRequiredError,
|
|
17
|
+
SearchFailedError,
|
|
18
|
+
SearchRefundedError,
|
|
19
|
+
ValidationError,
|
|
20
|
+
WaitTimeoutError,
|
|
21
|
+
)
|
|
22
|
+
from osintverse._models import (
|
|
23
|
+
BulkSearch,
|
|
24
|
+
BulkSummary,
|
|
25
|
+
InputType,
|
|
26
|
+
InputTypePrice,
|
|
27
|
+
Provider,
|
|
28
|
+
ProviderId,
|
|
29
|
+
ProviderResult,
|
|
30
|
+
Search,
|
|
31
|
+
SearchStatus,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"APIError",
|
|
36
|
+
"AsyncOSINTverse",
|
|
37
|
+
"AuthenticationError",
|
|
38
|
+
"BulkSearch",
|
|
39
|
+
"BulkSummary",
|
|
40
|
+
"ForbiddenError",
|
|
41
|
+
"InputType",
|
|
42
|
+
"InputTypePrice",
|
|
43
|
+
"NotFoundError",
|
|
44
|
+
"OSINTverse",
|
|
45
|
+
"OSINTverseError",
|
|
46
|
+
"PaymentRequiredError",
|
|
47
|
+
"Provider",
|
|
48
|
+
"ProviderId",
|
|
49
|
+
"ProviderResult",
|
|
50
|
+
"Search",
|
|
51
|
+
"SearchFailedError",
|
|
52
|
+
"SearchRefundedError",
|
|
53
|
+
"SearchStatus",
|
|
54
|
+
"ValidationError",
|
|
55
|
+
"WaitTimeoutError",
|
|
56
|
+
"__version__",
|
|
57
|
+
]
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
|
|
8
|
+
from osintverse._async_search import AsyncSearchResource
|
|
9
|
+
from osintverse._constants import (
|
|
10
|
+
API_KEY_ENV,
|
|
11
|
+
DEFAULT_BASE_URL,
|
|
12
|
+
DEFAULT_TIMEOUT,
|
|
13
|
+
USER_AGENT,
|
|
14
|
+
)
|
|
15
|
+
from osintverse._exceptions import AuthenticationError
|
|
16
|
+
from osintverse._http import raise_for_status
|
|
17
|
+
from osintverse._models import Provider
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class AsyncProvidersResource:
|
|
21
|
+
def __init__(self, client: AsyncOSINTverse) -> None:
|
|
22
|
+
self._client = client
|
|
23
|
+
|
|
24
|
+
async def list(self) -> list[Provider]:
|
|
25
|
+
"""Return the live provider catalog via ``GET /v1/providers``."""
|
|
26
|
+
payload = await self._client.request("GET", "/v1/providers", auth=False)
|
|
27
|
+
return [Provider.model_validate(item) for item in payload]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class AsyncOSINTverse:
|
|
31
|
+
"""Async client for the OSINTverse SearchIn API.
|
|
32
|
+
|
|
33
|
+
Parameters match :class:`osintverse.OSINTverse`.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(
|
|
37
|
+
self,
|
|
38
|
+
api_key: str | None = None,
|
|
39
|
+
*,
|
|
40
|
+
base_url: str = DEFAULT_BASE_URL,
|
|
41
|
+
timeout: float = DEFAULT_TIMEOUT,
|
|
42
|
+
http_client: httpx.AsyncClient | None = None,
|
|
43
|
+
) -> None:
|
|
44
|
+
self.api_key = api_key if api_key is not None else os.environ.get(API_KEY_ENV)
|
|
45
|
+
self.base_url = base_url.rstrip("/")
|
|
46
|
+
self._owns_http_client = http_client is None
|
|
47
|
+
self._http = http_client or httpx.AsyncClient(
|
|
48
|
+
base_url=self.base_url,
|
|
49
|
+
timeout=timeout,
|
|
50
|
+
headers={"User-Agent": USER_AGENT, "Accept": "application/json"},
|
|
51
|
+
)
|
|
52
|
+
self.providers = AsyncProvidersResource(self)
|
|
53
|
+
self.search = AsyncSearchResource(self)
|
|
54
|
+
|
|
55
|
+
async def health(self) -> dict[str, Any]:
|
|
56
|
+
"""Service health check via ``GET /health``."""
|
|
57
|
+
payload = await self.request("GET", "/health", auth=False)
|
|
58
|
+
return payload if isinstance(payload, dict) else {"status": payload}
|
|
59
|
+
|
|
60
|
+
async def request(
|
|
61
|
+
self,
|
|
62
|
+
method: str,
|
|
63
|
+
path: str,
|
|
64
|
+
*,
|
|
65
|
+
json: dict[str, Any] | None = None,
|
|
66
|
+
auth: bool = True,
|
|
67
|
+
) -> Any:
|
|
68
|
+
headers: dict[str, str] = {}
|
|
69
|
+
if auth:
|
|
70
|
+
if not self.api_key:
|
|
71
|
+
raise AuthenticationError(
|
|
72
|
+
f"Missing API key. Pass api_key= or set {API_KEY_ENV}.",
|
|
73
|
+
status_code=401,
|
|
74
|
+
)
|
|
75
|
+
headers["x-api-key"] = self.api_key
|
|
76
|
+
response = await self._http.request(method, path, headers=headers, json=json)
|
|
77
|
+
raise_for_status(response)
|
|
78
|
+
if response.status_code == 204 or not response.content:
|
|
79
|
+
return None
|
|
80
|
+
return response.json()
|
|
81
|
+
|
|
82
|
+
async def aclose(self) -> None:
|
|
83
|
+
if self._owns_http_client:
|
|
84
|
+
await self._http.aclose()
|
|
85
|
+
|
|
86
|
+
async def __aenter__(self) -> AsyncOSINTverse:
|
|
87
|
+
return self
|
|
88
|
+
|
|
89
|
+
async def __aexit__(self, *args: object) -> None:
|
|
90
|
+
await self.aclose()
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
from collections.abc import Sequence
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from osintverse._constants import DEFAULT_POLL_INTERVAL, DEFAULT_WAIT_TIMEOUT, TERMINAL_STATUSES
|
|
8
|
+
from osintverse._exceptions import WaitTimeoutError
|
|
9
|
+
from osintverse._models import BulkSearch, Search
|
|
10
|
+
from osintverse._search import _raise_if_unsuccessful, _summarize
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AsyncSearchResource:
|
|
14
|
+
def __init__(self, client: Any) -> None:
|
|
15
|
+
self._client = client
|
|
16
|
+
|
|
17
|
+
async def create(
|
|
18
|
+
self,
|
|
19
|
+
*,
|
|
20
|
+
provider: str,
|
|
21
|
+
input_type: str,
|
|
22
|
+
query: str,
|
|
23
|
+
premium: bool = False,
|
|
24
|
+
wait: bool = False,
|
|
25
|
+
poll_interval: float = DEFAULT_POLL_INTERVAL,
|
|
26
|
+
timeout: float = DEFAULT_WAIT_TIMEOUT,
|
|
27
|
+
) -> Search:
|
|
28
|
+
"""Create a SearchIn job via ``POST /v1/search``."""
|
|
29
|
+
body: dict[str, Any] = {
|
|
30
|
+
"provider": provider,
|
|
31
|
+
"input_type": input_type,
|
|
32
|
+
"query": query,
|
|
33
|
+
}
|
|
34
|
+
if premium:
|
|
35
|
+
body["premium"] = True
|
|
36
|
+
search = Search.model_validate(await self._client.request("POST", "/v1/search", json=body))
|
|
37
|
+
if wait:
|
|
38
|
+
return await self.wait(search, poll_interval=poll_interval, timeout=timeout)
|
|
39
|
+
return search
|
|
40
|
+
|
|
41
|
+
async def bulk(
|
|
42
|
+
self,
|
|
43
|
+
*,
|
|
44
|
+
input_type: str,
|
|
45
|
+
queries: Sequence[str],
|
|
46
|
+
providers: Sequence[str],
|
|
47
|
+
premium: bool = False,
|
|
48
|
+
wait: bool = False,
|
|
49
|
+
poll_interval: float = DEFAULT_POLL_INTERVAL,
|
|
50
|
+
timeout: float = DEFAULT_WAIT_TIMEOUT,
|
|
51
|
+
) -> BulkSearch:
|
|
52
|
+
"""Create many jobs via ``POST /v1/search/bulk``."""
|
|
53
|
+
body: dict[str, Any] = {
|
|
54
|
+
"input_type": input_type,
|
|
55
|
+
"queries": list(queries),
|
|
56
|
+
"providers": list(providers),
|
|
57
|
+
}
|
|
58
|
+
if premium:
|
|
59
|
+
body["premium"] = True
|
|
60
|
+
batch = BulkSearch.model_validate(
|
|
61
|
+
await self._client.request("POST", "/v1/search/bulk", json=body)
|
|
62
|
+
)
|
|
63
|
+
if wait:
|
|
64
|
+
return await self.wait_bulk(batch, poll_interval=poll_interval, timeout=timeout)
|
|
65
|
+
return batch
|
|
66
|
+
|
|
67
|
+
async def retrieve(self, search_id: str) -> Search:
|
|
68
|
+
"""Fetch a job via ``GET /v1/search/{id}``."""
|
|
69
|
+
return Search.model_validate(await self._client.request("GET", f"/v1/search/{search_id}"))
|
|
70
|
+
|
|
71
|
+
get = retrieve
|
|
72
|
+
|
|
73
|
+
async def unlock(self, search_id: str) -> Search:
|
|
74
|
+
"""Unlock remaining LeakRadar credentials via ``POST /v1/search/{id}/unlock``."""
|
|
75
|
+
return Search.model_validate(
|
|
76
|
+
await self._client.request(
|
|
77
|
+
"POST",
|
|
78
|
+
f"/v1/search/{search_id}/unlock",
|
|
79
|
+
json={"unlock_remaining": True},
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
async def premium(self, search_id: str) -> Search:
|
|
84
|
+
"""Run OSINT Industries premium modules via ``POST /v1/search/{id}/premium``."""
|
|
85
|
+
return Search.model_validate(
|
|
86
|
+
await self._client.request(
|
|
87
|
+
"POST",
|
|
88
|
+
f"/v1/search/{search_id}/premium",
|
|
89
|
+
json={"premium": True},
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
async def wait(
|
|
94
|
+
self,
|
|
95
|
+
search: Search | str,
|
|
96
|
+
*,
|
|
97
|
+
poll_interval: float = DEFAULT_POLL_INTERVAL,
|
|
98
|
+
timeout: float = DEFAULT_WAIT_TIMEOUT,
|
|
99
|
+
) -> Search:
|
|
100
|
+
"""Poll until the job leaves ``running``, then raise on ``failed`` / ``refunded``."""
|
|
101
|
+
current = await self.retrieve(search) if isinstance(search, str) else search
|
|
102
|
+
loop = asyncio.get_running_loop()
|
|
103
|
+
deadline = loop.time() + timeout
|
|
104
|
+
while current.status == "running":
|
|
105
|
+
if loop.time() >= deadline:
|
|
106
|
+
raise WaitTimeoutError(f"Timed out waiting for search {current.id}")
|
|
107
|
+
if poll_interval > 0:
|
|
108
|
+
await asyncio.sleep(poll_interval)
|
|
109
|
+
current = await self.retrieve(current.id)
|
|
110
|
+
return _raise_if_unsuccessful(current)
|
|
111
|
+
|
|
112
|
+
async def wait_bulk(
|
|
113
|
+
self,
|
|
114
|
+
batch: BulkSearch,
|
|
115
|
+
*,
|
|
116
|
+
poll_interval: float = DEFAULT_POLL_INTERVAL,
|
|
117
|
+
timeout: float = DEFAULT_WAIT_TIMEOUT,
|
|
118
|
+
) -> BulkSearch:
|
|
119
|
+
"""Poll every ``running`` job in a bulk batch to a terminal status."""
|
|
120
|
+
searches: list[Search] = []
|
|
121
|
+
for search in batch.searches:
|
|
122
|
+
if search.status == "running":
|
|
123
|
+
searches.append(
|
|
124
|
+
await self._wait_terminal(
|
|
125
|
+
search,
|
|
126
|
+
poll_interval=poll_interval,
|
|
127
|
+
timeout=timeout,
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
else:
|
|
131
|
+
searches.append(search)
|
|
132
|
+
return batch.model_copy(update={"searches": searches, "summary": _summarize(searches)})
|
|
133
|
+
|
|
134
|
+
async def _wait_terminal(
|
|
135
|
+
self,
|
|
136
|
+
search: Search,
|
|
137
|
+
*,
|
|
138
|
+
poll_interval: float,
|
|
139
|
+
timeout: float,
|
|
140
|
+
) -> Search:
|
|
141
|
+
current = search
|
|
142
|
+
loop = asyncio.get_running_loop()
|
|
143
|
+
deadline = loop.time() + timeout
|
|
144
|
+
while current.status not in TERMINAL_STATUSES:
|
|
145
|
+
if loop.time() >= deadline:
|
|
146
|
+
raise WaitTimeoutError(f"Timed out waiting for search {current.id}")
|
|
147
|
+
if poll_interval > 0:
|
|
148
|
+
await asyncio.sleep(poll_interval)
|
|
149
|
+
current = await self.retrieve(current.id)
|
|
150
|
+
return current
|