urlquery-api 0.8.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.
- urlquery_api-0.8.0/.github/dependabot.yml +9 -0
- urlquery_api-0.8.0/.github/workflows/ci.yml +26 -0
- urlquery_api-0.8.0/.github/workflows/release.yml +33 -0
- urlquery_api-0.8.0/.gitignore +6 -0
- urlquery_api-0.8.0/LICENSE +21 -0
- urlquery_api-0.8.0/PKG-INFO +109 -0
- urlquery_api-0.8.0/README.md +84 -0
- urlquery_api-0.8.0/pyproject.toml +39 -0
- urlquery_api-0.8.0/src/urlquery_api/__init__.py +29 -0
- urlquery_api-0.8.0/src/urlquery_api/_client.py +560 -0
- urlquery_api-0.8.0/src/urlquery_api/_errors.py +50 -0
- urlquery_api-0.8.0/src/urlquery_api/models.py +1911 -0
- urlquery_api-0.8.0/src/urlquery_api/py.typed +0 -0
- urlquery_api-0.8.0/tests/test_client.py +128 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Proposes updates to the pinned GitHub Actions. This repository is published
|
|
2
|
+
# from urlquery's main repository, so accepted updates are applied there and
|
|
3
|
+
# arrive with the next release.
|
|
4
|
+
version: 2
|
|
5
|
+
updates:
|
|
6
|
+
- package-ecosystem: github-actions
|
|
7
|
+
directory: /
|
|
8
|
+
schedule:
|
|
9
|
+
interval: weekly
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
17
|
+
steps:
|
|
18
|
+
# Actions are pinned to full commit SHAs; Dependabot proposes updates.
|
|
19
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
20
|
+
with:
|
|
21
|
+
persist-credentials: false
|
|
22
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
23
|
+
with:
|
|
24
|
+
python-version: ${{ matrix.python-version }}
|
|
25
|
+
- run: pip install '.[test]'
|
|
26
|
+
- run: pytest -q
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
# A v* tag builds the package, attests its provenance, and publishes it to
|
|
4
|
+
# PyPI with trusted publishing: PyPI trusts this workflow, so no token is
|
|
5
|
+
# stored. The pypi environment must be set up on PyPI and here.
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
tags: ["v*"]
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
release:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
environment: pypi
|
|
17
|
+
permissions:
|
|
18
|
+
id-token: write # trusted publishing and signing
|
|
19
|
+
attestations: write # build provenance
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
22
|
+
with:
|
|
23
|
+
fetch-depth: 0 # the version comes from the tag
|
|
24
|
+
persist-credentials: false
|
|
25
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
26
|
+
with:
|
|
27
|
+
python-version: "3.12"
|
|
28
|
+
- run: pip install '.[test]' && pytest -q
|
|
29
|
+
- run: pip install build==1.6.1 && python -m build
|
|
30
|
+
- uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
|
|
31
|
+
with:
|
|
32
|
+
subject-path: dist/*
|
|
33
|
+
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 urlquery.net
|
|
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,109 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: urlquery-api
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Summary: Python client for the urlquery v2 API: URL analysis reports, search, reputation, Host Profile, YARA and monitoring
|
|
5
|
+
Project-URL: Homepage, https://urlquery.net
|
|
6
|
+
Project-URL: Documentation, https://docs.urlquery.net/docs/libraries/python
|
|
7
|
+
Project-URL: Source, https://github.com/urlquery/urlquery-api-python
|
|
8
|
+
Project-URL: Issues, https://github.com/urlquery/urlquery-api-python/issues
|
|
9
|
+
Author-email: "urlquery.net" <contact@urlquery.net>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: phishing,sandbox,threat intelligence,url analysis,urlquery,yara
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Information Technology
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Security
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: httpx>=0.27
|
|
21
|
+
Requires-Dist: pydantic>=2.7
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
Requires-Dist: pytest>=8; extra == 'test'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# urlquery-api-python
|
|
27
|
+
|
|
28
|
+
[](https://pypi.org/project/urlquery-api/)
|
|
29
|
+
[](LICENSE)
|
|
30
|
+
|
|
31
|
+
The Python client for the [urlquery](https://urlquery.net) v2 API. urlquery
|
|
32
|
+
analyzes URLs in an isolated browser and records what they do: redirects,
|
|
33
|
+
HTTP traffic, scripts, downloads, detections and a screenshot.
|
|
34
|
+
|
|
35
|
+
With this package you can submit URLs and wait for the reports, read and
|
|
36
|
+
compare reports, search a year of reports, look up reputation, explore Host
|
|
37
|
+
Profile, and manage YARA rules, watchlists and page monitors. Results are
|
|
38
|
+
typed [pydantic](https://docs.pydantic.dev) models.
|
|
39
|
+
|
|
40
|
+
**Documentation: <https://docs.urlquery.net/docs/libraries/python>**
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
pip install urlquery-api
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
It needs Python 3.10 or later, and an API key from your
|
|
49
|
+
[urlquery.net](https://urlquery.net) account.
|
|
50
|
+
|
|
51
|
+
## Example
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from urlquery_api import Client
|
|
55
|
+
|
|
56
|
+
with Client() as client: # the API key from URLQUERY_APIKEY
|
|
57
|
+
# Analyze a URL as a restricted report and wait for it.
|
|
58
|
+
s = client.submit("https://example.com/login", access="restricted", wait=True)
|
|
59
|
+
|
|
60
|
+
# The full report: every HTTP transaction, script and artifact.
|
|
61
|
+
report = client.report(s.report_id)
|
|
62
|
+
for t in report.http:
|
|
63
|
+
print(t.response.status_code, t.url.addr)
|
|
64
|
+
|
|
65
|
+
# Every other report that loaded the same scripts.
|
|
66
|
+
for script in report.javascript.script:
|
|
67
|
+
for hit in client.iter_search_results(f"javascript.script.sha256:{script.sha256}"):
|
|
68
|
+
print(script.sha256[:12], hit.report_id, hit.url.addr)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## How it behaves
|
|
72
|
+
|
|
73
|
+
- **Typed results.** The models in `urlquery_api.models` are generated from
|
|
74
|
+
the API's [OpenAPI description](https://docs.urlquery.net/openapi/public-v2.yaml),
|
|
75
|
+
so every field of every response, down to the report's transactions,
|
|
76
|
+
scripts and artifacts, is typed.
|
|
77
|
+
- **Paging.** Each list method returns one page; its `iter_…` method yields
|
|
78
|
+
every item, following cursors for you.
|
|
79
|
+
- **Rate limits and retries.** A call waits out a rate limit for its
|
|
80
|
+
`Retry-After`, and a GET is retried after a server error or a network
|
|
81
|
+
failure; `max_retry_wait` bounds the waiting. Submissions are never retried
|
|
82
|
+
once they may have been queued.
|
|
83
|
+
- **Waiting for an analysis.** `submit(..., wait=True)` and
|
|
84
|
+
`wait_for_submission` poll until the analysis is done or has failed; on a
|
|
85
|
+
timeout, `WaitTimeoutError.submission` is the last state, with the queue and
|
|
86
|
+
report IDs.
|
|
87
|
+
- **Errors.** API errors raise `APIError` with the API's error `code`, such as
|
|
88
|
+
`NOT_FOUND` or `RATE_LIMIT_EXCEEDED`.
|
|
89
|
+
- **Hostile content.** Report content comes from the analyzed sites: treat
|
|
90
|
+
titles, scripts and downloads as untrusted data.
|
|
91
|
+
|
|
92
|
+
## Contributing
|
|
93
|
+
|
|
94
|
+
Report bugs and ask for features in the
|
|
95
|
+
[issues](https://github.com/urlquery/urlquery-api-python/issues). Pull requests
|
|
96
|
+
are welcome: this repository is published from urlquery's main repository, so
|
|
97
|
+
an accepted change is applied there and arrives here with the next release.
|
|
98
|
+
`src/urlquery_api/models.py` is generated from the API description; don't
|
|
99
|
+
edit it by hand. For other questions, write to
|
|
100
|
+
[contact@urlquery.net](mailto:contact@urlquery.net).
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
pip install -e '.[test]'
|
|
104
|
+
pytest
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
MIT © [urlquery.net](https://urlquery.net), see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# urlquery-api-python
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/urlquery-api/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
The Python client for the [urlquery](https://urlquery.net) v2 API. urlquery
|
|
7
|
+
analyzes URLs in an isolated browser and records what they do: redirects,
|
|
8
|
+
HTTP traffic, scripts, downloads, detections and a screenshot.
|
|
9
|
+
|
|
10
|
+
With this package you can submit URLs and wait for the reports, read and
|
|
11
|
+
compare reports, search a year of reports, look up reputation, explore Host
|
|
12
|
+
Profile, and manage YARA rules, watchlists and page monitors. Results are
|
|
13
|
+
typed [pydantic](https://docs.pydantic.dev) models.
|
|
14
|
+
|
|
15
|
+
**Documentation: <https://docs.urlquery.net/docs/libraries/python>**
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
pip install urlquery-api
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
It needs Python 3.10 or later, and an API key from your
|
|
24
|
+
[urlquery.net](https://urlquery.net) account.
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from urlquery_api import Client
|
|
30
|
+
|
|
31
|
+
with Client() as client: # the API key from URLQUERY_APIKEY
|
|
32
|
+
# Analyze a URL as a restricted report and wait for it.
|
|
33
|
+
s = client.submit("https://example.com/login", access="restricted", wait=True)
|
|
34
|
+
|
|
35
|
+
# The full report: every HTTP transaction, script and artifact.
|
|
36
|
+
report = client.report(s.report_id)
|
|
37
|
+
for t in report.http:
|
|
38
|
+
print(t.response.status_code, t.url.addr)
|
|
39
|
+
|
|
40
|
+
# Every other report that loaded the same scripts.
|
|
41
|
+
for script in report.javascript.script:
|
|
42
|
+
for hit in client.iter_search_results(f"javascript.script.sha256:{script.sha256}"):
|
|
43
|
+
print(script.sha256[:12], hit.report_id, hit.url.addr)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## How it behaves
|
|
47
|
+
|
|
48
|
+
- **Typed results.** The models in `urlquery_api.models` are generated from
|
|
49
|
+
the API's [OpenAPI description](https://docs.urlquery.net/openapi/public-v2.yaml),
|
|
50
|
+
so every field of every response, down to the report's transactions,
|
|
51
|
+
scripts and artifacts, is typed.
|
|
52
|
+
- **Paging.** Each list method returns one page; its `iter_…` method yields
|
|
53
|
+
every item, following cursors for you.
|
|
54
|
+
- **Rate limits and retries.** A call waits out a rate limit for its
|
|
55
|
+
`Retry-After`, and a GET is retried after a server error or a network
|
|
56
|
+
failure; `max_retry_wait` bounds the waiting. Submissions are never retried
|
|
57
|
+
once they may have been queued.
|
|
58
|
+
- **Waiting for an analysis.** `submit(..., wait=True)` and
|
|
59
|
+
`wait_for_submission` poll until the analysis is done or has failed; on a
|
|
60
|
+
timeout, `WaitTimeoutError.submission` is the last state, with the queue and
|
|
61
|
+
report IDs.
|
|
62
|
+
- **Errors.** API errors raise `APIError` with the API's error `code`, such as
|
|
63
|
+
`NOT_FOUND` or `RATE_LIMIT_EXCEEDED`.
|
|
64
|
+
- **Hostile content.** Report content comes from the analyzed sites: treat
|
|
65
|
+
titles, scripts and downloads as untrusted data.
|
|
66
|
+
|
|
67
|
+
## Contributing
|
|
68
|
+
|
|
69
|
+
Report bugs and ask for features in the
|
|
70
|
+
[issues](https://github.com/urlquery/urlquery-api-python/issues). Pull requests
|
|
71
|
+
are welcome: this repository is published from urlquery's main repository, so
|
|
72
|
+
an accepted change is applied there and arrives here with the next release.
|
|
73
|
+
`src/urlquery_api/models.py` is generated from the API description; don't
|
|
74
|
+
edit it by hand. For other questions, write to
|
|
75
|
+
[contact@urlquery.net](mailto:contact@urlquery.net).
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
pip install -e '.[test]'
|
|
79
|
+
pytest
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT © [urlquery.net](https://urlquery.net), see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling==1.33.0", "hatch-vcs==0.5.0"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "urlquery-api"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Python client for the urlquery v2 API: URL analysis reports, search, reputation, Host Profile, YARA and monitoring"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "urlquery.net", email = "contact@urlquery.net" }]
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
dependencies = ["httpx>=0.27", "pydantic>=2.7"]
|
|
15
|
+
keywords = ["urlquery", "threat intelligence", "phishing", "url analysis", "sandbox", "yara"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Intended Audience :: Information Technology",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Topic :: Security",
|
|
22
|
+
"Typing :: Typed",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.optional-dependencies]
|
|
26
|
+
test = ["pytest>=8"]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://urlquery.net"
|
|
30
|
+
Documentation = "https://docs.urlquery.net/docs/libraries/python"
|
|
31
|
+
Source = "https://github.com/urlquery/urlquery-api-python"
|
|
32
|
+
Issues = "https://github.com/urlquery/urlquery-api-python/issues"
|
|
33
|
+
|
|
34
|
+
[tool.hatch.version]
|
|
35
|
+
source = "vcs"
|
|
36
|
+
fallback-version = "0.0.0"
|
|
37
|
+
|
|
38
|
+
[tool.hatch.build.targets.wheel]
|
|
39
|
+
packages = ["src/urlquery_api"]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""The Python client for the urlquery v2 API (https://api.urlquery.net/public/v2).
|
|
2
|
+
|
|
3
|
+
Submit URLs for analysis, read and compare reports, search a year of reports,
|
|
4
|
+
look up reputation, explore Host Profile, and manage YARA rules, watchlists and
|
|
5
|
+
page monitors::
|
|
6
|
+
|
|
7
|
+
from urlquery_api import Client
|
|
8
|
+
|
|
9
|
+
with Client() as client: # the API key from URLQUERY_APIKEY
|
|
10
|
+
s = client.submit("https://example.com/login", access="restricted", wait=True)
|
|
11
|
+
report = client.report(s.report_id)
|
|
12
|
+
|
|
13
|
+
Results are pydantic models generated from the API's OpenAPI description, in
|
|
14
|
+
``urlquery_api.models``. Documentation: https://docs.urlquery.net/docs/libraries/python
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from . import models
|
|
18
|
+
from ._client import DEFAULT_BASE_URL, Client
|
|
19
|
+
from ._errors import APIError, InvalidResponseError, URLQueryError, WaitTimeoutError
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"DEFAULT_BASE_URL",
|
|
23
|
+
"APIError",
|
|
24
|
+
"Client",
|
|
25
|
+
"InvalidResponseError",
|
|
26
|
+
"URLQueryError",
|
|
27
|
+
"WaitTimeoutError",
|
|
28
|
+
"models",
|
|
29
|
+
]
|