# Shopify Price Monitor & E-Commerce Stock Scraper (JSON-LD + AI) (`cautious_canteen_a8q/ecommerce-competitor-price-stock-monitor`) Actor

Monitors competitor product prices, stockouts, and free-shipping thresholds via Shopify JSON and Schema.org JSON-LD, outputting AI merchandising proposals and Slack alerts.

- **URL**: https://apify.com/cautious_canteen_a8q/ecommerce-competitor-price-stock-monitor.md
- **Developed by:** [Oki ei](https://apify.com/cautious_canteen_a8q) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $11.00 / 1,000 product analyzeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## E-Commerce Competitor Price & Stock Monitor (Shopify + JSON-LD + AI Alerts)

Stop checking competitor product pages manually—or building fragile browser scrapers just to track price drops, stockouts, and shipping promos.

**E-Commerce Competitor Price & Stock Monitor** asynchronously fetches competitor product URLs using lightweight HTTP (`httpx` + `BeautifulSoup`), extracts structured data from **Shopify `/products/*.json` endpoints** and **Schema.org JSON-LD (`Product` / `Offer`)**, calculates exact price differences against your `ourBaselinePrice`, and uses **Gemini 2.5 Flash** to generate actionable **merchandising proposals** and ready-to-post **Slack alerts**.

***

### Key Features

1. **Dual-Engine Product Extraction (Shopify JSON + Schema.org JSON-LD)**
   - **Shopify `/products/*.json` (and `.js` availability fallback)**: Automatically probes Shopify product JSON endpoints to extract product title, brand, SKU, variant count, price, `compareAtPrice`, and stock status.
   - **Schema.org JSON-LD (`Product` / `Offer` / `AggregateOffer`) + OpenGraph Fallback**: Works across non-Shopify storefronts by parsing `<script type="application/ld+json">` blocks and meta tags.
2. **Accurate Stock & Free Shipping Intelligence**
   - Normalizes inventory into `IN_STOCK`, `OUT_OF_STOCK`, or `UNKNOWN`.
   - Extracts free shipping conditions from JSON-LD `OfferShippingDetails` and English/Japanese storefront shipping banners (e.g., `"Free shipping on orders over $75"`, `"5,000円以上で送料無料"`).
3. **Baseline Price Gap Calculation**
   - Compares each competitor's live price against your `ourBaselinePrice` and outputs `priceDiff`, `priceDiffPercent`, and `pricePosition` (`COMPETITOR_CHEAPER`, `COMPETITOR_HIGHER`, `EQUAL`, `UNKNOWN`).
4. **Gemini 2.5 Flash Merchandising & Slack Alerts (with Built-In Fallback)**
   - Outputs structured recommendations (`recommendedAction`, `urgencyLevel`, `merchandisingProposal`, and `slackAlertMessage`) via `gemini-2.5-flash` (with automatic model fallback and rule-based fallback if no API key is supplied).
5. **Fast, Low-Cost, Browserless Architecture**
   - Runs purely on asynchronous `httpx` requests without launching heavy headless browsers, keeping Apify compute usage ultra-low.

***

### Input Parameters

| Field | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `productUrls` | `string[]` | `["https://allbirds.com/products/mens-tree-runners"]` | List of competitor product URLs (Shopify `/products/*` or any JSON-LD store). |
| `ourBaselinePrice` | `integer` | `100` | Your baseline product price for computing `priceDiff` and `priceDiffPercent`. |
| `geminiApiKey` | `string` (secret) | `""` | Optional Google Gemini API key (BYOK). Falls back to `GEMINI_API_KEY` env var if set. |
| `geminiModel` | `string` | `""` | Optional Gemini model override (defaults to `gemini-2.5-flash`). |

***

### Sample Output (Dataset Item)

```json
{
  "url": "https://allbirds.com/products/mens-tree-runners",
  "productName": "Men's Tree Runners",
  "brand": "Allbirds",
  "competitorPrice": 98.0,
  "compareAtPrice": 110.0,
  "currency": "USD",
  "stockStatus": "IN_STOCK",
  "freeShippingCondition": "Free shipping on orders over $75",
  "sku": "A10012",
  "variantCount": 8,
  "extractionSources": ["shopify_json", "json_ld"],
  "extractionErrors": [],
  "ourBaselinePrice": 100.0,
  "priceDiff": -2.0,
  "priceDiffPercent": -2.0,
  "pricePosition": "COMPETITOR_CHEAPER",
  "recommendedAction": "LAUNCH_PROMO_BUNDLE",
  "urgencyLevel": "MEDIUM",
  "merchandisingProposal": "Competitor Men's Tree Runners is priced at 98.0 USD (-2.0 USD / -2.0% vs our 100.0 USD baseline) with free shipping over $75. Launch a limited-time bundle or match free-shipping parity rather than cutting list price directly.",
  "slackAlertMessage": "*Competitor Price & Stock Alert* [MEDIUM]\n• *Product:* Men's Tree Runners\n• *Competitor Price:* 98.0 USD (vs Baseline 100.0 USD: -2.00 USD (-2.00%))\n• *Stock:* `IN_STOCK` | *Shipping:* Free shipping on orders over $75\n• *Recommended Action:* `LAUNCH_PROMO_BUNDLE`",
  "aiAnalysisMode": "Gemini",
  "checkedAt": "2026-11-16T15:30:00+00:00"
}
```

***

### Pricing (Pay-Per-Event)

This Actor uses transparent **Pay-Per-Event** monetization:

- **`product-analyzed`** (`count=1`): Charged once per product URL analyzed and pushed to the dataset.

***

### Integration with Slack, n8n, Make, and AI Agents (MCP)

1. **Automated Slack Alerts (n8n / Make)**:
   - Schedule this Actor daily or hourly via Apify Schedules or n8n's Apify node.
   - Filter items where `urgencyLevel == "HIGH"` (e.g., `OUT_OF_STOCK` or major price undercut) and forward `slackAlertMessage` straight to a Slack Incoming Webhook.
2. **AI Agent Integration (Apify MCP)**:
   - Connect via `https://mcp.apify.com` so your AI merchandising assistant can inspect live competitor prices, stockouts, and shipping offers on demand.

# Actor input Schema

## `productUrls` (type: `array`):

List of competitor e-commerce product URLs to monitor (supports Shopify /products/\* URLs and any store with Schema.org Product/Offer JSON-LD).

## `ourBaselinePrice` (type: `integer`):

Your baseline product price for calculating price difference (priceDiff and priceDiffPercent) against each competitor product.

## `geminiApiKey` (type: `string`):

Google Gemini API key for AI merchandising proposals and Slack alert generation. Falls back to GEMINI_API_KEY environment variable if omitted.

## `geminiModel` (type: `string`):

Optional Gemini model name override (defaults to gemini-2.5-flash with automatic fallback discovery).

## Actor input object example

```json
{
  "productUrls": [
    "https://allbirds.com/products/mens-tree-runners"
  ],
  "ourBaselinePrice": 100,
  "geminiModel": ""
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing all monitored competitor product records and AI merchandising insights.

# 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 = {
    "productUrls": [
        "https://allbirds.com/products/mens-tree-runners"
    ],
    "ourBaselinePrice": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("cautious_canteen_a8q/ecommerce-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 = {
    "productUrls": ["https://allbirds.com/products/mens-tree-runners"],
    "ourBaselinePrice": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("cautious_canteen_a8q/ecommerce-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 '{
  "productUrls": [
    "https://allbirds.com/products/mens-tree-runners"
  ],
  "ourBaselinePrice": 100
}' |
apify call cautious_canteen_a8q/ecommerce-competitor-price-stock-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,cautious_canteen_a8q/ecommerce-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/WmBUweOoR5lkjgZTz/builds/NYdtYwP9y05vTwIir/openapi.json
