Supacrawler Docs

Watch Endpoint

Monitor websites for changes using the Python SDK

Basic Usage

from supacrawler import SupacrawlerClient, WatchCreateRequest

client = SupacrawlerClient(api_key="YOUR_API_KEY")

# Create watch job
watch = client.watch_create(WatchCreateRequest(
    url="https://example.com/pricing",
    frequency="hourly",
    notify_email="[email protected]"
))

print(f"watch created: {watch.watch_id}")

Frequencies

# Check every hour
watch = client.watch_create(WatchCreateRequest(
    url="https://example.com",
    frequency="hourly",
    notify_email="[email protected]"
))

# Check daily
watch = client.watch_create(WatchCreateRequest(
    url="https://example.com",
    frequency="daily",
    notify_email="[email protected]"
))

# Check weekly
watch = client.watch_create(WatchCreateRequest(
    url="https://example.com",
    frequency="weekly",
    notify_email="[email protected]"
))

Notification Preferences

Changes Only

watch = client.watch_create(WatchCreateRequest(
    url="https://example.com/blog",
    frequency="hourly",
    notify_email="[email protected]",
    notification_preference="changes_only"  # Only notify on changes
))

All Runs

watch = client.watch_create(WatchCreateRequest(
    url="https://example.com",
    frequency="daily",
    notify_email="[email protected]",
    notification_preference="all_runs"  # Notify on every check
))

Include Content

HTML Content

watch = client.watch_create(WatchCreateRequest(
    url="https://example.com",
    frequency="hourly",
    notify_email="[email protected]",
    include_html=True  # Include HTML in results
))

Screenshot

watch = client.watch_create(WatchCreateRequest(
    url="https://example.com",
    frequency="daily",
    notify_email="[email protected]",
    include_image=True,  # Include screenshot
    full_page=False,     # Viewport only
    quality=85          # JPEG quality
))

Specific Elements

Monitor with CSS Selector

watch = client.watch_create(WatchCreateRequest(
    url="https://example.com/pricing",
    frequency="hourly",
    notify_email="[email protected]",
    selector="#pricing-table",  # Only watch this element
    notification_preference="changes_only"
))

Managing Watches

Get Watch Details

# Get watch details and results
details = client.watch_get(watch.watch_id)

print(f"status: {details.watch.status}")
print(f"last check: {details.watch.last_check}")
print(f"results: {len(details.results)}")

# Access latest result
if details.results:
    latest = details.results[0]
    print(f"has changed: {latest.has_changed}")
    print(f"change type: {latest.change_type}")

List All Watches

# List all watches
all_watches = client.watch_list()

print(f"total watches: {all_watches.total}")

for watch in all_watches.watches:
    print(f"ID: {watch.id}")
    print(f"URL: {watch.url}")
    print(f"frequency: {watch.frequency}")
    print(f"status: {watch.status}")
    print("-" * 50)

Pause Watch

# Pause a watch (stop checking)
client.watch_pause(watch.watch_id)
print("watch paused")

Resume Watch

# Resume a paused watch
client.watch_resume(watch.watch_id)
print("watch resumed")

Manual Check

# Trigger immediate check (bypasses schedule)
result = client.watch_check(watch.watch_id)
print(f"manual check completed: {result}")

Delete Watch

# Delete watch
client.watch_delete(watch.watch_id)
print("watch deleted")

Complete Example

import os
from dotenv import load_dotenv
from supacrawler import SupacrawlerClient, WatchCreateRequest

load_dotenv()

client = SupacrawlerClient(api_key=os.environ.get("SUPACRAWLER_API_KEY"))

# Create comprehensive watch
watch = client.watch_create(WatchCreateRequest(
    url="https://supacrawler.com/blog",
    frequency="hourly",
    notify_email="[email protected]",
    notification_preference="changes_only",
    include_html=True,
    include_image=True,
    full_page=False,
    quality=85
))

print(f"✅ watch created: {watch.watch_id}")

# Get details
details = client.watch_get(watch.watch_id)
print(f"\nwatch details:")
print(f"URL: {details.watch.url}")
print(f"status: {details.watch.status}")
print(f"frequency: {details.watch.frequency}")

# Check results
if details.results:
    print(f"\nlatest result:")
    latest = details.results[0]
    print(f"executed at: {latest.executed_at}")
    print(f"has changed: {latest.has_changed}")
    
    if latest.content:
        print(f"content hash: {latest.content_hash}")
    
    if latest.image_url:
        print(f"screenshot: {latest.image_url}")

# List all watches
all_watches = client.watch_list()
print(f"\ntotal active watches: {all_watches.total}")

# Trigger manual check
print("\ntriggering manual check...")
client.watch_check(watch.watch_id)

# Pause watch
print("pausing watch...")
client.watch_pause(watch.watch_id)

# Resume watch
print("resuming watch...")
client.watch_resume(watch.watch_id)

# Clean up (optional)
# client.watch_delete(watch.watch_id)

Response Structure

Watch Object

details = client.watch_get(watch_id)

watch = details.watch
print(watch.id)                      # Watch ID
print(watch.user_id)                 # User ID
print(watch.url)                     # Monitored URL
print(watch.frequency)               # Check frequency
print(watch.notify_email)            # Notification email
print(watch.notification_preference) # Notification setting
print(watch.include_html)            # HTML included
print(watch.include_image)           # Screenshot included
print(watch.full_page)               # Full page screenshot
print(watch.quality)                 # Screenshot quality
print(watch.selector)                # CSS selector (if set)
print(watch.status)                  # "active", "paused"
print(watch.last_check)              # Last check timestamp
print(watch.created_at)              # Creation timestamp

Watch Result

result = details.results[0]
print(result.id)               # Result ID
print(result.executed_at)      # Execution timestamp
print(result.has_changed)      # Boolean: content changed
print(result.change_type)      # Type of change detected
print(result.content_hash)     # Hash of content
print(result.content)          # Text content (if available)
print(result.html_content)     # HTML content (if included)
print(result.image_url)        # Screenshot URL (if included)

Use Cases

Price Monitoring

# Monitor pricing page for changes
watch = client.watch_create(WatchCreateRequest(
    url="https://competitor.com/pricing",
    frequency="daily",
    notify_email="[email protected]",
    selector="#pricing-table",
    notification_preference="changes_only",
    include_html=True
))

Product Availability

# Watch for product back in stock
watch = client.watch_create(WatchCreateRequest(
    url="https://store.com/product/limited-edition",
    frequency="hourly",
    notify_email="[email protected]",
    selector=".product-availability",
    notification_preference="changes_only"
))

Blog Updates

# Get notified of new blog posts
watch = client.watch_create(WatchCreateRequest(
    url="https://competitor.com/blog",
    frequency="daily",
    notify_email="[email protected]",
    notification_preference="changes_only",
    include_image=True,
    full_page=True
))

Documentation Changes

# Monitor docs for updates
watch = client.watch_create(WatchCreateRequest(
    url="https://api-provider.com/docs/changelog",
    frequency="daily",
    notify_email="[email protected]",
    notification_preference="changes_only",
    include_html=True
))

Error Handling

try:
    watch = client.watch_create(WatchCreateRequest(
        url="https://example.com",
        frequency="hourly",
        notify_email="[email protected]"
    ))
    
    print(f"✅ watch created: {watch.watch_id}")
    
except Exception as e:
    print(f"❌ failed to create watch: {e}")

# Handle watch operations
try:
    details = client.watch_get(watch.watch_id)
    print(f"watch status: {details.watch.status}")
except Exception as e:
    print(f"failed to get watch: {e}")

Next Steps

Was this page helpful?