Skip to content

Commit 2530892

Browse files
authored
Update screenshot-endpoint.mdx
- update to same style as pdf endpoint
1 parent 2dc2936 commit 2530892

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

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"
@@ -90,10 +106,9 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
90106
--output "authenticated-screenshot.png"
91107
```
92108

93-
94109
### Navigate and capture a full-page screenshot
95110

96-
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.
111+
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.
97112

98113
```bash
99114
curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot' \
@@ -140,7 +155,9 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
140155
}' \
141156
--output "screenshot.png"
142157
```
158+
143159
### Capture a specific element using the selector option
160+
144161
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.
145162

146163
```bash

0 commit comments

Comments
 (0)