A deployed Scraper has no schedule and no trigger of its own. It runs when someone calls it. Any program or agent with the instance's run token can do that, in three ways.
| Way | Use it when |
|---|---|
| Typed client | You write TypeScript with Effect and want inputs and items typed by the Definition. |
| Plain HTTPS | You call from another language or from a shell. |
| MCP | An AI agent runs the Scraper. |
All three do the same thing. A call starts a Run and returns a result record with its result ID. The Run continues on the instance whether or not the caller stays; the caller reads the record until it ends, then the items, by result ID.
With the typed client
@scwrap/client takes the Definition and gives you a typed stream of items that fails with the Scraper's own errors. Import the Definition from the Scraper's ./schema entry point, which carries the contract without the scraping code.
Example (Running quotes and reading its items)
import { createClient } from "@scwrap/client";
import { Quotes } from "@scwrap/quotes/schema";
import { Config, Console, Effect, Stream } from "effect";
import { FetchHttpClient } from "effect/http";
const program = Effect.gen(function* callQuotes() {
const client = yield* createClient({
instance: yield* Config.String("SCWRAP_INSTANCE_URL"),
token: yield* Config.Redacted("SCWRAP_INSTANCE_RUN_TOKEN"),
});
yield* client.scraper(Quotes).stream({ maxPages: 2 }).pipe(
Stream.runForEach((quote) => Console.log(quote.author)),
Effect.catchTag("RateLimited", ({ reason }) => Console.log(reason))
);
}).pipe(Effect.provide(FetchHttpClient.layer));
await Effect.runPromise(program);stream starts the Run, waits for it to end and streams its items. It accepts only a valid encoded QuotesQuery, quote is a Quote, and a failed Run fails the Stream with one of the Definition's errors. There is no generated client: the types come straight from the Definition.
Items are checked against your Definition
The client decodes every item with your Quote schema and fails on one that does not match, such as an item with a field your Definition does not know. The result record's revision and digest name the build that produced it.
Keeping the result ID
stream hides the result ID. When you want to keep it, run starts the Run and returns its result record; start returns as soon as the Run has started. A Run that fails on the instance is still a record, with status: "failed", an error string and, for a declared error, its encoded failure.
const result = yield* client.scraper(Quotes).run({ maxPages: 2 });
if (result.status === "failed") {
yield* Console.log(result.error);
}The items delivered before the failure are stored, and items(result.resultId) reads them. Check status before you treat the items as complete.
With plain HTTPS
Every request carries the run token as a bearer token.
Example (Running quotes with curl)
curl -sS -X POST "$SCWRAP_INSTANCE_URL/scrapers/quotes/run" \
-H "Authorization: Bearer $SCWRAP_INSTANCE_RUN_TOKEN" \
-H "content-type: application/json" \
-d '{"maxPages": 2}'The body is the raw JSON input. The answer, status 202, is the running result record. Read it again by result ID until status is completed or failed:
curl -sS "$SCWRAP_INSTANCE_URL/results/<resultId>" \
-H "Authorization: Bearer $SCWRAP_INSTANCE_RUN_TOKEN"{
"count": 20,
"digest": "…",
"endedAt": 1795100000000,
"error": null,
"implementationDigest": "…",
"input": { "maxPages": 2 },
"resultId": "…",
"revision": "v1",
"scraper": "quotes",
"startedAt": 1795099990000,
"status": "completed"
}Then read the items as NDJSON, one quote per line:
curl -sS "$SCWRAP_INSTANCE_URL/results/<resultId>/items" \
-H "Authorization: Bearer $SCWRAP_INSTANCE_RUN_TOKEN"| Status | Meaning |
|---|---|
| 202 | The Run started. The body is its running record. |
| 400 | The input does not match the Definition. Nothing ran. |
| 401 | The token is missing or wrong. |
HTTP API lists every route.
With MCP
The instance serves an MCP server at /mcp. Connect it in your agent as a remote MCP server with the header Authorization: Bearer <run token>.
An agent then works in a few calls:
list_scrapersreturns the installed Releases and the instance's generation.get_scraperreturns the input, output and error JSON Schemas ofquotes, derived from the Definition.run_scraperstarts it with a JSON input. A Run that ends within 20 seconds returns the result record with the first page of items; a longer one returns itsrunningrecord, and the agent pollsget_run.get_run_itemsreturns the next page, for a result of more than 100 items or 64 KiB.
MCP server describes each tool and its limits.
Three things to remember
WARNING
Retry a lost Run only with an idempotency key. A Run whose response was lost may already have run. Pass { idempotencyKey } to start, run or stream (the Idempotency-Key header over HTTP, idempotencyKey in MCP) and retry with the same key: the instance returns the original Run for 24 hours. Without a key, retrying can run the Scraper twice.
- Results expire. An instance keeps a Run's record and items for 30 days unless its owner sets another retention.
GET /scrapers/<id>/runs,client.scraper(D).runs()and MCPlist_runslist a Scraper's recent Runs, newest first. - The run token runs everything installed. Whoever holds it can run every Scraper and read every result, but cannot deploy. Use it from servers and agents you trust, never from a browser.
Next
quotes is written, tested, deployed and called. The next two guides grow it without changing its Definition: Adding a proxy and Adding a browser.