Skip to content

Commit 66c320e

Browse files
Markdown endpoint docs
1 parent 686ca7a commit 66c320e

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ pcx_content_type: navigation
33
title: Reference
44
external_link: /api/resources/browser_rendering/
55
sidebar:
6-
order: 8
6+
order: 11
77
---
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
pcx_content_type: how-to
3+
title: Extract Markdown from a webpage
4+
sidebar:
5+
order: 10
6+
---
7+
8+
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.
9+
10+
## Basic usage
11+
12+
This example fetches the Markdown representation of a webpage.
13+
14+
```bash
15+
curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdown' \
16+
-H 'Content-Type: application/json' \
17+
-H 'Authorization: Bearer <apiToken>' \
18+
-d '{
19+
"url": "https://example.com"
20+
}'
21+
```
22+
23+
### JSON response
24+
25+
```json title="json response"
26+
{
27+
"success": true,
28+
"result": "# Example Domain\n\nThis domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.\n\n[More information...](https://www.iana.org/domains/example)"
29+
}
30+
```
31+
32+
## Advanced usage
33+
34+
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.
35+
36+
```bash
37+
curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/markdown' \
38+
-H 'Content-Type: application/json' \
39+
-H 'Authorization: Bearer <apiToken>' \
40+
-d '{
41+
"url": "https://example.com",
42+
"rejectRequestPattern": ["/^.*\\.(css)/"]
43+
}'
44+
```
45+
46+
### JSON response
47+
48+
```json title="json response"
49+
{
50+
"success": true,
51+
"result": "# Example Domain\n\nThis domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.\n\n[More information...](https://www.iana.org/domains/example)"
52+
}
53+
```
54+
55+
## Potential use-cases
56+
57+
1. **Content extraction:** Convert a blog post or article into Markdown format for storage or further processing.
58+
2. **Static site generation:** Retrieve structured Markdown content for use in static site generators like Jekyll or Hugo.
59+
3. **Automated summarization:** Extract key content from web pages while ignoring CSS, scripts, or unnecessary elements.

0 commit comments

Comments
 (0)