Skip to main content

Watch Endpoint

Set up URL monitoring in a single API call. The watch endpoint combines strategy generation and schedule creation, eliminating the need for multi-step orchestration.

Create watch

Create a new watch to monitor a URL for changes.
POST /api/watch

Request body

{
  "url": "https://example.com/products",
  "description": "Extract product names and prices",
  "webhook_url": "https://your-app.com/webhooks/meter",
  "interval_seconds": 3600,
  "name": "Product Monitor"
}
FieldTypeRequiredDescription
urlstringYesURL to monitor for changes
descriptionstringYesWhat to extract from the page
webhook_urlstringNoWebhook URL for change notifications
interval_secondsintegerNoHow often to check (default: 3600, minimum: 60)
namestringNoName for the strategy (auto-generated if not provided)

Response

{
  "strategy_id": "550e8400-e29b-41d4-a716-446655440000",
  "schedule_id": "880e8400-e29b-41d4-a716-446655440000",
  "preview_data": [
    {"name": "Product A", "price": "$19.99"},
    {"name": "Product B", "price": "$29.99"}
  ],
  "next_run_at": "2025-01-15T10:30:00Z"
}
FieldTypeDescription
strategy_idUUIDID of the created extraction strategy
schedule_idUUIDID of the created schedule
preview_dataarraySample data extracted from the URL
next_run_atdatetimeWhen the first scheduled scrape will run

Example

curl -X POST https://api.meter.sh/api/watch \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://news.ycombinator.com",
    "description": "Extract post titles, scores, and links",
    "webhook_url": "https://my-app.com/webhook",
    "interval_seconds": 1800
  }'

What happens internally

The watch endpoint performs two operations in a single transaction:
  1. Generates a strategy - Analyzes the page and creates extraction selectors using AI
  2. Creates a schedule - Sets up recurring scrapes with your specified interval
This is equivalent to calling:
# Step 1: Generate strategy
POST /api/strategies/generate

# Step 2: Create schedule with the strategy_id
POST /api/schedules

Managing your watch

After creation, use the standard endpoints to manage your watch:
  • Update schedule: PATCH /api/schedules/{schedule_id}
  • Pause/resume: PATCH /api/schedules/{schedule_id} with {"enabled": false}
  • Get changes: GET /api/schedules/{schedule_id}/changes
  • Delete: DELETE /api/schedules/{schedule_id}
  • Refine strategy: POST /api/strategies/{strategy_id}/refine

Error responses

StatusDescription
400Invalid request (missing required fields, interval too short)
401Invalid or missing API key
429Rate limit exceeded (watch endpoint is rate-limited)
500Internal server error
503Service temporarily unavailable (AI service issues)
See REST API Errors for detailed error handling.

Next steps

Need help?

Email me at [email protected]