Skip to content

Commit f6261cf

Browse files
kathaylToriLindsay
andauthored
Update content-endpoint.mdx (#25824)
* Update content-endpoint.mdx - add subheadings - update to same style as pdf endpoint * Update screenshot-endpoint.mdx - update to same style as pdf endpoint * Update snapshot.mdx - add subheadings - update to same style as pdf endpoint * Update scrape-endpoint.mdx - add subheadings - update to same style as pdf endpoint * Update json-endpoint.mdx - update to same style as pdf endpoint * Update links-endpoint.mdx - add subheadings - update to same style as pdf endpoint * Update markdown-endpoint.mdx - add subheadings - update to same style as pdf endpoint * Update src/content/docs/browser-rendering/rest-api/links-endpoint.mdx Co-authored-by: ToriLindsay <[email protected]> * Update src/content/docs/browser-rendering/rest-api/links-endpoint.mdx Co-authored-by: ToriLindsay <[email protected]> * Update src/content/docs/browser-rendering/rest-api/scrape-endpoint.mdx Co-authored-by: ToriLindsay <[email protected]> --------- Co-authored-by: ToriLindsay <[email protected]>
1 parent 6c1df75 commit f6261cf

File tree

7 files changed

+142
-13
lines changed

7 files changed

+142
-13
lines changed

src/content/docs/browser-rendering/rest-api/content-endpoint.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,26 @@ import { Tabs, TabItem, Render } from "~/components";
99

1010
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.
1111

12+
## Endpoint
13+
14+
```txt
15+
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/content
16+
```
17+
18+
## Required fields
19+
You must provide either `url` or `html`:
20+
- `url` (string)
21+
- `html` (string)
22+
23+
## Common use cases
24+
25+
- Capture the fully rendered HTML of a dynamic page
26+
- Extract HTML for parsing, scraping, or downstream processing
27+
1228
## Basic usage
1329

30+
### Fetch rendered HTML from a URL
31+
1432
<Tabs syncKey="workersExamples"> <TabItem label="curl">
1533

1634
Go to `https://developers.cloudflare.com/` and return the rendered HTML.
@@ -46,6 +64,8 @@ console.log(content);
4664
:::note[Looking for more parameters?]
4765
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`.
4866
:::
67+
68+
### Block specific resource types
4969

5070
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`.
5171

src/content/docs/browser-rendering/rest-api/json-endpoint.mdx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,33 @@ By default, the `/json` endpoint leverages [Workers AI](/workers-ai/) for data e
1717

1818
:::
1919

20-
## Basic Usage
20+
## Endpoint
2121

22-
<Tabs syncKey="workersExamples"> <TabItem label="curl">
22+
```txt
23+
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/json
24+
```
25+
26+
## Required fields
27+
You must provide either `url` or `html`:
28+
- `url` (string)
29+
- `html` (string)
30+
31+
And at least one of:
32+
- `prompt` (string), or
33+
- `response_format` (object with a JSON Schema)
34+
35+
## Common use cases
36+
37+
- Extract product info (title, price, availability) or listings (jobs, rentals)
38+
- Normalize article metadata (title, author, publish date, canonical URL)
39+
- Convert unstructured pages into typed JSON for downstream pipelines
40+
41+
## Basic Usage
2342

2443
### With a Prompt and JSON schema
2544

45+
<Tabs syncKey="workersExamples"> <TabItem label="curl">
46+
2647
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.
2748

2849
```bash

src/content/docs/browser-rendering/rest-api/links-endpoint.mdx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,30 @@ import { Tabs, TabItem, Render } from "~/components";
99

1010
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.
1111

12+
## Endpoint
13+
14+
```txt
15+
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/links
16+
```
17+
18+
## Required fields
19+
You must provide either `url` or `html`:
20+
- `url` (string)
21+
- `html` (string)
22+
23+
## Common use cases
24+
25+
- Collect only user-visible links for UX or SEO analysis
26+
- Crawl a site by discovering links on seed pages
27+
- Validate navigation/footers and detect broken or external links
28+
1229
## Basic usage
1330

31+
### Get all links on a page
32+
1433
<Tabs syncKey="workersExamples"> <TabItem label="curl">
1534

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

1938
```bash

src/content/docs/browser-rendering/rest-api/markdown-endpoint.mdx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,26 @@ import { Tabs, TabItem, Render } from "~/components";
99

1010
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.
1111

12+
## Endpoint
13+
14+
```txt
15+
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdown
16+
```
17+
18+
## Required fields
19+
You must provide either `url` or `html`:
20+
- `url` (string)
21+
- `html` (string)
22+
1223
## Common use cases
1324

14-
- **Content extraction:** Convert a blog post or article into Markdown format for storage or further processing.
15-
- **Static site generation:** Retrieve structured Markdown content for use in static site generators like Jekyll or Hugo.
16-
- **Automated summarization:** Extract key content from web pages while ignoring CSS, scripts, or unnecessary elements.
25+
- Normalize content for downstream processing (summaries, diffs, embeddings)
26+
- Save articles or docs for editing or storage
27+
- Strip styling/scripts and keep readable content + links
1728

1829
## Basic usage
1930

20-
### Using a URL
31+
### Convert a URL to Markdown
2132

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

@@ -58,7 +69,7 @@ console.log(markdown);
5869

5970
</TabItem> </Tabs>
6071

61-
### Use raw HTML
72+
### Convert raw HTML to Markdown
6273

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

@@ -82,7 +93,9 @@ curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browse
8293

8394
:::note[Looking for more parameters?]
8495
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`.
85-
:::
96+
:::
97+
98+
### Exclude unwanted requests (for example, CSS)
8699

87100
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.
88101

src/content/docs/browser-rendering/rest-api/scrape-endpoint.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,26 @@ import { Tabs, TabItem, Render } from "~/components";
99

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

12+
## Endpoint
13+
14+
```txt
15+
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/scrape
16+
```
17+
18+
## Required fields
19+
You must provide either `url` or `elements`:
20+
- `url` (string)
21+
- `elements` (array of objects) — each object must include `selector` (string)
22+
23+
## Common use cases
24+
25+
- Extract headings, links, prices, or other repeated content with CSS selectors
26+
- Collect metadata (for example, titles, descriptions, canonical links)
27+
1228
## Basic usage
1329

30+
### Extract headings and links from a URL
31+
1432
<Tabs syncKey="workersExamples"> <TabItem label="curl">
1533

1634
Go to `https://example.com` and extract metadata from all `h1` and `a` elements in the DOM.

src/content/docs/browser-rendering/rest-api/screenshot-endpoint.mdx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,25 @@ import { Tabs, TabItem, Render } from "~/components";
99

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

12+
## Endpoint
13+
14+
```txt
15+
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot
16+
```
17+
18+
## Required fields
19+
You must provide either `url` or `html`:
20+
- `url` (string)
21+
- `html` (string)
22+
23+
## Common use cases
24+
25+
- Generate previews for websites, dashboards, or reports
26+
- Capture screenshots for automated testing, QA, or visual regression
27+
1228
## Basic usage
1329

14-
### Capture a screenshot from HTML
30+
### Take a screenshot from custom HTML
1531

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

@@ -52,7 +68,7 @@ console.log(screenshot.status);
5268

5369
</TabItem> </Tabs>
5470

55-
### Capture a screenshot from a URL
71+
### Take a screenshot from a URL
5672

5773
<Render
5874
file="example-screenshot-from-url"
@@ -94,10 +110,9 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
94110
--output "authenticated-screenshot.png"
95111
```
96112

97-
98113
### Navigate and capture a full-page screenshot
99114

100-
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.
115+
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.
101116

102117
```bash
103118
curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot' \
@@ -144,7 +159,9 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
144159
}' \
145160
--output "screenshot.png"
146161
```
162+
147163
### Capture a specific element using the selector option
164+
148165
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.
149166

150167
```bash

src/content/docs/browser-rendering/rest-api/snapshot.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,27 @@ import { Tabs, TabItem, Render } from "~/components";
99

1010
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.
1111

12+
## Endpoint
13+
14+
```txt
15+
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/snapshot
16+
```
17+
18+
## Required fields
19+
You must provide either `url` or `html`:
20+
- `url` (string)
21+
- `html` (string)
22+
23+
## Common use cases
24+
25+
- Capture both the rendered HTML and a visual screenshot in a single API call
26+
- Archive pages with visual and structural data together
27+
- Build monitoring tools that compare visual and DOM differences over time
28+
1229
## Basic usage
1330

31+
### Capture a snapshot from a URL
32+
1433
<Tabs syncKey="workersExamples"> <TabItem label="curl">
1534

1635
1. Go to `https://example.com/`.
@@ -67,6 +86,8 @@ console.log(snapshot.content);
6786
:::note[Looking for more parameters?]
6887
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`.
6988
:::
89+
90+
### Create a snapshot from custom HTML
7091

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

0 commit comments

Comments
 (0)