# Shopify Price & Restock Monitor — Variant Changes (`surefeed/shopify-price-restock-monitor`) Actor

Monitor public Shopify products and variants for price drops, increases, restocks and new products. Compare observations across runs, return only changes, and export JSON or CSV. Currency-aware tracking with clear scan limits. Charged per product checked, including unchanged products.

- **URL**: https://apify.com/surefeed/shopify-price-restock-monitor.md
- **Developed by:** [gianluca de dominicis](https://apify.com/surefeed) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.50 / 1,000 product checkeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Shopify Price & Restock Monitor — Variant Changes

Monitor public Shopify storefronts for product and variant price changes, restocks, out-of-stock transitions and newly observed products. Export JSON, CSV or Excel, or connect the Apify dataset to your existing workflow.

**A product can have dozens of sizes or colours. This monitor compares each variant ID separately.** A size returning to stock does not get confused with a different size being available.

### Quick start

The example input checks up to **5 products**, without persistent monitoring or paid third-party services. At the launch price, five successfully checked products cost $0.0075. The run is bounded by 2 catalog pages and a 120-second work deadline. Available products and source access can change.

```json
{
  "startUrls": ["https://www.deathwishcoffee.com"],
  "monitor": false,
  "maxProductsPerSource": 5,
  "maxProductsTotal": 5,
  "maxPagesPerSource": 2,
  "maxRunSeconds": 120
}
```

Use your target store's canonical HTTPS URL. Supported inputs:

- Store root: `https://your-store.com`
- Collection: `https://your-store.com/collections/shoes`
- Product: `https://your-store.com/products/red-shoe`
- Optional locale prefix, such as `/en-gb/collections/shoes`

Remove tracking query strings and fragments. Redirects are not followed: supply the final public storefront domain. Custom ports, credentials, IP literals, private networks and Admin API URLs are rejected.

### Monitor only changes

```json
{
  "startUrls": ["https://www.deathwishcoffee.com"],
  "monitor": true,
  "onlyChanges": true,
  "monitorKey": "competitor-watch",
  "maxProductsPerSource": 100,
  "maxProductsTotal": 100,
  "maxPagesPerSource": 5,
  "maxRunSeconds": 240
}
```

The first successful observation of a product emits `new_product`. Later observations emit only products with detected changes when `onlyChanges` is enabled. A known product that is newly added to a watched collection is not necessarily a new product; baselines are shared by store/locale, currency, product ID and monitor key.

Keep the monitor key unchanged. Use separate keys for independent baselines. **Do not run the same store/key concurrently**: this version does not provide distributed locking. Use sequential Apify schedules. Monitoring state is stored separately from the output dataset in the named key-value store `surefeed-shopify-monitor-v1`.

Schedules and notifications are **not automatically configured**. Configure an Apify schedule and connect Make/n8n or a webhook integration if you need alerts.

### Output

One dataset row per delivered **product**, with all currently observed variants in `variants` and the changed variants in `variantChanges`. JSON is the easiest format for nested variant data. CSV/Excel retain nested lists as structured cell content; this version does not emit one row per variant.

| Field | Meaning |
|---|---|
| `productId`, `handle`, `title`, `url` | Public product identity |
| `storeUrl`, `sourceUrl` | Store/locale scope and requested source |
| `currency` | Presentment currency from public `cart.js` |
| `priceMin`, `priceMax` | Price range across returned variants |
| `available` | At least one returned variant is publicly available |
| `variants` | Variant ID, title, SKU when exposed, options, price, compare-at price and availability |
| `changeTypes` | Unique detected changes for the product |
| `variantChanges` | Variant ID, previous/current price and availability, and detected change types |
| `observedAt`, `previousObservedAt` | Observation timestamps |
| `changedSinceLastRun` | True only when a previous product baseline exists and an observed change is detected |

Change types: `snapshot`, `new_product`, `new_variant`, `price_decreased`, `price_increased`, `restocked`, `out_of_stock`, `compare_at_price_changed`.

Prices from the Ajax product endpoint are integer Shopify monetary values. `priceRaw` and `compareAtPriceRaw` retain those values; decimal price fields divide them by 100 according to Shopify Ajax conventions. The source-provided compare-at price is distinct from our previous observed price. Different currency or locale scopes use separate baselines; the tool never compares a EUR observation to a USD observation.

Example: variant A changes from €100 to €80, then €100, then €80. All three changes are detected. `restocked` requires an explicit observed `available: false` followed by `true` for the same variant.

### Billing — read before scheduling

The Store event is **`product-checked`**, one unit for each complete product successfully checked, **including unchanged products suppressed from output**. There is no per-variant fee and no separate changes fee. Snapshot rows and changed rows are delivered with that same event; unchanged checks use the event without adding an output row.

**Launch price: $1.50 / 1,000 product checks.** One `product-checked` event is $0.0015. There is no additional Actor-start or dataset-row fee. Platform usage is included in the Store event price. Confirm the price shown by Apify before running; owner/development runs can display infrastructure costs and do not establish customer revenue.

For example, monitoring 100 products daily for 30 days means up to 3,000 checks: $4.50 at the launch event price, even if only ten changes are delivered. Ten variants of one product still count as one product check.

Set Apify's maximum cost per run. An explicit zero event budget prevents product requests when pay-per-event pricing is active and zero is actually passed to the Actor. The Apify Console may interpret a typed 0 as unlimited; use a small positive cap below one check (for example $0.001 at this price) to test a no-check run in the Console. Invalid responses, malformed products and failed product retrievals do not create product-check events. Successfully checked earlier products can remain billable if a later source fails. State/output/billing operations are not a single atomic transaction: a failure after delivery can cause a change to be delivered again on retry; the run stops visibly rather than silently advancing history.

### Coverage and limitations

- Public Shopify Online Store endpoints only: catalog discovery from `products.json` and product data from the documented Ajax `products/{handle}.js` endpoint. The catalog endpoint is not guaranteed on every store.
- No Shopify login, Admin API token, CAPTCHA solving, paid unblocker or access-control bypass. Password-protected stores, custom/headless storefronts and stores disabling public JSON may be unsupported.
- The tool reads public availability, **not exact warehouse stock**. `available` may reflect a merchant's backorder or continue-selling policy.
- Missing products or variants are never declared deleted, sold out or removed. A capped/incomplete response cannot prove absence. The tool retains the last baseline of unobserved variants.
- No claim of complete catalog/variant coverage. Source limits, public endpoint restrictions, pagination, product limits, time limits and budget can restrict observations.
- A product with missing/invalid essential data is skipped without charging or changing its baseline. A store with no valid products after retrieval failures fails visibly. A valid empty catalog can succeed with no results.
- Overlapping sources in one run deduplicate product checks. Work caps count successful checks, including unchanged products. Source page limits also prevent unchanged monitors from scanning indefinitely.
- HTTP requests have a maximum 20-second timeout and at most one retry for selected temporary status codes. Long rate-limit delays are deferred rather than ignored. No proxies are purchased automatically.
- Runtime DNS must be able to resolve store domains for the production HTTP client's private-network checks. A managed environment with remote-only proxy DNS can use the explicit test adapter in the smoke script; that adapter is not used by the Actor.

`RUN_SUMMARY` records product checks, output count, unchanged count, errors, page counts, limits and partial coverage. A partial run is not proof that unseen products stopped existing.

### Development and tests

Requires Node.js 22+.

```sh
npm ci --ignore-scripts
npm test
npm start
```

Set the Actor input through Apify local storage or the Apify Console. `npm test` is offline; it covers changes, monitor continuity, budget limits, failed writes, invalid sources and coverage safeguards. `npm run smoke` checks two public stores twice with a nonbilling in-memory backend. For an environment that resolves DNS only through its managed HTTPS proxy, use `node scripts/smoke.js --curl`.

Live smoke tests make small, read-only requests. They do not configure an Apify schedule, publish the Actor, activate pricing or test paid platform billing.

### Deployment checklist

1. Create a private Actor and upload this source or connect a repository.
2. Build the Docker image; its build runs the offline tests.
3. Run the prefilled input with a 300-second hard timeout.
4. Run two sequential monitoring checks with one monitor key. Confirm output and unchanged summary.
5. Configure `product-checked` pricing and test a small maximum charge and a zero budget.
6. Review source, README, permissions and costs before approving public release.

This is an independent SureFeed tool, not affiliated with Shopify or monitored stores.

### Technical references

- [Shopify Ajax product API](https://shopify.dev/docs/api/ajax/reference/product)
- [Apify JavaScript SDK Actor reference](https://docs.apify.com/sdk/js/reference/class/Actor)

# Actor input Schema

## `startUrls` (type: `array`):

Public Shopify storefronts only. Full HTTPS URLs; optional locale prefixes. No login, private Admin API or bypass of access blocks.

## `monitor` (type: `boolean`):

Enable for recurring checks. First observation returns new_product; later runs compare observed variants. Use the same monitor key and avoid overlapping runs.

## `onlyChanges` (type: `boolean`):

With monitoring enabled, suppress unchanged output. Each successfully checked product is still one billable event, even when unchanged. No extra per-variant charge.

## `monitorKey` (type: `string`):

Independent baseline namespace, 1–80 characters. Reuse on future runs.

## `maxProductsPerSource` (type: `integer`):

Counts checked products, including unchanged products. Does not count variants separately.

## `maxProductsTotal` (type: `integer`):

Maximum successfully checked products across the run, including unchanged products. Each product is counted once per run.

## `maxPagesPerSource` (type: `integer`):

Maximum catalog pages requested per source. Limits work even when monitoring finds no changes.

## `maxRunSeconds` (type: `integer`):

HTTP requests are bounded by the deadline. Final state/storage writes can finish later. Also configure the Apify hard timeout.

## Actor input object example

```json
{
  "startUrls": [
    "https://www.deathwishcoffee.com"
  ],
  "monitor": false,
  "onlyChanges": true,
  "monitorKey": "default",
  "maxProductsPerSource": 5,
  "maxProductsTotal": 5,
  "maxPagesPerSource": 2,
  "maxRunSeconds": 120
}
```

# Actor output Schema

## `products` (type: `string`):

Delivered products and their observed variants.

## `runSummary` (type: `string`):

Checked and unchanged counts, errors, limits and event counters.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        "https://www.deathwishcoffee.com"
    ],
    "monitor": false,
    "maxProductsPerSource": 5,
    "maxProductsTotal": 5,
    "maxPagesPerSource": 2,
    "maxRunSeconds": 120
};

// Run the Actor and wait for it to finish
const run = await client.actor("surefeed/shopify-price-restock-monitor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "startUrls": ["https://www.deathwishcoffee.com"],
    "monitor": False,
    "maxProductsPerSource": 5,
    "maxProductsTotal": 5,
    "maxPagesPerSource": 2,
    "maxRunSeconds": 120,
}

# Run the Actor and wait for it to finish
run = client.actor("surefeed/shopify-price-restock-monitor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    "https://www.deathwishcoffee.com"
  ],
  "monitor": false,
  "maxProductsPerSource": 5,
  "maxProductsTotal": 5,
  "maxPagesPerSource": 2,
  "maxRunSeconds": 120
}' |
apify call surefeed/shopify-price-restock-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,surefeed/shopify-price-restock-monitor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/MaA9QV6MQphsxOZ3p/builds/RopdBdKYEgw8EDbPV/openapi.json
