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
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,23 @@
1
1
---
2
2
pcx_content_type: how-to
3
-
title: Capture Webpage Data in JSON Format
3
+
title: Capture webpage data in JSON format
4
4
sidebar:
5
5
order: 9
6
6
---
7
7
8
-
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.
8
+
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.
| url | yes | The URL of the webpage to extract data from. |
15
+
| prompt |no|Must supply one of `prompt` or `response_format`. |
16
+
| response_format |no|Must supply one of `prompt` or `response_format`. May include a JSON schema. |
17
17
18
-
## Basic Usage
18
+
## Basic usage
19
19
20
-
### With a Prompt and JSON Schema
20
+
### With a prompt and JSON schema
21
21
22
22
This example captures webpage data by providing both a prompt and a JSON schema. If multiple headings exist, the first occurrence of each (e.g. `h1`, `h2`) is returned.
23
23
@@ -48,7 +48,7 @@ curl --request POST 'https://api.cloudflare.com/client/v4/accounts/CF_ACCOUNT_ID
48
48
}'
49
49
```
50
50
51
-
#### JSON Response
51
+
#### JSON response
52
52
53
53
```json title="json response"
54
54
{
@@ -60,7 +60,7 @@ curl --request POST 'https://api.cloudflare.com/client/v4/accounts/CF_ACCOUNT_ID
60
60
}
61
61
```
62
62
63
-
### With Only a Prompt
63
+
### With only a prompt
64
64
65
65
In this example, only a prompt is provided. The endpoint will use the prompt to extract the heading information from the page.
66
66
@@ -74,7 +74,7 @@ curl --request POST 'https://api.cloudflare.com/client/v4/accounts/CF_ACCOUNT_ID
74
74
}'
75
75
```
76
76
77
-
#### JSON Response
77
+
#### JSON response
78
78
79
79
```json title="json response"
80
80
{
@@ -86,7 +86,7 @@ curl --request POST 'https://api.cloudflare.com/client/v4/accounts/CF_ACCOUNT_ID
86
86
}
87
87
```
88
88
89
-
### With Only a JSON Schema (No Prompt)
89
+
### With only a JSON schema (no prompt)
90
90
91
91
In this case, you supply a JSON schema via the `response_format` parameter. The schema defines the structure of the extracted data.
92
92
@@ -116,7 +116,7 @@ curl --request POST 'https://api.cloudflare.com/client/v4/accounts/CF_ACCOUNT_ID
116
116
}'
117
117
```
118
118
119
-
#### JSON Response
119
+
#### JSON response
120
120
121
121
```json title="json response"
122
122
{
@@ -128,7 +128,7 @@ curl --request POST 'https://api.cloudflare.com/client/v4/accounts/CF_ACCOUNT_ID
128
128
}
129
129
```
130
130
131
-
## Potential Use-Cases
131
+
## Potential use-cases
132
132
133
133
1.**Extract Movie Data:** Retrieve details like name, genre, and release date for the top 10 action movies from the IMDB top 250 list by supplying the appropriate IMDB link and JSON schema.
134
134
2.**Weather Information:** Fetch current weather conditions for a location (e.g., Edinburgh) using a weather website link (like from BBC Weather).
0 commit comments