> ## Documentation Index
> Fetch the complete documentation index at: https://docs.urldna.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Python Package

> The urlDNA Python package allows you to interact with the URLDNA API for scanning and analyzing URLs. With this package, you can retrieve scan results, extract metadata, and detect potential threats. 

## Installation

Install the package using `pip`:

```sh theme={null}
pip install urldna
```

### Setup

```python theme={null}
from urldna import UrlDNA

# Initialize the client with your API key (available in your profile)
api_key = '<YOUR_API_KEY>'
client = UrlDNA(api_key)
```

### Create a scan

```python theme={null}
url = 'https://urldna.io'

# Create a new scan and wait until the scan status is DONE or ERROR
scan_result = client.create_scan(url) 
```

```python theme={null}
url = 'https://urldna.io'

# Create a new scan and return the scan object while its status is still PENDING or RUNNING
scan = client.async_create_scan(url)
scan_id = scan.id # Use this id to fecth scan result
```

### Get a scan

```python theme={null}
scan_result = client.get_scan(scan_id)

# Print various scan results
print(scan_result.cookies)           # List of cookies found on the webpage
print(scan_result.dom)               # Full HTML source code of the page
print(scan_result.favicon)           # Favicon details, including hash and URL
print(scan_result.http_transactions) # List of all HTTP requests and responses
print(scan_result.ip_address)        # IP address associated with the scanned URL
print(scan_result.scan_whois)        # WHOIS registration details
print(scan_result.malicious)         # Indicates whether the URL is flagged as malicious (beta feature)
print(scan_result.page)              # Extracted meta tags, headers, and text content
print(scan_result.screenshot)        # URL of the captured webpage screenshot
print(scan_result.technologies)      # List of detected technologies used on the site
print(scan_result.scan_feedback)     # User-submitted feedback on the scan

```

### Scan feedback

```python theme={null}
# Submit user feedback for a scan (marking the URL as MALICIOUS or SAFE)
scan_feedback = client.scan_feedback(scan_id, "MALICIOUS")  
print(scan_feedback.malicious_count)  # Number of users who marked this as malicious
```

### Fast Check

```python theme={null}
url = 'https://urldna.io'

# Perform a quick reputation check on the URL (returns cached results if available)
response = client.fast_check(url)
print(response.status)  # Possible values: MALICIOUS, SAFE, or UNRATED

```

## Additional Resources

* [PyPI](https://pypi.org/project/urlDNA/).

* [GitHub](https://github.com/urldna/urldna).

* [OpenAPI](https://api.urldna.io/openapi.json).
