/content - Fetch HTML
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.
Go to https://developers.cloudflare.com/
and return the rendered HTML.
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://developers.cloudflare.com/"}'
import Cloudflare from "cloudflare";
const client = new Cloudflare({ apiToken: process.env["CLOUDFLARE_API_TOKEN"],});
const content = await client.browserRendering.content.create({ account_id: process.env["CLOUDFLARE_ACCOUNT_ID"], url: "https://developers.cloudflare.com/",});
console.log(content);
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
.
curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/content' \ -H 'Authorization: Bearer <apiToken>' \ -H 'Content-Type: application/json' \ -d '{ "url": "https://cloudflare.com/", "rejectResourceTypes": ["image"], "rejectRequestPattern": ["/^.*\\.(css)"] }'
Many more options exist, like setting HTTP headers using setExtraHTTPHeaders
, setting cookies
, and using gotoOptions
to control page load behaviour - check the endpoint reference for all available parameters.
You can change the user agent at the page level by passing userAgent
as a top-level parameter in the JSON body. This is useful if the target website serves different content based on the user agent.
If you have questions or encounter an error, see the Browser Rendering FAQ and troubleshooting guide.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark