-
Notifications
You must be signed in to change notification settings - Fork 10.2k
[Browser Rendering] quick actions API #20221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 69 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
16d5d9e
Guardails docs
daisyfaithauma 8e7de6b
Merge branch 'production' of https://github.com/cloudflare/cloudflare…
daisyfaithauma 1deed6d
Merge branch 'production' of https://github.com/cloudflare/cloudflare…
daisyfaithauma b9b204a
Merge branch 'production' of https://github.com/cloudflare/cloudflare…
daisyfaithauma 912be66
Initial commit
daisyfaithauma 9bc1e3d
quick actions endpoints
daisyfaithauma 7a32d66
Fix
kodster28 33e5fa8
change to bullets
daisyfaithauma 0e582ac
moved get started to a file
daisyfaithauma 1ac96e4
summary
daisyfaithauma 963a7f3
summar of endpoints
daisyfaithauma 80549ce
fixed merge conflict
kodster28 423edaa
code samples
daisyfaithauma 17c3b53
Merge branch 'rendering-quick-actions' of https://github.com/cloudfla…
daisyfaithauma 7f85bbc
code samples and title change
daisyfaithauma 888f77b
Update src/content/docs/browser-rendering/quick-actions-rest-api/scra…
daisyfaithauma 13fbe0b
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 8a9346d
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 412e75e
Update src/content/docs/browser-rendering/quick-actions-rest-api/scra…
daisyfaithauma 08f7fe5
director listing
daisyfaithauma 26957d9
Merge branch 'rendering-quick-actions' of https://github.com/cloudfla…
daisyfaithauma 1e91167
added code sample
daisyfaithauma 864b0ee
index descriptions
daisyfaithauma 7159abb
redirects
daisyfaithauma f01f28d
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma 7602ec4
delete custom css
daisyfaithauma e162f5a
Merge branch 'rendering-quick-actions' of https://github.com/cloudfla…
daisyfaithauma daa44b8
fixes from responses
daisyfaithauma 17a6931
Update src/content/docs/browser-rendering/quick-actions-rest-api/scra…
daisyfaithauma 10d25f4
code fixes
daisyfaithauma 105a878
parameters added
daisyfaithauma d17637a
Update get-started.mdx
kathayl 7863d7c
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma b5bb84f
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma e90f198
Update src/content/docs/browser-rendering/quick-actions-rest-api/inde…
daisyfaithauma 43ba4b1
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma 8afb47e
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma 41a5fc8
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma b8655d5
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 93bff6e
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 581c2d3
Update src/content/docs/browser-rendering/quick-actions-rest-api/scra…
daisyfaithauma 3109164
Update src/content/docs/browser-rendering/quick-actions-rest-api/scra…
daisyfaithauma 8ee92dd
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 161492d
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 5335a26
minor fixes
daisyfaithauma e5fe663
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 3db0a71
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 048a6e2
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 5371bdf
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma d6b0ad7
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 0de2ee8
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma 51803f9
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 69f7a8d
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma 5adf461
Update src/content/docs/browser-rendering/quick-actions-rest-api/inde…
daisyfaithauma 9225637
Update src/content/docs/browser-rendering/quick-actions-rest-api/inde…
daisyfaithauma 21bb019
Update src/content/docs/browser-rendering/workers-binding-api/index.mdx
daisyfaithauma a4d75c9
Update src/content/docs/browser-rendering/quick-actions-rest-api/snap…
daisyfaithauma b68d7e6
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma 35e2abd
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 6fb4b3b
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma a80e9c8
Update src/content/docs/browser-rendering/quick-actions-rest-api/cont…
daisyfaithauma ad050ce
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma 11c235f
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma 4653fd5
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma 96fe9a2
Update src/content/docs/browser-rendering/quick-actions-rest-api/pdf-…
daisyfaithauma e0d8002
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma 048a8b1
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma d567aaf
Update src/content/docs/browser-rendering/quick-actions-rest-api/scre…
daisyfaithauma eff3d93
minor fixes
daisyfaithauma e31c9ad
links fix
daisyfaithauma 227b7b1
Update src/content/docs/browser-rendering/workers-binding-api/reuse-s…
daisyfaithauma ffd76d6
code fix
daisyfaithauma d4c37ca
removed link
daisyfaithauma bd711a5
Fix error
kodster28 0540b69
Added beta badge
kodster28 7034b6e
Update public/_redirects
kodster28 84accea
Small edit
kodster28 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| pcx_content_type: navigation | ||
| title: Get started | ||
| sidebar: | ||
| order: 2 | ||
| --- | ||
|
|
||
| Browser rendering can be used in two ways: | ||
|
|
||
| - [Workers Binding API](/browser-rendering/workers-binding-api) for complex scripts. | ||
| - [Quick Actions REST API](/browser-rendering/quick-actions-rest-api/) for simple actions. |
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
src/content/docs/browser-rendering/quick-actions-rest-api/content-endpoint.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Fetch HTML | ||
| sidebar: | ||
| order: 2 | ||
| --- | ||
|
|
||
| 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. | ||
|
|
||
| ## Basic usage | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Go to `https://example.com` and return the rendered HTML. | ||
|
|
||
| ```bash | ||
| curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/content' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -d '{"url": "https://example.com"}' | ||
| ``` | ||
|
|
||
| ## Advanced usage | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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`). | ||
|
|
||
| ```bash | ||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/content' \ | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "url": "https://cloudflare.com/", | ||
| "rejectResourceTypes": ["image"], | ||
| "rejectRequestPattern": ["/^.*\\.(css)"] | ||
| } | ||
|
|
||
| ``` | ||
|
|
||
| ### Parameters | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - `url` _(string)_ - The URL of the webpage to extract content from. | ||
| - `rejectResourceTypes` _(array)_ - Blocks specific resource types such as images, fonts from loading to improve performance. | ||
| - `rejectRequestPattern` _(array of regex patterns)_ - Prevents loading of resources matching specified patterns such as CSS files. | ||
21 changes: 21 additions & 0 deletions
21
src/content/docs/browser-rendering/quick-actions-rest-api/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| --- | ||
| pcx_content_type: navigation | ||
| title: Quick Actions REST API | ||
| sidebar: | ||
| order: 2 | ||
| --- | ||
|
|
||
| The Quick Actions API is a RESTful interface that provides endpoints for common browser actions such as capturing screenshots, extracting HTML content, generating PDFs, and more. | ||
| The following are the available options: | ||
|
|
||
| import { DirectoryListing } from "~/components"; | ||
|
|
||
| <DirectoryListing /> | ||
|
|
||
| Use the Quick Actions API when you need a fast, simple way to perform common browser tasks such as capturing screenshots, extracting HTML, or generating PDFs without writing complex scripts. If you require more advanced automation, custom workflows, or persistent browser sessions, the [Workers Binding API](/browser-rendering/workers-binding-api/) is the better choice. | ||
|
|
||
| Before you begin, make sure you [create a custom **API Token**](/fundamentals/api/get-started/create-token/): | ||
|
|
||
| 1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/). | ||
| 2. Go to your account, then select **Browser Rendering**. | ||
| 3. Select **Edit** permissions. |
86 changes: 86 additions & 0 deletions
86
src/content/docs/browser-rendering/quick-actions-rest-api/pdf-endpoint.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Render PDF | ||
| sidebar: | ||
| order: 5 | ||
| --- | ||
|
|
||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| The `/pdf` endpoint instructs the browser to render the webpage as a PDF document. | ||
|
|
||
| ## Basic usage | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Navigate to `https://example.com/` and inject custom CSS and an external stylesheet. Then return the rendered page as a PDF. | ||
|
|
||
| ```bash | ||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/pdf' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "url": "https://example.com/", | ||
| "addStyleTag": [ | ||
| { "content": "body { font-family: Arial; }" }, | ||
| { "url": "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" } | ||
| ] | ||
| }' \ | ||
| --output "output.pdf" | ||
| ``` | ||
|
|
||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ## Advanced usage | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Navigate to `https://example.com`, first setting an additional HTTP request header and configuring the page size (`viewport`). Then, wait until there are no more than 2 network connections for at least 500 ms, or until the maximum timeout of 4500 ms is reached, before considering the page loaded and returning the rendered PDF document. | ||
|
|
||
| The `goToOptions` parameter exposes most of [Puppeteer'd API](https://pptr.dev/api/puppeteer.gotooptions). | ||
|
|
||
| ```bash | ||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/pdf' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "url": "https://example.com/", | ||
| "setExtraHTTPHeaders": { | ||
| "X-Custom-Header": "value" | ||
| }, | ||
| "viewport": { | ||
| "width": 1200, | ||
| "height": 800 | ||
| }, | ||
| "gotoOptions": { | ||
| "waitUntil": "networkidle2", | ||
| "timeout": 45000 | ||
| } | ||
| }' \ | ||
| --output "advanced-output.pdf" | ||
| ``` | ||
|
|
||
| ## PDF with no images or CSS | ||
|
|
||
| Use PDF with no images or CSS if you want to accelerate the scanning process and you do not need the images. | ||
|
|
||
| ```bash | ||
| curl -X POST https://api.cloudflare.com/client/v4/accounts/<acccountID>/browser-rendering/pdf \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "url": "https://cloudflare.com/", | ||
| "rejectResourceTypes": ["image"], | ||
| "rejectRequestPattern": ["/^.*\\.(css)"] | ||
| }' \ | ||
| --output "cloudflare.pdf" | ||
| ``` | ||
|
|
||
| ## Parameters | ||
|
|
||
| - `url` _(string)_ - The webpage URL to render as a PDF. | ||
| - `addStyleTag` _(array of objects)_ - Injects custom CSS before generating the PDF. | ||
| - `content` _(string)_ - Inline CSS styles. | ||
| - `url` _(string)_ - URL of an external stylesheet. | ||
| - `setExtraHTTPHeaders` _(object)_ - Adds custom HTTP headers when making the request. | ||
| - `X-Custom-Header` _(string)_ - Example of a custom header. | ||
| - `viewport` _(object)_ - Defines the browser viewport size. | ||
| - `width` _(number)_ - Viewport width in pixels. | ||
| - `height` _(number)_ - Viewport height in pixels. | ||
| - `gotoOptions` _(object)_ - Configures page navigation settings. | ||
| - `waitUntil` _(string)_ - Defines when the browser considers the page fully loaded. | ||
| - `timeout` _(number)_ - Maximum wait time before failing the request. | ||
| - `rejectResourceTypes` _(array)_ - Blocks specific resource types to improve rendering performance. | ||
| - `rejectRequestPattern` _(array of regex patterns)_ - Prevents loading of resources matching certain patterns. | ||
81 changes: 81 additions & 0 deletions
81
src/content/docs/browser-rendering/quick-actions-rest-api/scrape-endpoint.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Scrape HTML elements | ||
| sidebar: | ||
| order: 7 | ||
| --- | ||
|
|
||
| The `/scrape` endpoint extracts structured data from specific elements on a webpage, returning details such as element dimensions and inner HTML. | ||
|
|
||
| ## Basic usage | ||
|
|
||
| ```bash | ||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/scrape' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "url": "https://example.com/", | ||
| "elements": [{ | ||
| "selector": "h1" | ||
| }, | ||
| { | ||
| "selector": "a" | ||
| }] | ||
| } | ||
| ``` | ||
|
|
||
| ### JSON response | ||
|
|
||
| ```json title="json response" | ||
| { | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "success": true, | ||
| "result": [ | ||
| { | ||
| "results": [ | ||
| { | ||
| "attributes": [], | ||
| "height": 39, | ||
| "html": "Example Domain", | ||
| "left": 100, | ||
| "text": "Example Domain", | ||
| "top": 133.4375, | ||
| "width": 600 | ||
| } | ||
| ], | ||
| "selector": "h1" | ||
| }, | ||
| { | ||
| "results": [ | ||
| { | ||
| "attributes": [ | ||
| { "name": "href", "value": "https://www.iana.org/domains/example" } | ||
| ], | ||
| "height": 20, | ||
| "html": "More information...", | ||
| "left": 100, | ||
| "text": "More information...", | ||
| "top": 249.875, | ||
| "width": 142 | ||
| } | ||
| ], | ||
| "selector": "a" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ## Parameters | ||
|
|
||
| - `url` _(string)_ - The webpage to extract data from. | ||
| - `elements` _(object)_ - Defines the elements to extract from the page. | ||
| - `selectors` _(array of strings)_ - List of CSS selectors identifying elements to scrape (e.g., `"h1"`, `".article"`). | ||
|
|
||
| ### Response fields | ||
|
|
||
| - `results` _(array of objects)_ - Contains extracted data for each selector. | ||
| - `selector` _(string)_ - The CSS selector used. | ||
| - `results` _(array of objects)_ - List of extracted elements matching the selector. | ||
| - `text` _(string)_ - Inner text of the element. | ||
| - `html` _(string)_ - Inner HTML of the element. | ||
| - `attributes` _(array of objects)_ - List of extracted attributes such as `href` for links. | ||
| - `height`, `width`, `top`, `left` _(number)_ - Position and dimensions of the element. | ||
95 changes: 95 additions & 0 deletions
95
src/content/docs/browser-rendering/quick-actions-rest-api/screenshot-endpoint.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Capture screenshot | ||
| sidebar: | ||
| order: 3 | ||
| --- | ||
|
|
||
| The `/screenshot` endpoint renders the webpage by processing its HTML and JavaScript, then captures a screenshot of the fully rendered page. | ||
|
|
||
| ## Basic usage | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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. | ||
|
|
||
| ```bash | ||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "html": "Hello World!", | ||
| "screenshotOptions": { | ||
| "omitBackground": true | ||
| } | ||
| }' \ | ||
| --output "screenshot.webp" | ||
| ``` | ||
|
|
||
| ## Advanced usage | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Navigate to `https://cloudflare.com/`, changing the page size and waiting until there are no active network connections or up to a maximum of `4500ms`. Then take a `fullPage` screenshot. | ||
|
|
||
| ```bash | ||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "url": "https://cloudflare.com/", | ||
| "screenshotOptions": { | ||
daisyfaithauma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "fullPage": true, | ||
| "omitBackground": true, | ||
| }, | ||
| "viewport": { | ||
| "width": 1280, | ||
| "height": 720 | ||
| }, | ||
| "gotoOptions": { | ||
| "waitUntil": "networkidle0", | ||
| "timeout": 45000 | ||
| } | ||
| }' \ | ||
| --output "advanced-screenshot.webp" | ||
| ``` | ||
|
|
||
| ## Customize CSS and embed custom JavaScript | ||
|
|
||
| ```bash | ||
| curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot' \ | ||
| -H 'Authorization: Bearer <apiToken>' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "url": "https://example.com/", | ||
| "addScriptTag": [ | ||
|
|
||
| { "content": "document.querySelector(`h1`).innerText = `Hello World!!!`" } | ||
| ], | ||
| "addStyleTag": [ | ||
| { | ||
| "content": "div { background: linear-gradient(45deg, #2980b9 , #82e0aa ); }" | ||
| }, | ||
| { | ||
| "url": "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" | ||
| } | ||
| ] | ||
| }' \ | ||
| --output "screenshot.webp" | ||
| ``` | ||
|
|
||
| ## Parameters | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove. It should be in the api docs and some of these are common to all endpoints. |
||
|
|
||
| - `url` _(string)_ - The webpage URL to take a screenshot of. | ||
| - `html` _(string)_ - Instead of a URL, allows rendering custom HTML for the screenshot. | ||
| - `screenshotOptions` _(object)_ - Configures the screenshot format and quality. | ||
| - `omitBackground` _(boolean)_ - Removes the default white background when taking a screenshot. | ||
| - `viewport` _(object)_ - Sets the browser viewport dimensions for rendering. | ||
| - `width` _(number)_ - Viewport width in pixels. | ||
| - `height` _(number)_ - Viewport height in pixels. | ||
| - `gotoOptions` _(object)_ - Configures how and when the page is considered fully loaded. | ||
| - `waitUntil` _(string)_ - Defines when the browser considers navigation complete (`networkidle0`, `domcontentloaded`). | ||
| - `networkidle0` - Waits until there are no more than 0 network connections for at least 500 ms before taking a screenshot. | ||
| - `timeout` _(number)_ - Maximum wait time (in milliseconds) before navigation times out. | ||
| - `addScriptTag` _(array of objects)_ - Injects JavaScript code before taking a screenshot. | ||
| - `url` _(string)_ - Loads an external script file before rendering. | ||
| - `content` _(string)_ - Runs inline JavaScript before rendering. | ||
| - `addStyleTag` _(array of objects)_ - Injects CSS styles before rendering. | ||
| - `content` _(string)_ - Defines inline CSS rules. | ||
| - `url` _(string)_ - Loads external stylesheets before rendering. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.