# Shopify Competitor Price Tracker & Stock Monitor (`egeusta/shopify-competitor-price-stock-monitor`) Actor

Track Shopify competitor prices, product availability and catalog changes across public stores with automated change detection.

- **URL**: https://apify.com/egeusta/shopify-competitor-price-stock-monitor.md
- **Developed by:** [Ege Usta](https://apify.com/egeusta) (community)
- **Categories:** E-commerce
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Shopify Competitor Price & Stock Monitor

Track competitor pricing and product availability for ecommerce research,
pricing intelligence and catalog monitoring. Add public Shopify stores and get
structured snapshots plus changes between runs.

Monitors one or more **public** Shopify stores via their `/products.json`
endpoint and emits deterministic change events between runs.

### Input

| Field | Type | Default | Notes |
| --- | --- | --- | --- |
| `storeDomains` | string\[] | — (required) | `shop.com`, `https://shop.com`, or `shop.myshopify.com`. Non-http(s) schemes, IP literals and `localhost` are rejected. Duplicates are collapsed. |
| `maxProductsPerStore` | integer | `2000` | Distinct-product cap per store. |
| `maxPagesPerStore` | integer | `20` | `/products.json` page cap (page size 250). |
| `requestTimeoutSecs` | integer | `30` | Per-request timeout. |
| `concurrency` | integer | `3` | Stores fetched in parallel. |
| `minRequestDelayMs` | integer | `500` | Client-side rate limit between paginated requests. |
| `maxResponseBytes` | integer | `5000000` | Byte ceiling per response. |
| `emitSnapshotRows` | boolean | `true` | Also write the current variant-level catalog to the dataset. |
| `resetSnapshot` | boolean | `false` | Ignore the stored snapshot; treat as a fresh baseline. |

### How comparison works

Each run fetches the current catalog, loads the previous snapshot from the
key-value store (`SNAPSHOT-<domain>`), diffs them deterministically, writes the
new snapshot, and appends events to the dataset.

- **First run** for a domain (or `resetSnapshot`) establishes the baseline and
  emits **no** change events (`firstRun: true` in the summary).
- Event types: `new_product`, `removed_product` (a product id appeared /
  disappeared); `price_changed` (a shared variant's price, compare-at price or
  SKU moved, or a new variant appeared under an existing product with
  `before: null`); `availability_changed` (a shared variant's `available` flag
  flipped, or a variant disappeared from a surviving product with
  `after.removed: true`).
- Events are fully sorted (type → productId → variantId) so re-running on
  unchanged data produces byte-identical output.

### Resilience

- A request failure **stops pagination for that store**, is counted in
  `requestFailures` / `failuresByReason`, and never throws.
- If **every** page fails (`pagesFetched === 0`) the stored snapshot is left
  untouched and no events are emitted — a network blip never looks like "all
  products removed".
- If a previously populated store (> 5 products) suddenly returns an empty
  catalog, the run flags `suspicious-empty-catalog` and refuses to overwrite the
  snapshot.
- One failing store never affects the others (bounded-concurrency, per-store
  isolation).

### Output

`type: "change"` and `type: "snapshot"` rows — see `.actor/dataset_schema.json`.
A `SUMMARY` record with per-domain reports, totals, `changeCounts` and
`failuresByReason` is written to the key-value store.

### Safety

Only the public `/products.json` endpoint is used — no admin API, no tokens, no
private data. All requests go through the shared `safeFetchJson` (https upgrade,
DNS checked against private ranges, manual redirects, JSON content-type
allow-list, byte ceiling, timeout cleared in `finally`).

### Known limitations

- Stores that disable `/products.json`, sit behind Cloudflare bot protection, or
  are not Shopify will yield `catalog-fetch-failed` / an empty parse rather than
  data. This is reported, not fatal.
- `available` reflects the storefront `available` flag, not real-time inventory
  counts (Shopify does not expose those publicly).

### Commands

```bash
npm ci                                                  # monorepo root
npm run check -w shopify-competitor-price-stock-monitor
npm run smoke -w shopify-competitor-price-stock-monitor  # offline, two-run diff
npx apify validate-schema
```

### Deployment

Not deployed here. `apify push` is intentionally not run — the lead engineer
handles deployment.

# Actor input Schema

## `storeDomains` (type: `array`):

Public Shopify store domains to monitor. Accepts "shop.com", "https://shop.com" or "shop.myshopify.com". Non-http(s) schemes, IPs and localhost are rejected.

## `maxProductsPerStore` (type: `integer`):

Upper bound on distinct products collected per store.

## `maxPagesPerStore` (type: `integer`):

Upper bound on /products.json pages requested per store (page size is 250).

## `requestTimeoutSecs` (type: `integer`):

Per-request timeout for each /products.json page fetch.

## `concurrency` (type: `integer`):

Number of stores fetched in parallel.

## `minRequestDelayMs` (type: `integer`):

Client-side rate limiting: minimum pause between paginated requests to the same store.

## `maxResponseBytes` (type: `integer`):

Hard ceiling on bytes read from a single /products.json response.

## `emitSnapshotRows` (type: `boolean`):

When enabled, the current variant-level catalog is written to the dataset alongside change events.

## `resetSnapshot` (type: `boolean`):

Ignore any stored snapshot and treat this run as a fresh baseline (no change events).

## Actor input object example

```json
{
  "maxProductsPerStore": 2000,
  "maxPagesPerStore": 20,
  "requestTimeoutSecs": 30,
  "concurrency": 3,
  "minRequestDelayMs": 500,
  "maxResponseBytes": 5000000,
  "emitSnapshotRows": true,
  "resetSnapshot": false
}
```

# Actor output Schema

## `results` (type: `string`):

Structured Shopify product snapshots and detected catalog changes.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("egeusta/shopify-competitor-price-stock-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("egeusta/shopify-competitor-price-stock-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 '{}' |
apify call egeusta/shopify-competitor-price-stock-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,egeusta/shopify-competitor-price-stock-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/lgur5czjHZjmgeTQ5/builds/pRd1I7UCiov30zvVK/openapi.json
