urlscope
urlscope is an async-first Python wrapper for the urlscan.io API. It provides typed Pydantic models for common API responses, automatic API key handling, built-in retry logic for rate limits, and a sync convenience wrapper for scripts.
Installation
pip install urlscope
Set your API key before making requests:
export URLSCAN_API_KEY="your-api-key-here"
Quickstart
Async submit and wait
import asyncio
from urlscope import UrlscopeClient
async def main() -> None:
async with UrlscopeClient() as client:
result = await client.submit_and_wait(
"https://example.com",
visibility="public",
)
overall = result.verdicts.overall if result.verdicts else None
print(result.task.uuid)
print(result.page.url)
print(overall.score if overall else None)
asyncio.run(main())
Submit now, fetch the result later
import asyncio
from urlscope import NotFoundError, UrlscopeClient
async def main() -> None:
async with UrlscopeClient() as client:
submission = await client.submit("https://example.com", visibility="private")
print(submission.uuid, submission.result)
# Later: get_result raises NotFoundError while the scan is still running.
try:
result = await client.get_result(submission.uuid)
print(result.page.url)
except NotFoundError:
print("still pending")
asyncio.run(main())
Sync usage
from urlscope import SyncClient
with SyncClient() as client:
result = client.get_result("scan-uuid-here")
print(result.page.url)
Search
import asyncio
from urlscope import UrlscopeClient
async def main() -> None:
async with UrlscopeClient() as client:
response = await client.search(
"domain:example.com",
size=10,
datasource="scans",
)
print("total:", response.total, "took:", response.took)
for item in response.results:
page_url = item.page.get("url") if item.page else None
print(item.id, page_url, item.result)
# Cursor-based pagination is handled via the previous item's sort key.
if response.has_more and response.results and response.results[-1].sort:
next_page = await client.search(
"domain:example.com",
size=10,
search_after=response.results[-1].sort,
collapse="page.domain.keyword",
)
print(len(next_page.results))
asyncio.run(main())
Download artifacts
import asyncio
from urlscope import UrlscopeClient
async def main() -> None:
async with UrlscopeClient() as client:
screenshot = await client.get_screenshot("scan-uuid-here")
dom = await client.get_dom("scan-uuid-here")
print(len(screenshot), len(dom))
asyncio.run(main())
urlscan occasionally produces no screenshot for a finished scan; get_screenshot then raises NotFoundError.
Check quotas
import asyncio
from urlscope import UrlscopeClient
async def main() -> None:
async with UrlscopeClient() as client:
quotas = await client.get_quotas()
print(quotas.scope)
for q in quotas.quotas[:5]:
print(q.scope, q.action, q.window, q.used, q.remaining, q.limit, q.reset)
asyncio.run(main())
The live quotas response is also available in raw form via QuotaInfo.limits, including account metadata that is not flattened into QuotaInfo.quotas.
Error handling
import asyncio
from urlscope import RateLimitError, ScanTimeoutError, UrlscopeClient
async def main() -> None:
async with UrlscopeClient() as client:
try:
await client.submit_and_wait("https://example.com", poll_timeout=120.0)
except ScanTimeoutError as exc:
print(exc.uuid)
except RateLimitError as exc:
print(exc.retry_after, exc.scope, exc.window)
asyncio.run(main())
Network failures are not wrapped: connection errors and timeouts propagate as httpx2 exceptions, such as httpx2.ConnectError and httpx2.TimeoutException.
submit(..., override_safety=True) is supported by the wrapper and is serialized to the current live urlscan wire format for overrideSafety.
API Reference
Primary clients:
UrlscopeClient: async interface for submit, result retrieval, polling, search, artifacts, and quotasSyncClient: sync wrapper with the same method surface for scripts and simple integrations
Key response models:
SubmissionResponseScanResult,TaskInfo,PageInfo,Verdicts,BrandMatch,ScanLists,CertificateInfoSearchResponse,SearchResultItemQuotaInfo,QuotaWindow
Every model keeps the fields it does not type: result.model_extra holds them, and result.model_dump(by_alias=True) returns the whole parsed response as a dict with urlscan's field names, including computed fields such as QuotaInfo.quotas.
ScanResult.verdicts follows the live urlscan structure with nested sections such as overall, urlscan, engines, and community. For example, use result.verdicts.overall.score for the top-level score.
SearchResponse includes total, took, has_more, and results. SearchResultItem exposes stable top-level fields such as id, score, sort, page, task, stats, result, and screenshot, while preserving less consistent live API sections as model extras. Search supports optional datasource and collapse parameters, and serializes search_after cursors in the comma-separated form expected by urlscan.
Search uses urlscan's searchable index. If you already have an exact scan UUID, prefer get_result(uuid); a retrievable UUID is not guaranteed to appear in search results under every account plan or index state.
Key exceptions:
UrlscopeErrorAuthenticationErrorValidationErrorNotFoundErrorScanDeletedErrorRateLimitErrorScanTimeoutErrorAPIError
Development
uv sync # dev tools included
git config core.hooksPath .githooks # once per clone: gitleaks secret scanning
uv run pytest tests/ # mocked tests
uv run --env-file .env pytest -m live # tests against the real API; needs URLSCAN_API_KEY
uv run ruff check src/ tests/
uv run ruff format --check src/ tests/
uv run mypy src/
uv build && uvx twine check --strict dist/*
The package version is defined in src/urlscope/__init__.py and read dynamically by Hatchling during builds. Design notes and known urlscan API quirks are in docs/design.md; report security issues as described in SECURITY.md.
License
MIT
Metadata
Release files for urlscope 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| urlscope-0.2.0.tar.gz | 81.9 kB | With provenance | Details for urlscope-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| urlscope-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for urlscope-0.2.0-py3-none-any.whl |
Total release size: 96.0 kB
Release files / urlscope-0.2.0.tar.gz
| Download URL | urlscope-0.2.0.tar.gz |
|---|---|
| Size | 81.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e26d4c0ba672f383e21af6e730d1b67be7d06adc9f594d749b64e5f9e5c41c7
|
|
BLAKE2b-256 checksum How to use checksums |
769fb49dfa2d712b37df3b49a31b4280e9e5f91d33ffb78c0deecf7766ce1b65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / urlscope-0.2.0-py3-none-any.whl
| Download URL | urlscope-0.2.0-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6005328b6f7b1b73eae00ff82d58b774119164d298e6a4297764bda76ff1881b
|
|
BLAKE2b-256 checksum How to use checksums |
0549fa8431f108e19e02b940bf6ad866835cd8b2e44ee2da3b4bec50761b4ce2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logSecurity for urlscope 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for urlscope-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.