spicrawlspicrawlDocs
Monitors

Create a monitor

Starts watching one page, or with `scope: "site"` every page reachable from `url` on its exact host.

Requires scope: monitors

POST
/v1/monitors

Starts watching one page, or with scope: "site" every page reachable from url on its exact host. The first successful check records a baseline and reports no change. Later checks report a change when the watched content differs from the last accepted version, after confirm_checks checks in a row agree on the new version.

What is compared is the main content of the page, or the text of every element matched by selector. The content is normalised first (runs of whitespace collapse, lines are trimmed, empty lines drop), so layout churn does not count as a change.

interval_seconds defaults to the plan minimum and must be at least that. The interval adapts between the plan minimum and the value you set: it shortens while the page changes and lengthens while it does not. See current_interval_seconds.

Each check bills the same credits as the scrape that performed it: 1 credit for a plain fetch, more with js_render. Checks are billed to the API key that created the monitor, and that key must stay valid.

webhook_endpoint_id must name an endpoint of this organization. Notifications go to it as monitor.changed and monitor.failed, if those events are in its events.

A site monitor (scope: "site") needs max_pages. Each run discovers the site's pages from robots.txt, its sitemaps or the start page's links, fetches the changed ones and sends one monitor.changed digest for the run. confirm_checks is ignored for site monitors. Each fetched page, each sitemap file and robots.txt is a plain scrape call and is billed as one (a 404 is not charged); changing selector or js_render clears the stored pages, so the next run is a new baseline; a page skipped by its sitemap lastmod costs nothing. The Monitors section of the API reference has the rules.

Plan limits: the number of monitors and the minimum interval depend on the plan. See the Monitors section of the API reference.

Authorization

bearerAuth
AuthorizationBearer <token>

Authorization: Bearer <key>. Read the key from the SPICRAWL_API_KEY environment variable; never hard-code or log it. spicrawl_test_… keys can never spend live credits. Scopes: scrape, batch, sessions (granted by default), browser and read (granted deliberately), and partner (only on a partner account's key). A missing scope is 403 ERR::AUTH::INSUFFICIENT_SCOPE naming the scope.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Body of POST /v1/monitors. Unknown fields are a 400.

Response Body

application/json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

curl -X POST "https://example.com/v1/monitors" \  -H "Content-Type: application/json" \  -d '{    "url": "https://example.com/pricing",    "name": "pricing-page",    "interval_seconds": 3600,    "webhook_endpoint_id": "0190f3a2-7c1e-7d4b-9a2f-3b8e5c6d7e80"  }'
{  "id": "0190f5c4-2b7a-7e10-8d3f-6a1c9e4b2d70",  "name": "string",  "url": "http://example.com",  "selector": "string",  "js_render": true,  "interval_seconds": 60,  "current_interval_seconds": 0,  "confirm_checks": 1,  "webhook_endpoint_id": "string",  "enabled": true,  "disabled_reason": "string",  "last_error": "string",  "last_checked_at": "2019-08-24T14:15:22Z",  "last_changed_at": "2019-08-24T14:15:22Z",  "next_check_at": "2019-08-24T14:15:22Z",  "consecutive_failures": 0,  "created_at": "2019-08-24T14:15:22Z",  "updated_at": "2019-08-24T14:15:22Z",  "scope": "page",  "max_pages": 1,  "include_paths": [    "string"  ],  "exclude_paths": [    "string"  ],  "max_credits_per_run": 1,  "pages_tracked": 0,  "last_run": {    "checked": 0,    "skipped": 0,    "changed": 0,    "added": 0,    "removed": 0,    "credits": 0,    "truncated": true  }}