Skip to content
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 @@ -46,6 +64,8 @@ console.log(content);
:::note[Looking for more parameters?]
Visit the [Browser Rendering PDF API reference](/api/resources/browser_rendering/subresources/content/methods/create/) for all available parameters, such as setting HTTP credentials using `authenticate`, setting `cookies`, and customizing load behavior using `gotoOptions`.
:::

### 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`.

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
21 changes: 20 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,30 @@ 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)
- `html` (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 Doc'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,15 +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

- **Content extraction:** Convert a blog post or article into Markdown format for storage or further processing.
- **Static site generation:** Retrieve structured Markdown content for use in static site generators like Jekyll or Hugo.
- **Automated summarization:** Extract key content from web pages while ignoring CSS, scripts, or unnecessary elements.
- 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 @@ -58,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 @@ -82,7 +93,9 @@ curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browse

:::note[Looking for more parameters?]
Visit the [Browser Rendering PDF API reference](/api/resources/browser_rendering/subresources/markdown/methods/create/) for all available parameters, such as setting HTTP credentials using `authenticate`, setting `cookies`, and customizing load behavior using `gotoOptions`.
:::
:::

### 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.

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 `elements`:
- `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 @@ -94,10 +110,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 @@ -144,7 +159,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 @@ -67,6 +86,8 @@ console.log(snapshot.content);
:::note[Looking for more parameters?]
Visit the [Browser Rendering PDF API reference](/api/resources/browser_rendering/subresources/snapshot/methods/create/) for all available parameters, such as setting HTTP credentials using `authenticate`, setting `cookies`, and customizing load behavior using `gotoOptions`.
:::

### 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:

Expand Down
Loading