> ## Documentation Index
> Fetch the complete documentation index at: https://docs-preview.webcompute.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK quick actions reference

> Reference deterministic SDK quick actions for scrape, screenshot, and PDF generation, including options, responses, policy, and proxy support.

Quick actions create an ephemeral browser for one deterministic operation. They are useful when you do not need a persistent browser handle or a model-backed agent.

```ts theme={null}
const page = await web.scrape({
  url: "https://www.sec.gov/edgar/search/",
  format: "markdown",
  maxChars: 20_000,
  policy: { allowedDomains: ["sec.gov"] },
});
```

All quick actions accept `policy`. All quick actions also accept `proxy`, which routes the ephemeral browser through a custom proxy URL.

## `web.scrape()`

```ts theme={null}
web.scrape(options: string | ScrapeOptions): Promise<ScrapeResponse>
```

Pass a URL string for the default markdown read:

```ts theme={null}
const result = await web.scrape("https://example.com");
```

Use `ScrapeOptions` for control:

| Field           | Type                             | Default                            | Description                                                          |
| --------------- | -------------------------------- | ---------------------------------- | -------------------------------------------------------------------- |
| `url`           | `string`                         | Required                           | URL to read.                                                         |
| `format`        | `"html" \| "markdown" \| "text"` | `markdown`                         | Returned content format.                                             |
| `selector`      | `string`                         | None                               | CSS selector that scopes page content.                               |
| `iframe`        | `string`                         | None                               | CSS selector of a specific iframe to target.                         |
| `waitFor`       | `string`                         | None                               | CSS selector to wait for before reading.                             |
| `timeout`       | `number`                         | `30000`                            | Total operation timeout in milliseconds.                             |
| `maxChars`      | `number`                         | `20000`                            | Soft cap on returned content characters. Maximum is `50000`.         |
| `startFromChar` | `number`                         | `0`                                | Zero-based content character offset for continuing a truncated read. |
| `readFrom`      | `"start" \| "end"`               | `start`                            | Read window direction.                                               |
| `includeLinks`  | `boolean`                        | `false`                            | Include deterministic anchor links.                                  |
| `iframeText`    | `boolean`                        | `false`                            | When `format` is not `html`, append iframe text to content.          |
| `proxy`         | `string`                         | None                               | Proxy URL for the ephemeral browser.                                 |
| `policy`        | `BrowserNavigationPolicy`        | Client-level policy, if configured | Browser navigation policy for the read.                              |

`ScrapeResponse`:

| Field          | Description                                      |
| -------------- | ------------------------------------------------ |
| `v`            | Response version. Current value is `1`.          |
| `url`          | Final URL.                                       |
| `title`        | Page title.                                      |
| `format`       | Returned format.                                 |
| `content`      | Primary deterministic read content.              |
| `provenance`   | Read source and scoping metadata.                |
| `diagnostics`  | Read threshold and fallback diagnostics.         |
| `completeness` | Ratio and cap/pruning diagnostics.               |
| `statusCode`   | Page HTTP status code.                           |
| `links`        | Deterministic links when `includeLinks` is true. |
| `truncated`    | Whether `content` was clamped to `maxChars`.     |
| `charsOmitted` | Omitted UTF-16 code units when truncated.        |
| `warnings`     | Structured warnings.                             |
| `tips`         | Browser policy tips.                             |
| `elapsedMs`    | Browser-side elapsed time.                       |

## `web.screenshot()`

```ts theme={null}
web.screenshot(options: ScreenshotOptions): Promise<ScreenshotResponse>
```

```ts theme={null}
const shot = await web.screenshot({
  url: "https://example.com/dashboard",
  fullPage: true,
  format: "png",
});
```

`ScreenshotOptions`:

| Field           | Type                        | Default                            | Description                                                   |
| --------------- | --------------------------- | ---------------------------------- | ------------------------------------------------------------- |
| `url`           | `string`                    | Required                           | URL to capture.                                               |
| `fullPage`      | `boolean`                   | `false`                            | Capture the full scrollable page.                             |
| `format`        | `"png" \| "jpeg" \| "webp"` | `png`                              | Image format.                                                 |
| `quality`       | `number`                    | `80`                               | Image quality for `jpeg` and `webp`.                          |
| `selector`      | `string`                    | None                               | CSS selector of a specific element to capture.                |
| `hideSelectors` | `string[]`                  | None                               | CSS selectors hidden with `visibility:hidden` during capture. |
| `maskSelectors` | `string[]`                  | None                               | CSS selectors covered by screenshot masks.                    |
| `maskColor`     | `string`                    | None                               | Mask color.                                                   |
| `style`         | `string`                    | None                               | Temporary screenshot-only CSS.                                |
| `waitFor`       | `string`                    | None                               | CSS selector to wait for before capture.                      |
| `timeout`       | `number`                    | `30000`                            | Total operation timeout in milliseconds.                      |
| `proxy`         | `string`                    | None                               | Proxy URL for the ephemeral browser.                          |
| `policy`        | `BrowserNavigationPolicy`   | Client-level policy, if configured | Browser navigation policy for capture.                        |

`ScreenshotResponse`:

| Field       | Description                      |
| ----------- | -------------------------------- |
| `url`       | Final URL.                       |
| `data`      | Base64-encoded image data.       |
| `format`    | Image format.                    |
| `width`     | Image width.                     |
| `height`    | Image height.                    |
| `elapsedMs` | Browser-side elapsed time.       |
| `artifact`  | Sensitivity and export metadata. |
| `tips`      | Browser policy tips.             |
| `_meta`     | Quick-action metadata.           |

## `web.pdf()`

```ts theme={null}
web.pdf(options: PdfOptions): Promise<PdfResponse>
```

```ts theme={null}
const pdf = await web.pdf({
  url: "https://example.com/report",
  format: "Letter",
  landscape: false,
});
```

`PdfOptions`:

| Field             | Type                                                           | Default                            | Description                                     |
| ----------------- | -------------------------------------------------------------- | ---------------------------------- | ----------------------------------------------- |
| `url`             | `string`                                                       | Required                           | URL to render.                                  |
| `format`          | `"A4" \| "Letter" \| "A3" \| "Tabloid" \| "Ledger" \| "Legal"` | `A4`                               | Paper size.                                     |
| `landscape`       | `boolean`                                                      | `false`                            | Use landscape orientation.                      |
| `printBackground` | `boolean`                                                      | `true`                             | Print background graphics.                      |
| `waitFor`         | `string`                                                       | None                               | CSS selector to wait for before PDF generation. |
| `timeout`         | `number`                                                       | `30000`                            | Total operation timeout in milliseconds.        |
| `proxy`           | `string`                                                       | None                               | Proxy URL for the ephemeral browser.            |
| `policy`          | `BrowserNavigationPolicy`                                      | Client-level policy, if configured | Browser navigation policy for rendering.        |

`PdfResponse`:

| Field       | Description                |
| ----------- | -------------------------- |
| `url`       | Final URL.                 |
| `data`      | Base64-encoded PDF data.   |
| `pages`     | Page count.                |
| `elapsedMs` | Browser-side elapsed time. |
| `tips`      | Browser policy tips.       |
| `_meta`     | Quick-action metadata.     |

## Proxy example

```ts theme={null}
const result = await web.scrape({
  url: "https://example.com",
  proxy: process.env.RESIDENTIAL_PROXY_URL,
});
```

Proxy credentials can appear inside URLs. Keep proxy URLs in environment variables and avoid logging request objects directly.
