Skip to main content

The official Python API client for urlscan.io

Project description

urlscan-python

PyPI version

The official Python API client for urlscan.io.

Requirements

  • Python 3.10+

Installation

pip install urlscan-python

Quickstart

Start by importing urlscan module:

import urlscan

Create a client with your API key:

with urlscan.Client("<your_api_key>") as client:
    ...

[!NOTE] The recommended way to use Client is as a context manager like the above. This will ensure closing a connection when leaving the with block.

Alternatively, you can explicitly close the connection pool without block-usage using ._close():

client = urlscan.Client("<your_api_key>")
try:
    ...
finally:
    client._close()

Scan a URL:

res = client.scan("<url>", visibility="public")
uuid: str = res["uuid"]

Wait for a scan result:

client.wait_for_result(uuid)

Get a scan result:

result = client.get_result(uuid)

Bulk scan:

client.bulk_scan(["<url>", "<url>"], visibility="public")

Alternatively, you can use _and_get_result(s) suffixed methods to do scan, wait and get at once.

client.scan_and_get_result("<url>", visibility="public")
client.bulk_scan_and_get_results(["<url>", "<url>"], visibility="public")

urlscan.Client.search() returns an iterator to iterate search results:

for result in client.search("page.domain:example.com"):
    print(result["_id"])

Pro

Use Pro class to interact with the pro API endpoints:

from urlscan import Pro

with Pro("<your_api_key>") as client:
    res = client.livescan.scan("<url>", scanner_id="us01")
    resource_id: str = res["uuid"]
    result = client.livescan.get_resource(scanner_id="us01", resource_id=resource_id, resource_type="result")

Examples

See Examples.

References

Help Wanted?

Please feel free to to open an issue if you find a bug or some feature that you want to see implemented.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

urlscan_python-2026.3.26.tar.gz (107.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

urlscan_python-2026.3.26-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file urlscan_python-2026.3.26.tar.gz.

File metadata

  • Download URL: urlscan_python-2026.3.26.tar.gz
  • Upload date:
  • Size: 107.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for urlscan_python-2026.3.26.tar.gz
Algorithm Hash digest
SHA256 81cc0d9544ea337ea86bedb0b61f6926006bd9d86fb1b5ce8cb585425f69e695
MD5 7bf6cb6ccfc8341699f49fe0117bad5f
BLAKE2b-256 8876a7461d1d754fdf595baea8deaec658f696e8710eab16fe3b748a7223189b

See more details on using hashes here.

Provenance

The following attestation bundles were made for urlscan_python-2026.3.26.tar.gz:

Publisher: publish.yml on urlscan/urlscan-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file urlscan_python-2026.3.26-py3-none-any.whl.

File metadata

File hashes

Hashes for urlscan_python-2026.3.26-py3-none-any.whl
Algorithm Hash digest
SHA256 1b9a4d190d873844f1bd54e16a4b494f8be1d6d5cd3eeb831a6baf03a2e91567
MD5 0e0d12fe69d77267271bcbf70e8a14bb
BLAKE2b-256 48102be33deb71eb3012a98d81e6bc9c6b4695ce324a230f67b38d60b8ca7671

See more details on using hashes here.

Provenance

The following attestation bundles were made for urlscan_python-2026.3.26-py3-none-any.whl:

Publisher: publish.yml on urlscan/urlscan-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page