Skip to content

Commit 463b54e

Browse files
VinciGit00claude
andcommitted
docs: update monitor API to use interval param from v2 SDK
Align monitor docs with Python SDK PR #82 (scrapegraph-py v2): - Rename `cron` parameter to `interval` across all code examples - Add required `name` parameter to SDK snippets - Replace Pydantic model schema with JSON Schema dict - Update FetchConfig usage (mode enum instead of stealth bool) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d104531 commit 463b54e

3 files changed

Lines changed: 31 additions & 17 deletions

File tree

sdks/javascript.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,10 @@ Create and manage site monitoring jobs.
241241
```javascript
242242
// Create a monitor
243243
const monitor = await sgai.monitor.create({
244+
name: "Price Tracker",
244245
url: "https://example.com",
245246
prompt: "Track price changes",
246-
schedule: "daily",
247+
interval: "0 9 * * *", // Daily at 9 AM
247248
});
248249

249250
// List all monitors

sdks/python.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,10 @@ Create and manage site monitoring jobs.
212212
```python
213213
# Create a monitor
214214
monitor = client.monitor.create(
215+
name="Price Tracker",
215216
url="https://example.com",
216217
prompt="Track price changes",
217-
schedule="daily",
218+
interval="0 9 * * *", # Daily at 9 AM
218219
)
219220

220221
# List all monitors

services/monitor.mdx

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ monitor = client.monitor.create(
2828
name="Price Tracker",
2929
url="https://example.com/products",
3030
prompt="Extract current product prices",
31-
cron="0 9 * * *", # Daily at 9 AM
31+
interval="0 9 * * *", # Daily at 9 AM
3232
)
3333
print("Monitor created:", monitor)
3434
```
@@ -42,7 +42,7 @@ const monitor = await sgai.monitor.create({
4242
name: 'Price Tracker',
4343
url: 'https://example.com/products',
4444
prompt: 'Extract current product prices',
45-
cron: '0 9 * * *',
45+
interval: '0 9 * * *', // Daily at 9 AM
4646
});
4747

4848
console.log('Monitor created:', monitor.data.id);
@@ -62,7 +62,7 @@ curl -X POST https://api.scrapegraphai.com/api/v2/monitor \
6262
"name": "Price Tracker",
6363
"url": "https://example.com/products",
6464
"prompt": "Extract current product prices",
65-
"cron": "0 9 * * *"
65+
"interval": "0 9 * * *"
6666
}'
6767
```
6868

@@ -75,9 +75,9 @@ curl -X POST https://api.scrapegraphai.com/api/v2/monitor \
7575
| name | string | Yes | A descriptive name for the monitor. |
7676
| url | string | Yes | The URL to monitor. |
7777
| prompt | string | Yes | What data to extract on each run. |
78-
| cron | string | Yes | Cron expression for the schedule (e.g., `"0 9 * * *"` for daily at 9 AM). |
79-
| output_schema | object | No | Pydantic or Zod schema for structured response format. |
80-
| fetch_config | FetchConfig | No | Configuration for page fetching (headers, stealth, etc.). |
78+
| interval | string | Yes | Cron expression for the schedule (5 fields, e.g., `"0 9 * * *"` for daily at 9 AM). |
79+
| output_schema | object | No | JSON Schema (Python dict / JS object) for structured response format. |
80+
| fetch_config | FetchConfig | No | Configuration for page fetching (mode, headers, wait, etc.). |
8181
| llm_config | LlmConfig | No | Configuration for the AI model (temperature, max_tokens, etc.). |
8282

8383
<Note>
@@ -123,23 +123,35 @@ client.monitor.delete(monitor_id)
123123
### With Output Schema and Config
124124

125125
```python
126-
from pydantic import BaseModel, Field
127126
from scrapegraph_py import Client, FetchConfig, LlmConfig
128127

129-
class ProductPrice(BaseModel):
130-
name: str = Field(description="Product name")
131-
price: float = Field(description="Current price")
132-
in_stock: bool = Field(description="Whether the product is in stock")
128+
schema = {
129+
"type": "object",
130+
"properties": {
131+
"products": {
132+
"type": "array",
133+
"items": {
134+
"type": "object",
135+
"properties": {
136+
"name": {"type": "string"},
137+
"price": {"type": "number"},
138+
"in_stock": {"type": "boolean"},
139+
},
140+
"required": ["name", "price"],
141+
},
142+
},
143+
},
144+
}
133145

134146
client = Client(api_key="your-api-key")
135147

136148
monitor = client.monitor.create(
137149
name="Product Price Monitor",
138150
url="https://example.com/products",
139151
prompt="Extract product names, prices, and stock status",
140-
cron="0 */6 * * *", # Every 6 hours
141-
output_schema=ProductPrice,
142-
fetch_config=FetchConfig(stealth=True),
152+
interval="0 */6 * * *", # Every 6 hours
153+
output_schema=schema,
154+
fetch_config=FetchConfig(mode="js+stealth", wait=2000),
143155
llm_config=LlmConfig(temperature=0.1),
144156
)
145157
```
@@ -156,7 +168,7 @@ async def main():
156168
name="Tracker",
157169
url="https://example.com",
158170
prompt="Extract prices",
159-
cron="0 9 * * *",
171+
interval="0 9 * * *",
160172
)
161173

162174
monitors = await client.monitor.list()

0 commit comments

Comments
 (0)