Skip to content

Commit 8b75c8e

Browse files
VinciGit00claude
andcommitted
fix: rename monitor 'cron' field to 'interval' to match API contract
Integration testing revealed the v2 API expects 'interval' not 'cron' for the monitor create endpoint. Updated model, both clients, all tests, examples, and migration guide. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 01ecb04 commit 8b75c8e

11 files changed

Lines changed: 22 additions & 22 deletions

examples/async_monitor_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async def main():
1515
name="Async Price Tracker",
1616
url="https://example.com/products",
1717
prompt="Extract product prices",
18-
cron="0 12 * * *", # Every day at noon
18+
interval="0 12 * * *", # Every day at noon
1919
)
2020
print("Created:", json.dumps(monitor, indent=2))
2121

examples/monitor_create_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Create a monitor to track changes on a webpage.
33
4-
Monitors run on a cron schedule and use AI to extract data each time.
4+
Monitors run on an interval (cron expression) and use AI to extract data each time.
55
This replaces the old scheduled jobs API.
66
"""
77

@@ -15,7 +15,7 @@
1515
name="Daily Price Tracker",
1616
url="https://example.com/products",
1717
prompt="Extract all product names and prices",
18-
cron="0 9 * * *", # Every day at 9am
18+
interval="0 9 * * *", # Every day at 9am
1919
)
2020
print("Monitor created:", json.dumps(monitor, indent=2))
2121

examples/monitor_with_config_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
name="Stealth News Monitor",
1313
url="https://example.com/news",
1414
prompt="Extract the top 5 news headlines with their dates",
15-
cron="0 */6 * * *", # Every 6 hours
15+
interval="0 */6 * * *", # Every 6 hours
1616
fetch_config=FetchConfig(
1717
mode="js+stealth",
1818
wait=2000,

examples/monitor_with_schema_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
name="Weekly Product Monitor",
3434
url="https://example.com/shop",
3535
prompt="Extract all product names, prices, and currencies",
36-
cron="0 8 * * 1", # Every Monday at 8am
36+
interval="0 8 * * 1", # Every Monday at 8am
3737
output_schema=schema,
3838
)
3939
print("Monitor created:", json.dumps(monitor, indent=2))

scrapegraph-py/MIGRATION_V2.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ client.crawl.resume(crawl_id)
349349

350350
### Scheduled Jobs → `monitor.*`
351351

352-
The entire scheduled jobs API has been replaced by the **monitor** namespace. Monitors are simpler: instead of configuring a `service_type` + `job_config`, you directly provide a `url`, `prompt`, and `cron`.
352+
The entire scheduled jobs API has been replaced by the **monitor** namespace. Monitors are simpler: instead of configuring a `service_type` + `job_config`, you directly provide a `url`, `prompt`, and `interval` (a cron expression).
353353

354354
#### v1
355355

@@ -397,7 +397,7 @@ monitor = client.monitor.create(
397397
name="Daily Scraper",
398398
url="https://example.com",
399399
prompt="Extract company info",
400-
cron="0 9 * * *",
400+
interval="0 9 * * *",
401401
output_schema={"type": "object", "properties": {"name": {"type": "string"}}},
402402
fetch_config=FetchConfig(mode="direct+stealth"),
403403
llm_config=LlmConfig(temperature=0.1),
@@ -602,7 +602,7 @@ async def main():
602602
name="Tracker",
603603
url="https://example.com",
604604
prompt="Extract prices",
605-
cron="0 9 * * *",
605+
interval="0 9 * * *",
606606
)
607607

608608
asyncio.run(main())

scrapegraph-py/scrapegraph_py/async_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def create(
9898
name: str,
9999
url: str,
100100
prompt: str,
101-
cron: str,
101+
interval: str,
102102
output_schema: Optional[Dict[str, Any]] = None,
103103
fetch_config: Optional[FetchConfig] = None,
104104
llm_config: Optional[LlmConfig] = None,
@@ -109,7 +109,7 @@ async def create(
109109
name=name,
110110
url=url,
111111
prompt=prompt,
112-
cron=cron,
112+
interval=interval,
113113
output_schema=output_schema,
114114
fetch_config=fetch_config,
115115
llm_config=llm_config,

scrapegraph-py/scrapegraph_py/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def create(
121121
name: str,
122122
url: str,
123123
prompt: str,
124-
cron: str,
124+
interval: str,
125125
output_schema: Optional[Dict[str, Any]] = None,
126126
fetch_config: Optional[FetchConfig] = None,
127127
llm_config: Optional[LlmConfig] = None,
@@ -132,7 +132,7 @@ def create(
132132
name: Name of the monitor
133133
url: URL to monitor
134134
prompt: Prompt for AI extraction
135-
cron: Cron expression (5 fields)
135+
interval: Cron expression (5 fields)
136136
output_schema: Optional JSON Schema for structured output
137137
fetch_config: Fetch configuration options
138138
llm_config: LLM configuration options
@@ -142,7 +142,7 @@ def create(
142142
name=name,
143143
url=url,
144144
prompt=prompt,
145-
cron=cron,
145+
interval=interval,
146146
output_schema=output_schema,
147147
fetch_config=fetch_config,
148148
llm_config=llm_config,

scrapegraph-py/scrapegraph_py/models/monitor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MonitorCreateRequest(BaseModel):
2222
name: str = Field(..., description="Name of the monitor")
2323
url: str = Field(..., description="URL to monitor")
2424
prompt: str = Field(..., description="Prompt for AI extraction")
25-
cron: str = Field(..., description="Cron expression for scheduling (5 fields)")
25+
interval: str = Field(..., description="Cron expression for scheduling (5 fields)")
2626
output_schema: Optional[Dict[str, Any]] = Field(
2727
default=None,
2828
description="JSON Schema defining the structure of extracted data",
@@ -44,9 +44,9 @@ def validate_fields(self) -> "MonitorCreateRequest":
4444
raise ValueError("URL must start with http:// or https://")
4545
if not self.prompt or not self.prompt.strip():
4646
raise ValueError("Prompt cannot be empty")
47-
parts = self.cron.strip().split()
47+
parts = self.interval.strip().split()
4848
if len(parts) != 5:
49-
raise ValueError("Cron expression must have exactly 5 fields")
49+
raise ValueError("Interval cron expression must have exactly 5 fields")
5050
return self
5151

5252
def model_dump(self, *args: Any, **kwargs: Any) -> Dict[str, Any]:

scrapegraph-py/tests/test_async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ async def test_monitor_create(client):
240240
name="Price Monitor",
241241
url="https://example.com/products",
242242
prompt="Extract product prices",
243-
cron="0 9 * * 1",
243+
interval="0 9 * * 1",
244244
)
245245
assert result["name"] == "Price Monitor"
246246

scrapegraph-py/tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def test_monitor_create(client):
283283
name="Price Monitor",
284284
url="https://example.com/products",
285285
prompt="Extract product prices",
286-
cron="0 9 * * 1",
286+
interval="0 9 * * 1",
287287
)
288288
assert result["name"] == "Price Monitor"
289289

0 commit comments

Comments
 (0)