Python wrapper for the urlscan.io API.
Project description
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",
)
print(result.task.uuid)
print(result.page.url)
print(result.verdicts.score if result.verdicts else None)
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)
for item in response.results:
print(item.id, item.page.get("url") if item.page else None)
# 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,
)
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())
Check quotas
import asyncio
from urlscope import UrlscopeClient
async def main() -> None:
async with UrlscopeClient() as client:
quotas = await client.get_quotas()
for q in quotas.quotas[:5]:
print(q.scope, q.action, q.window, q.remaining, q.limit)
asyncio.run(main())
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())
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
Key exceptions:
UrlscopeErrorAuthenticationErrorValidationErrorNotFoundErrorScanDeletedErrorRateLimitErrorScanTimeoutErrorAPIError
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file urlscope-0.1.3rc1.tar.gz.
File metadata
- Download URL: urlscope-0.1.3rc1.tar.gz
- Upload date:
- Size: 38.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46e04b1b5c1faf707f67da8f9a67fcbe48cdb0901f876cf077bd84cfc705b789
|
|
| MD5 |
58b772e50dba9ff4417eaf572399713d
|
|
| BLAKE2b-256 |
5e0b5f39bcab35d3c8337a7d62e7a355f7eda25ee00d6b9def724730b30188a8
|
Provenance
The following attestation bundles were made for urlscope-0.1.3rc1.tar.gz:
Publisher:
publish-pypi.yml on janwychowaniak/urlscope
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
urlscope-0.1.3rc1.tar.gz -
Subject digest:
46e04b1b5c1faf707f67da8f9a67fcbe48cdb0901f876cf077bd84cfc705b789 - Sigstore transparency entry: 1214446902
- Sigstore integration time:
-
Permalink:
janwychowaniak/urlscope@79f6c72d9a68f1a5691e6e760b1438fe19ba040c -
Branch / Tag:
refs/tags/v0.1.3rc1 - Owner: https://github.com/janwychowaniak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@79f6c72d9a68f1a5691e6e760b1438fe19ba040c -
Trigger Event:
push
-
Statement type:
File details
Details for the file urlscope-0.1.3rc1-py3-none-any.whl.
File metadata
- Download URL: urlscope-0.1.3rc1-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d4803201d2c0db0ce532df5f354be48bd9414a9c2fcf37ed1c98fb172787cf0
|
|
| MD5 |
04b0b035c29cca907277a7a074ceb063
|
|
| BLAKE2b-256 |
df9bf3bf9ff40c71474a8a5d011fc95b3a6a371b9e7ca749ed454560f1f8bb7e
|
Provenance
The following attestation bundles were made for urlscope-0.1.3rc1-py3-none-any.whl:
Publisher:
publish-pypi.yml on janwychowaniak/urlscope
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
urlscope-0.1.3rc1-py3-none-any.whl -
Subject digest:
2d4803201d2c0db0ce532df5f354be48bd9414a9c2fcf37ed1c98fb172787cf0 - Sigstore transparency entry: 1214446968
- Sigstore integration time:
-
Permalink:
janwychowaniak/urlscope@79f6c72d9a68f1a5691e6e760b1438fe19ba040c -
Branch / Tag:
refs/tags/v0.1.3rc1 - Owner: https://github.com/janwychowaniak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@79f6c72d9a68f1a5691e6e760b1438fe19ba040c -
Trigger Event:
push
-
Statement type: