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

# Synchronous scrape

> The `scrape` endpoint runs a browser session, executes JavaScript, and returns rendered HTML in a single synchronous request.

## Getting started

### Base URL

```
https://scrape.cleariflow.com/v1/scrape
```

### Example request

```bash theme={"system"}
curl -X POST 'https://scrape.cleariflow.com/v1/scrape' \
  -H 'Content-Type: application/json' \
  -d '{
    "api_key": "YOUR_UNIQUE_API_KEY",
    "url": "https://example.com",
    "render": {
      "wait_until": "networkidle",
      "timeout_ms": 60000
    }
  }'
```

This successful request returns the rendered page HTML and metadata:

```json theme={"system"}
{
  "ok": true,
  "html": "<!DOCTYPE html><html>...</html>",
  "meta": {
    "elapsed_ms": 4521
  }
}
```

### Render options

The `render` object controls how the browser loads the page before HTML is captured. All fields are optional — when omitted, server defaults apply.

```json theme={"system"}
{
  "render": {
    "wait_until": "networkidle",
    "timeout_ms": 60000,
    "post_load_wait_ms": 2000,
    "ignore_https_errors": false
  }
}
```

| Field | Type | Default | Description |
| - | - | - | - |
| `wait_until` | String | `domcontentloaded` | When to consider navigation finished. Use `domcontentloaded` for faster results; use `networkidle` when the page loads data via XHR/fetch after the initial HTML. |
| `timeout_ms` | Integer | `60000` | Maximum time in milliseconds to wait for page load. The request fails if navigation exceeds this limit. |
| `post_load_wait_ms` | Integer | `0` | Extra delay in milliseconds after `wait_until` before capturing HTML. Useful for animations, lazy-loaded widgets, or client-side rendering that continues after `networkidle`. |
| `ignore_https_errors` | Boolean | `false` | When `true`, ignore TLS certificate errors on the target page. |

Example for a JavaScript-heavy page that keeps fetching data after load:

```bash theme={"system"}
curl -X POST 'https://scrape.cleariflow.com/v1/scrape' \
  -H 'Content-Type: application/json' \
  -d '{
    "api_key": "YOUR_UNIQUE_API_KEY",
    "url": "https://quotes.toscrape.com/js/",
    "render": {
      "wait_until": "networkidle",
      "timeout_ms": 60000,
      "post_load_wait_ms": 1500,
      "ignore_https_errors": false
    }
  }'
```

### Resource options

The `resources` object controls which asset types the browser loads during scraping. Blocking heavy assets speeds up requests when you only need HTML text and structure.

```json theme={"system"}
{
  "resources": {
    "block": ["images", "fonts", "media"]
  }
}
```

| Value | Blocks |
| - | - |
| `images` | Images (`<img>`, CSS backgrounds, SVG icons loaded as images) |
| `fonts` | Web fonts |
| `media` | Video and audio streams |

All fields are optional. When `resources` is omitted, no resource types are blocked unless your deployment sets server-side defaults.

Example — scrape faster by skipping images and fonts:

```bash theme={"system"}
curl -X POST 'https://scrape.cleariflow.com/v1/scrape' \
  -H 'Content-Type: application/json' \
  -d '{
    "api_key": "YOUR_UNIQUE_API_KEY",
    "url": "https://quotes.toscrape.com/",
    "resources": {
      "block": ["images", "fonts"]
    }
  }'
```

### Request parameters

**url** `String` *required*

The target URL to scrape. Must be a public HTTP or HTTPS URL. Requests to localhost and private IP addresses are blocked by SSRF protection.

**api\_key** `String` *required*

Your unique API key.

**session\_id** `String`

Optional session identifier to reuse browser state (cookies, local storage) across multiple scrape requests.

**fingerprint** `String`

Browser fingerprint preset. Supported values: `desktop_en_us`, `desktop_ru_ru`, `mobile_en_us`.

**render** `Object`

Rendering options for the browser session.

**render.wait\_until** `String`

When to consider navigation finished. Values: `domcontentloaded`, `networkidle`. Defaults to `domcontentloaded`.

**render.timeout\_ms** `Integer`

Maximum time in milliseconds to wait for page load. Defaults to 60000.

**render.post\_load\_wait\_ms** `Integer`

Additional delay in milliseconds after the page load event before capturing content.

**render.ignore\_https\_errors** `Boolean`

When `true`, ignore TLS certificate errors for the target page.

**resources** `Object`

Resource loading controls.

**resources.block** `Array`

Resource types to block. Supported values: `images`, `fonts`, `media`.

**actions** `Array`

Ordered list of browser actions to perform before capturing content. Each action is an object with a `type` field.

**actions\[].type** `String` *required*

Action type. Supported values: `wait`, `wait_for`, `click`, `type`, `scroll`.

**actions\[].selector** `String`

CSS selector for `wait_for`, `click`, or `type` actions.

**actions\[].text** `String`

Text to type for the `type` action.

**actions\[].to** `String`

Scroll target for the `scroll` action (e.g. `bottom`).

**actions\[].wait\_ms** `Integer`

Duration in milliseconds for the `wait` action.

**actions\[].timeout\_ms** `Integer`

Timeout in milliseconds for `wait_for` actions.

**cookies** `Array`

Cookies to inject before navigation. Each cookie object requires `name` and `value`; optional fields: `domain`, `path`.

### Response parameters

The API response is returned in a universal and lightweight [JSON format](https://www.json.org/json-en.html).

**ok** `Boolean`

Whether the scrape completed successfully.

**html** `String`

The rendered page HTML.

**meta** `Object`

Metadata about the scrape, including final URL, HTTP status code, and duration.

**error** `Object`

Error details when `ok` is `false`.


## OpenAPI

````yaml openapi/scrape.json POST /v1/scrape
openapi: 3.0.3
info:
  title: Web Scraping API (Browser-as-a-Service)
  version: 1.0.0
  description: High-load browser scraping API backed by Camoufox workers.
servers:
  - url: https://scrape.cleariflow.com
    description: Production server
security: []
paths:
  /v1/scrape:
    post:
      summary: Synchronous scrape (Camoufox)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScrapeRequest'
      responses:
        '200':
          description: Scrape result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScrapeResponse'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '422':
          description: Quota reached
        '429':
          description: Too many requests
        '500':
          description: Internal server error
components:
  schemas:
    ScrapeRequest:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
        api_key:
          type: string
          description: Your Cleariflow API key, passed in the JSON request body.
        session_id:
          type: string
        fingerprint:
          type: string
          description: Preset string (desktop_en_us|desktop_ru_ru|mobile_en_us|...)
        render:
          $ref: '#/components/schemas/RenderOptions'
        resources:
          $ref: '#/components/schemas/ResourceOptions'
        actions:
          type: array
          items:
            $ref: '#/components/schemas/Action'
        artifacts:
          type: array
          items:
            type: string
            enum:
              - html
              - screenshot
        cookies:
          type: array
          items:
            $ref: '#/components/schemas/Cookie'
    ScrapeResponse:
      type: object
      properties:
        ok:
          type: boolean
        html:
          type: string
        artifacts:
          type: object
          additionalProperties: true
        meta:
          type: object
          additionalProperties: true
        error:
          type: object
          additionalProperties: true
    RenderOptions:
      type: object
      properties:
        wait_until:
          type: string
          enum:
            - domcontentloaded
            - networkidle
        timeout_ms:
          type: integer
        post_load_wait_ms:
          type: integer
    ResourceOptions:
      type: object
      properties:
        block:
          type: array
          items:
            type: string
            enum:
              - images
              - fonts
              - media
    Action:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - wait
            - wait_for
            - click
            - type
            - scroll
        selector:
          type: string
        text:
          type: string
        to:
          type: string
        wait_ms:
          type: integer
        timeout_ms:
          type: integer
    Cookie:
      type: object
      required:
        - name
        - value
      properties:
        path:
          type: string
        value:
          type: string
        name:
          type: string
        domain:
          type: string

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.