Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,26 @@ import { Tabs, TabItem, Render } from "~/components";

The `/content` endpoint instructs the browser to navigate to a website and capture the fully rendered HTML of a page, including the `head` section, after JavaScript execution. This is ideal for capturing content from JavaScript-heavy or interactive websites.

## Endpoint

```txt
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/content
```

## Required fields
You must provide either `url` or `html`:
- `url` (string)
- `html` (string)

## Common use cases

- Capture the fully rendered HTML of a dynamic page
- Extract HTML for parsing, scraping, or downstream processing

## Basic usage

### Fetch rendered HTML from a URL

<Tabs syncKey="workersExamples"> <TabItem label="curl">

Go to `https://developers.cloudflare.com/` and return the rendered HTML.
Expand Down Expand Up @@ -43,6 +61,8 @@ console.log(content);

## Advanced usage

### Block specific resource types

Navigate to `https://cloudflare.com/` but block images and stylesheets from loading. Undesired requests can be blocked by resource type (`rejectResourceTypes`) or by using a regex pattern (`rejectRequestPattern`). The opposite can also be done, only allow requests that match `allowRequestPattern` or `allowResourceTypes`.

```bash
Expand Down
25 changes: 23 additions & 2 deletions src/content/docs/browser-rendering/rest-api/json-endpoint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,33 @@ By default, the `/json` endpoint leverages [Workers AI](/workers-ai/) for data e

:::

## Basic Usage
## Endpoint

<Tabs syncKey="workersExamples"> <TabItem label="curl">
```txt
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/json
```

## Required fields
You must provide either `url` or `html`:
- `url` (string)
- `html` (string)

And at least one of:
- `prompt` (string), or
- `response_format` (object with a JSON Schema)

## Common use cases

- Extract product info (title, price, availability) or listings (jobs, rentals)
- Normalize article metadata (title, author, publish date, canonical URL)
- Convert unstructured pages into typed JSON for downstream pipelines

## Basic Usage

### With a Prompt and JSON schema

<Tabs syncKey="workersExamples"> <TabItem label="curl">

This example captures webpage data by providing both a prompt and a JSON schema. The prompt guides the extraction process, while the JSON schema defines the expected structure of the output.

```bash
Expand Down
20 changes: 19 additions & 1 deletion src/content/docs/browser-rendering/rest-api/links-endpoint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ import { Tabs, TabItem, Render } from "~/components";

The `/links` endpoint retrieves all links from a webpage. It can be used to extract all links from a page, including those that are hidden.

## Endpoint

```txt
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/links
```

## Required fields
You must provide either `url` or `html`:
- `url` (string)

## Common use cases

- Collect only user-visible links for UX or SEO analysis
- Crawl a site by discovering links on seed pages
- Validate navigation/footers and detect broken or external links

## Basic usage

### Get all links on a page

<Tabs syncKey="workersExamples"> <TabItem label="curl">

This example grabs all links from the Cloudflare Developers homepage.
This example grabs all links from the [Cloudflare Developer's homepage](https://developers.cloudflare.com/).
The response will be a JSON array containing the links found on the page.

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,26 @@ import { Tabs, TabItem, Render } from "~/components";

The `/markdown` endpoint retrieves a webpage's content and converts it into Markdown format. You can specify a URL and optional parameters to refine the extraction process.

## Endpoint

```txt
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdown
```

## Required fields
You must provide either `url` or `html`:
- `url` (string)
- `html` (string)

## Common use cases

- Normalize content for downstream processing (summaries, diffs, embeddings)
- Save articles or docs for editing or storage
- Strip styling/scripts and keep readable content + links

## Basic usage

### Using a URL
### Convert a URL to Markdown

<Tabs syncKey="workersExamples"> <TabItem label="curl">

Expand Down Expand Up @@ -52,7 +69,7 @@ console.log(markdown);

</TabItem> </Tabs>

### Use raw HTML
### Convert raw HTML to Markdown

Instead of fetching the content by specifying the URL, you can provide raw HTML content directly.

Expand All @@ -74,6 +91,8 @@ curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browse

## Advanced usage

### Exclude unwanted requests (for example, CSS)

You can refine the Markdown extraction by using the `rejectRequestPattern` parameter. In this example, requests matching the given regex pattern (such as CSS files) are excluded.

```bash
Expand Down
18 changes: 18 additions & 0 deletions src/content/docs/browser-rendering/rest-api/scrape-endpoint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,26 @@ import { Tabs, TabItem, Render } from "~/components";

The `/scrape` endpoint extracts structured data from specific elements on a webpage, returning details such as element dimensions and inner HTML.

## Endpoint

```txt
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/scrape
```

## Required fields
You must provide either `url` or `html`:
- `url` (string)
- `elements` (array of objects) — each object must include `selector` (string)

## Common use cases

- Extract headings, links, prices, or other repeated content with CSS selectors
- Collect metadata (for example, titles, descriptions, canonical links)

## Basic usage

### Extract headings and links from a URL

<Tabs syncKey="workersExamples"> <TabItem label="curl">

Go to `https://example.com` and extract metadata from all `h1` and `a` elements in the DOM.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,25 @@ import { Tabs, TabItem, Render } from "~/components";

The `/screenshot` endpoint renders the webpage by processing its HTML and JavaScript, then captures a screenshot of the fully rendered page.

## Endpoint

```txt
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot
```

## Required fields
You must provide either `url` or `html`:
- `url` (string)
- `html` (string)

## Common use cases

- Generate previews for websites, dashboards, or reports
- Capture screenshots for automated testing, QA, or visual regression

## Basic usage

### Capture a screenshot from HTML
### Take a screenshot from custom HTML

<Tabs syncKey="workersExamples"> <TabItem label="curl">

Expand Down Expand Up @@ -52,7 +68,7 @@ console.log(screenshot.status);

</TabItem> </Tabs>

### Capture a screenshot from a URL
### Take a screenshot from a URL

<Render
file="example-screenshot-from-url"
Expand Down Expand Up @@ -90,10 +106,9 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
--output "authenticated-screenshot.png"
```


### Navigate and capture a full-page screenshot

Navigate to `https://cloudflare.com/`, changing the page size (`viewport`) and waiting until there are no active network connections (`waitUntil`) or up to a maximum of `4500ms` (`timeout`). Then take a `fullPage` screenshot.
Navigate to `https://cloudflare.com/`, change the page size (`viewport`) and wait until there are no active network connections (`waitUntil`) or up to a maximum of `4500ms` (`timeout`) before capturing a `fullPage` screenshot.

```bash
curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot' \
Expand Down Expand Up @@ -140,7 +155,9 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
}' \
--output "screenshot.png"
```

### Capture a specific element using the selector option

To capture a screenshot of a specific element on a webpage, use the `selector` option with a valid CSS selector. You can also configure the `viewport` to control the page dimensions during rendering.

```bash
Expand Down
21 changes: 21 additions & 0 deletions src/content/docs/browser-rendering/rest-api/snapshot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,27 @@ import { Tabs, TabItem, Render } from "~/components";

The `/snapshot` endpoint captures both the HTML content and a screenshot of the webpage in one request. It returns the HTML as a text string and the screenshot as a Base64-encoded image.

## Endpoint

```txt
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/snapshot
```

## Required fields
You must provide either `url` or `html`:
- `url` (string)
- `html` (string)

## Common use cases

- Capture both the rendered HTML and a visual screenshot in a single API call
- Archive pages with visual and structural data together
- Build monitoring tools that compare visual and DOM differences over time

## Basic usage

### Capture a snapshot from a URL

<Tabs syncKey="workersExamples"> <TabItem label="curl">

1. Go to `https://example.com/`.
Expand Down Expand Up @@ -64,6 +83,8 @@ console.log(snapshot.content);

## Advanced usage

### Create a snapshot from custom HTML

The `html` property in the JSON payload, it sets the html to `<html><body>Advanced Snapshot</body></html>` then does the following steps:

1. Disable JavaScript.
Expand Down
Loading