Collect a useful product record
Treat this as an implementation recipe, not a customer case study. For each authorized target, request the fields your application needs, such as title, numeric price, currency, and availability. Required fields can be missing or ambiguous on a target; validate the returned values before treating an observation as current.
Keep raw observations separate from derived price-change events. A missing price is not zero, an empty response is not proof of removal, and a locale change can alter the displayed currency. The linked extraction example submits, polls, validates, and prints the JSON returned for a permitted test URL.
- In your application, maintain authorized target URLs, stable product identities, locale assumptions, and a scheduler or queue.
- For each observation, submit one individual structured Data API request and retain its idempotency key for an exact-body retry.
- Poll request status and fetch the result only after completion; handle page errors and extraction errors separately.
- Validate required fields, then persist the API result with its request ID and a client-generated observation timestamp.
- Compare observations for the same product only after normalizing currency and locale; apply your own staleness and alert-delivery rules.
Schedule around the business decision
Determine collection frequency according to your application's reaction speed, available capacity, and target-site access constraints. RunHarvester handles each submitted request; it does not schedule recurring checks or maintain your product history.
Keep an idempotency key with each logical submission so an uncertain network retry does not duplicate work. Use a fresh key for a new observation. Your application owns queueing, resubmission decisions, and delivery of any alert.
Separate data collection from monitoring operations
RunHarvester provides per-request page acquisition, structured extraction, request status, retained results, public error information, and an explicit retry operation. It does not run recurring monitoring jobs.
Your application owns the schedule and queue, durable history, stable product identity, currency and locale normalization, comparison and deduplication rules, staleness policy, retry decisions, and notification delivery. The example below builds an application-owned observation and change events; it does not write to storage or send an alert.
from datetime import datetime, timezone
from decimal import Decimal
def build_observation(request_state, result, product_key, product_url):
if request_state.get("status") != "completed":
raise ValueError("Only completed requests can become observations")
if request_state.get("id") != result.get("id"):
raise ValueError("Request status and result IDs do not match")
extraction = result.get("extraction")
if not isinstance(extraction, dict) or extraction.get("status") != "completed":
raise ValueError("Extraction did not complete")
data = result.get("data")
if not isinstance(data, dict):
raise ValueError("Expected structured product data")
if not isinstance(data.get("title"), str) or not data["title"].strip():
raise ValueError("Missing product title")
price = data.get("price")
if isinstance(price, bool) or not isinstance(price, (int, float)):
raise ValueError("Expected a numeric price")
if not isinstance(data.get("currency"), str) or not data["currency"].strip():
raise ValueError("Missing currency")
if not isinstance(data.get("availability"), str) or not data["availability"].strip():
raise ValueError("Missing availability")
# This record shape and timestamp are created by your application.
return {
"product_key": product_key,
"product_url": product_url,
"request_id": request_state["id"],
"observed_at": datetime.now(timezone.utc).isoformat(),
"data": data,
}
def build_change_events(previous, current):
if previous is None:
return []
if previous["product_key"] != current["product_key"]:
raise ValueError("Compare observations for the same product")
old = previous["data"]
new = current["data"]
events = []
if old["currency"] == new["currency"]:
old_price = Decimal(str(old["price"]))
new_price = Decimal(str(new["price"]))
if old_price != new_price:
events.append({
"type": "price_changed",
"product_key": current["product_key"],
"previous_price": str(old_price),
"current_price": str(new_price),
"currency": new["currency"],
"observed_at": current["observed_at"],
})
if old["availability"] != new["availability"]:
events.append({
"type": "availability_value_changed",
"product_key": current["product_key"],
"previous_availability_value": old["availability"],
"current_availability_value": new["availability"],
"observed_at": current["observed_at"],
})
return events
# state and result are the completed API responses from the extraction example.
observation = build_observation(state, result, product_key, product_url)
events = build_change_events(previous, observation)
# Your registry supplies product_key and product_url; your storage supplies previous.
# Persist observation and deliver events through your own infrastructure.Measure valid observations, not only successful requests
Track missing fields, unexpected record counts, stale observations, and changes in effective route cost. Save diagnostic identifiers when collection fails. Test layout variants before applying a recipe to an entire catalog.
Inspect cache behavior when freshness matters and use the documented cache controls deliberately. Target terms, permissions, privacy requirements, and the meaning of the collected data remain part of the integration design.