Skip to content

Commit d7caea7

Browse files
authored
Update screenshot-endpoint.mdx
add new basic usage example of screenshot from url going to make it a partial so can be used in get started page as well
1 parent 88f3c26 commit d7caea7

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,10 @@ The `/screenshot` endpoint renders the webpage by processing its HTML and JavaSc
1717

1818
Sets the HTML content of the page to `Hello World!` and then takes a screenshot. The option `omitBackground` hides the default white background and allows capturing screenshots with transparency.
1919

20-
```bash
21-
curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot' \
22-
-H 'Authorization: Bearer <apiToken>' \
23-
-H 'Content-Type: application/json' \
24-
-d '{
25-
"html": "Hello World!",
26-
"screenshotOptions": {
27-
"omitBackground": true
28-
}
29-
}' \
30-
--output "screenshot.png"
31-
```
20+
<Render
21+
file="example-screenshot-from-url"
22+
product="browser-rendering"
23+
/>
3224

3325
</TabItem> <TabItem label="TypeScript SDK">
3426

@@ -52,6 +44,18 @@ console.log(screenshot.status);
5244

5345
</TabItem> </Tabs>
5446

47+
### Capture a screenshot from a URL
48+
49+
```bash
50+
curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot' \
51+
-H 'Authorization: Bearer <apiToken>' \
52+
-H 'Content-Type: application/json' \
53+
-d '{
54+
"url": "https://www.cloudflare.com"
55+
}' \
56+
--output "screenshot.png"
57+
```
58+
5559
For more options to control the final screenshot, like `clip`, `captureBeyondViewport`, `fullPage` and others, check the endpoint [reference](/api/resources/browser_rendering/subresources/screenshot/methods/create/).
5660

5761
:::note[Notes for basic usage]
@@ -83,7 +87,6 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
8387
--output "authenticated-screenshot.png"
8488
```
8589

86-
8790
### Navigate and capture a full-page screenshot
8891

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

0 commit comments

Comments
 (0)