More endpoints
Monitors

Monitors

Automatic runs are not switched on yet. You can create, change and read monitors today, and a run happens when you call POST /v1/monitors/{id}/run (from your own scheduler, for example). The cadence field is stored now; the scheduled checks it sets are coming soon.

A monitor will check one page and tell you what changed since the last check. Use kind: "page" to compare the page text, or kind: "extract" to compare a list of records (products, listings, job posts) field by field.

EndpointDescription
POST /v1/monitorsCreate a monitor
GET /v1/monitorsList monitors
GET /v1/monitors/{id}Read one monitor
PATCH /v1/monitors/{id}Change name, cadence, active, webhook or target
DELETE /v1/monitors/{id}Delete a monitor
POST /v1/monitors/{id}/runRun it now and get the diff
GET /v1/monitors/{id}/runsRun history
GET /v1/monitors/{id}/runs/{runId}One run with its full diff
POST /v1/monitors/{id}/rotate-secretNew webhook signing secret

Create a monitor

curl -X POST https://api.superscraper.dev/v1/monitors \
  -H "x-api-key: YOUR_KEY" \
  -H "content-type: application/json" \
  -d '{
    "name": "Competitor prices",
    "kind": "extract",
    "url": "https://shop.example.com/catalog",
    "cadence": "daily",
    "selectors": {
      "item": "li.product",
      "fields": {
        "name": "h2",
        "url": { "selector": "a", "attr": "href" },
        "price": ".price"
      }
    },
    "key": "url",
    "webhook": "https://your-app.example.com/hooks/monitors"
  }'
FieldTypeDescription
namestringRequired. 1 to 120 characters.
urlstringRequired. A public http(s) page.
kindpage or extractDefault page.
cadencehourly, daily, weekly, monthlyDefault daily. How often automatic checks will run once scheduled runs are switched on (coming soon).
selectorsobjectextract only. item is the CSS selector of each repeating element; fields maps a field name to a selector inside it (text), or to { "selector", "attr" } to read an attribute. Up to 20 fields. Without selectors, the record is the page's structured data.
keystringextract only. The field that identifies a record between runs. Without it, url is used, then the whole record.
onlyMainContentbooleanpage only. Default true: navigation, headers and footers are left out of the comparison.
webhookstringA public http(s) URL that receives monitor.changed.
activebooleanDefault true.

The response holds the monitor and, when you set a webhook, webhook_secret. Store the secret: it is shown only here and when you rotate it.

What a run returns

The first run records a baseline and reports no change. Every later run compares with the previous successful run.

For an extract monitor the diff lists added and removed records and, under modified, each changed record with its fields:

{
  "type": "records",
  "baseline": false,
  "changed": true,
  "counts": { "added": 1, "removed": 0, "changed": 1, "unchanged": 48, "total": 50 },
  "added": [{ "key": "url:/p/new-item", "record": { "name": "New item", "url": "/p/new-item", "price": "$19" } }],
  "removed": [],
  "modified": [{ "key": "url:/p/widget", "fields": [{ "field": "price", "before": "$10", "after": "$12" }] }],
  "truncated": false
}

For a page monitor the diff lists the lines that were added and removed. Whitespace changes are ignored.

{
  "type": "page",
  "changed": true,
  "counts": { "added_lines": 1, "removed_lines": 1 },
  "added_lines": ["Pro plan: $12 per month"],
  "removed_lines": ["Pro plan: $10 per month"]
}

Each list holds at most 100 entries (200 lines); counts are always exact and truncated tells you when a list was cut.

A run fails, costs nothing and keeps the previous baseline when the page cannot be fetched, when selectors match no items (usually a changed page layout), or when the page could not be read in full (run.reason is page_too_large: the download was over 20 MB, the HTML was over 2 MB after scripts and styles, it was nested too deep to parse, or its conversion ran out of time). A page that is only partly read is never compared with the baseline, so it cannot report a change that did not happen. run.status is completed, failed or skipped, and run.reason says why a run failed or was skipped.

Pricing

Each successful run costs 1 credit. A failed run costs nothing. When your balance cannot cover a run, POST /v1/monitors/{id}/run answers HTTP 402 insufficient_credits and nothing is charged.

Webhooks

When a run finds a change and the monitor has a webhook, SuperScraper sends a POST:

X-SuperScraper-Event: monitor.changed
X-SuperScraper-Timestamp: 1791000000
X-SuperScraper-Signature: sha256=5d41402abc4b2a76b9719d911017c592...
{
  "event": "monitor.changed",
  "timestamp": 1791000000,
  "data": {
    "delivery_id": "mdl_6f1c...",
    "monitor_id": "1b7e...",
    "run_id": "6f1c...",
    "name": "Competitor prices",
    "kind": "extract",
    "url": "https://shop.example.com/catalog",
    "changed": true,
    "diff": { "type": "records", "changed": true }
  }
}

Each monitor signs with its own secret. To verify a delivery:

  1. Compute HMAC-SHA256 with your webhook_secret over {timestamp}.{raw body}, using the X-SuperScraper-Timestamp header and the body exactly as received.
  2. Compare sha256=<hex> with X-SuperScraper-Signature using a constant-time comparison.
  3. Reject the delivery when the timestamp is more than 5 minutes from your clock.
  4. Reject a delivery_id you have already processed. A retry of the same delivery keeps its id.
import { createHmac, timingSafeEqual } from 'node:crypto';
 
function verify(rawBody, headers, secret, seen) {
  const ts = Number(headers['x-superscraper-timestamp']);
  const expected = `sha256=${createHmac('sha256', secret).update(`${ts}.${rawBody}`).digest('hex')}`;
  const given = String(headers['x-superscraper-signature'] ?? '');
  if (expected.length !== given.length || !timingSafeEqual(Buffer.from(expected), Buffer.from(given))) return false;
  if (Math.abs(Date.now() / 1000 - ts) > 300) return false;
  const id = JSON.parse(rawBody).data?.delivery_id;
  if (!id || seen.has(id)) return false;
  seen.add(id);
  return true;
}

POST /v1/monitors/{id}/rotate-secret returns a new secret; the old one stops verifying at once. Webhook deliveries appear in the dashboard request log.

Teams and keys

An owner manages every monitor of the account. A team member sees and manages the monitors they created, and an API key a member created acts as that member. Another account's monitor answers HTTP 404.

A key restricted with scopes needs the monitor scope. See Privacy and key restrictions.

Zero data retention

A monitor stores each result so the next run can compare against it. With zero data retention on for the key or the account, creating, changing and running a monitor answer HTTP 400 zdr_unsupported. Reading and deleting monitors still work.

Errors

StatusCodeMeaning
400invalid_url, blocked_url, invalid_selectors, invalid_key, invalid_cadence, invalid_webhookThe request is not valid
400zdr_unsupportedZero data retention is on
402insufficient_creditsNot enough credits for a run
404monitor_not_foundNo such monitor for this account (or for this team member)
409monitor_run_in_progressA run of this monitor is in progress
409monitor_limit_reachedThe account holds the maximum number of monitors (50)
503monitors_unavailable, webhook_signing_unavailableRetry shortly