# Check the same product prices and stock again

Use this for up to eight authorized HTTPS product pages with a supported, unambiguous declared offer. It saves the last good baseline on your computer, so you do not have to copy JSON between runs. This is a small repeat-check client, not a claim of Amazon/Walmart coverage or an unattended monitoring service.

[Start the one-click sandbox on Apify](https://apify.com/merciful_goldenlarch/supplier-price-stock-diff/examples/supplier-stock-baseline-example), then use the client below when you want to repeat the check without copying the baseline.

## Run a sandbox check first

The client requires the Stock Actor's output-delivery contract, tested on build 0.4.1. An older or incompatible build without DELIVERY_STATUS is deliberately refused.

On macOS or Linux, with Python 3.8+ and APIFY_TOKEN set in your environment:

```sh
printf '{}\n' > watch.json
python3 stock_watch.py --config watch.json
python3 stock_watch.py --config watch.json
```

Each command can start one Apify run with a **$0.05 maximum Actor charge**, and Apify may charge your account. The empty configuration uses Books to Scrape practice pages, whose data is a sandbox and not commercial supplier pricing. The first run saves the baseline; the second checks again and reports what it actually observes, without promising the live page will remain unchanged.

## Use your own supported pages

Create `watch.json` with your authorized page links:

```json
{
  "productUrls": ["https://YOUR-SUPPLIER.example/YOUR-EXACT-PRODUCT"],
  "permissionConfirmed": true
}
```

Replace the placeholder URL before running. A supplier's native exact-variant alerts or product feed may be simpler, particularly for pages that this Actor cannot read. Unsupported, blocked, ambiguous, changed-identity or failed captures remain unresolved rather than becoming price or stock alerts. The Actor checks exposed offer identifiers and supported variant metadata; it does not establish every pack, destination, promotion or seller condition.

Run the same command whenever you want another check, or integrate it into your existing authorized scheduler. This example does not create a schedule or send notifications. Keep the same state file for the same configuration, and choose a different `--state` path when changing the URLs.

## Read the result

The command prints the actual run ID, checked count, change count and unresolved count, while `stock-results/RUN_ID/review.csv` contains the findings and next actions. An unresolved count is work to inspect, not a successful no-change result. `evidence.json` retains the machine-readable rows and baseline, and `receipt.json` records the build and reported usage separately from charge-event counts.

The client verifies successful run status, matching input/Actor identity, complete Dataset delivery, one check per watched URL and consistent counts before updating `.stock-watch.json`. Failed or ambiguous captures cannot overwrite the corresponding last good offer. Keep these local files private if your links or pricing are confidential; the configured inputs and authorized pages are processed in your Apify account.

## Recover without duplicate runs

If a run is still running or a download is interrupted, repeat the same command, which polls the saved run ID instead of submitting another one. Concurrent CLI invocations using the same state file are refused.

If the initial submission response was lost, inspect Apify Runs first and identify the run created by that command. Then use its real ID:

```sh
python3 stock_watch.py --config watch.json --recover-run ACTUAL_RUN_ID
```

The client checks that the recovered run belongs to the Actor and has the same input. It never automatically repeats an uncertain submission. If there is no matching run, reconcile the pending state before starting a new check; do not guess an ID or delete the state to retry blindly.

To exercise the isolated transport tests without network access or charges, run `python3 -m unittest discover -s tests -v`.
