You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/browser-rendering/rest-api/json-endpoint.mdx
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@ sidebar:
5
5
order: 9
6
6
---
7
7
8
+
import { Tabs, TabItem } from"~/components";
9
+
8
10
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.
9
11
10
12
:::note[Note]
@@ -15,6 +17,8 @@ The `/json` endpoint leverages [Workers AI](/workers-ai/) for data extraction. U
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
218
222
}
219
223
}
220
224
```
225
+
226
+
</TabItem> <TabItemlabel="TypeScript SDK">
227
+
228
+
Below is an example using the TypeScript SDK:
229
+
230
+
```typescript
231
+
importCloudflarefrom"cloudflare";
232
+
233
+
const client =newCloudflare({
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
0 commit comments