Skip to content

Commit 55540e0

Browse files
more sdk
1 parent eb5589e commit 55540e0

File tree

2 files changed

+48
-9
lines changed

2 files changed

+48
-9
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ sidebar:
55
order: 10
66
---
77

8+
import { Tabs, TabItem } from "~/components";
9+
810
The `/links` endpoint retrieves all links from a webpage. It can be used to extract all links from a page, including those that are hidden.
911

1012
## Basic usage
1113

14+
<Tabs syncKey="workersExamples"> <TabItem label="curl">
15+
1216
This example grabs all links from the Cloudflare Developers homepage.
1317
The response will be a JSON array containing the links found on the page.
1418

@@ -100,6 +104,24 @@ curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-
100104
}
101105
```
102106

107+
</TabItem> <TabItem label="TypeScript SDK">
108+
109+
```javascript
110+
import Cloudflare from "cloudflare";
111+
112+
const client = new Cloudflare({
113+
apiEmail: process.env["CLOUDFLARE_EMAIL"], // This is the default and can be omitted
114+
apiKey: process.env["CLOUDFLARE_API_KEY"], // This is the default and can be omitted
115+
});
116+
117+
const links = await client.browserRendering.links.create({
118+
account_id: "account_id",
119+
});
120+
121+
console.log(links);
122+
```
123+
124+
</TabItem> </Tabs>
103125
## Advanced usage
104126

105127
In this example we can pass a `visibleLinksOnly` parameter to only return links that are visible on the page.

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ sidebar:
55
order: 10
66
---
77

8+
import { Tabs, TabItem } from "~/components";
9+
810
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.
911

1012
## Basic usage
1113

1214
### Using a URL
1315

16+
<Tabs syncKey="workersExamples"> <TabItem label="curl">
17+
1418
This example fetches the Markdown representation of a webpage.
1519

1620
```bash
@@ -22,15 +26,32 @@ curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browse
2226
}'
2327
```
2428

25-
### JSON response
29+
```json output
2630

27-
```json title="json response"
28-
{
2931
"success": true,
3032
"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)"
3133
}
3234
```
3335

36+
</TabItem> <TabItem label="TypeScript SDK">
37+
38+
```javascript
39+
import Cloudflare from "cloudflare";
40+
41+
const client = new Cloudflare({
42+
apiEmail: process.env["CLOUDFLARE_EMAIL"], // This is the default and can be omitted
43+
apiKey: process.env["CLOUDFLARE_API_KEY"], // This is the default and can be omitted
44+
});
45+
46+
const markdown = await client.browserRendering.markdown.create({
47+
account_id: "account_id",
48+
});
49+
50+
console.log(markdown);
51+
```
52+
53+
</TabItem> </Tabs>
54+
3455
### Use raw HTML
3556

3657
Instead of fetching the content by specifying the URL, you can provide raw HTML content directly.
@@ -44,9 +65,7 @@ curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browse
4465
}'
4566
```
4667

47-
### JSON response
48-
49-
```json title="json response"
68+
```json output
5069
{
5170
"success": true,
5271
"result": "Hello World"
@@ -67,9 +86,7 @@ curl -X 'POST' 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browse
6786
}'
6887
```
6988

70-
### JSON response
71-
72-
```json title="json response"
89+
```json output
7390
{
7491
"success": true,
7592
"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)"

0 commit comments

Comments
 (0)