Four parts take a Scraper from code to a result:
The Definition
A Definition is the Scraper's contract: an ID, an input schema, an output schema and the errors it can fail with.
export const Quotes = Scraper.make("quotes", {
error: Schema.Union([Blocked, RateLimited, SchemaDrift, UpstreamDown]),
input: QuotesQuery,
output: Quote,
});Everything a caller needs is derived from it: the typed client, the JSON Schemas in the instance catalog and the MCP tool schemas. Nothing is written twice.
The Implementation
An Implementation is the code that does the scraping. It is an Effect Layer that turns one input into a stream of items.
The Layer's type lists what the code needs to run. Scwrap calls these needs Capabilities:
const QuotesApiLive: Layer.Layer<Rpc.Handler<"quotes">, never, HttpClient.HttpClient>This Implementation needs an HttpClient and nothing else. One that drives a browser needs a Browser. One Definition can have several Implementations, for example an API reader and a browser reader.
The Release
A Release is one deployable build of one Scraper. It names the Definition, picks one Implementation and provides every Capability that Implementation needs.
export default Deployment.worker({
implementation: QuotesApiLive,
module: import.meta.url,
scraper: Quotes,
services: FetchHttpClient.layer,
});An instance supplies no Capabilities of its own. If services leaves one out, the Release does not compile.
Every Release is a Worker release, declared with Deployment.worker. The instance runs each in its own Dynamic Worker sandbox, whether it uses fetch, a proxy route or a browser.
The instance
An instance is a private Scwrap installation in one Cloudflare account: a release Worker, a controller Worker that deploys it and two R2 buckets: one for artifacts and docs, one for Run results. You deploy Releases into it with the scwrap CLI, from your own repository. Several repositories can deploy to one instance: each deploys its own catalog of Releases.
When a caller runs a Scraper, the instance:
- Checks the input against the Definition. Invalid input never reaches your code.
- Runs the Implementation in the Release's own sandbox.
- Checks every item against the output schema and stores it in R2.
- Stores a result record with the status, the item count and the Release that produced it.
One execution for one input is a Run. A Run that fails after delivering items keeps them: the caller sees a failed result and the items that were checked before the failure.
Terms
| Term | Meaning |
|---|---|
| Scraper | A named job that turns one input into a stream of items. A Definition plus at least one Implementation. |
| Definition | The contract: ID, input, output and error schemas. |
| Implementation | An Effect Layer that fulfils a Definition. Its type lists its Capabilities. |
| Capability | A service an Implementation needs and its Release provides, such as an HTTP client, a proxy route or a browser. |
| Release | One immutable build of one Scraper on an instance. |
| Instance | A release Worker, a controller Worker and two R2 buckets in one Cloudflare account. |
| Run | One execution of a Scraper for one input. |
| Shared error | A failure every Scraper may declare, such as Blocked or RateLimited. |
The glossary has the full list.
Next
Installation sets up your Scraper repository. Then Your first Scraper builds the quotes Scraper shown above.