Skip to content

Commit 7ece23f

Browse files
typescript SDK
1 parent f8cefeb commit 7ece23f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ sidebar:
55
order: 9
66
---
77

8+
import { Tabs, TabItem } from "~/components";
9+
810
The `/json` endpoint extracts structured data from a webpage. You can specify the expected output using either a `prompt` or a `response_format` parameter which accepts a JSON schema. The endpoint returns the extracted data in JSON format.
911

1012
:::note[Note]
@@ -15,6 +17,8 @@ The `/json` endpoint leverages [Workers AI](/workers-ai/) for data extraction. U
1517

1618
## Basic Usage
1719

20+
<Tabs syncKey="workersExamples"> <TabItem label="curl">
21+
1822
### With a Prompt and JSON schema
1923

2024
This example captures webpage data by providing both a prompt and a JSON schema. The prompt guides the extraction process, while the JSON schema defines the expected structure of the output.
@@ -218,3 +222,24 @@ curl --request POST 'https://api.cloudflare.com/client/v4/accounts/CF_ACCOUNT_ID
218222
}
219223
}
220224
```
225+
226+
</TabItem> <TabItem label="TypeScript SDK">
227+
228+
Below is an example using the TypeScript SDK:
229+
230+
```typescript
231+
import Cloudflare from "cloudflare";
232+
233+
const client = new Cloudflare({
234+
apiEmail: process.env["CLOUDFLARE_EMAIL"], // This is the default and can be omitted
235+
apiKey: process.env["CLOUDFLARE_API_KEY"], // This is the default and can be omitted
236+
});
237+
238+
const json = await client.browserRendering.json.create({
239+
account_id: "account_id",
240+
});
241+
242+
console.log(json);
243+
```
244+
245+
</TabItem> </Tabs>

0 commit comments

Comments
 (0)