Skip to content

urlscan-python

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:

>>> client = urlscan.Client("<your_api_key>")

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"])

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.