# Universal Price & Stock Monitor (`symphony_bots/apify-actor-factory`) Actor

Monitor public product pages for price and stock changes. Auto-detect JSON-LD and common HTML, retain history, calculate price movements, and send webhook alerts—no site-specific setup required.

- **URL**: https://apify.com/symphony\_bots/apify-actor-factory.md
- **Developed by:** [Sinan Kuşdoğan](https://apify.com/symphony_bots) (community)
- **Categories:** E-commerce, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 results

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/platform/actors/running/actors-in-store#pay-per-event

## 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

## Universal Price & Stock Monitor

Scan public product pages, return structured price and availability data, compare it with earlier runs, and optionally send changes to an HTTPS webhook.

### Quick start

Use the prefilled public Books to Scrape URL or provide up to 200 product URLs. Automatic discovery checks Product JSON-LD first and then common HTML price, currency, availability, and product-name patterns. Add `priceSelector` or `stockSelector` only for a site that needs an override.

Example input:

```json
{
  "startUrls": [
    {
      "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
    }
  ],
  "maxConcurrency": 5,
  "maxRequestsPerMinute": 120,
  "maxRequestRetries": 3,
  "requestHandlerTimeoutSecs": 45,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

Each dataset row includes the URL, product name, raw and numeric price, currency, availability, stock flag, previous price, percentage change, change type, HTTP status, timestamp, and extraction method. The `OUTPUT` key-value-store record contains the run summary.

Example result:

```json
{
  "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
  "productName": "A Light in the Attic",
  "price": "£51.77",
  "priceValue": 51.77,
  "currency": "GBP",
  "availability": "In stock (22 available)",
  "inStock": true,
  "previousPrice": "£51.77",
  "priceChangePercentage": 0,
  "changeType": "unchanged",
  "extractionMethod": "html-fallback"
}
```

### History and change detection

The Actor stores snapshots in the named key-value store configured by `stateStoreName`. Use the same name on later runs to compare a product with its previous snapshot. `historyLimit` bounds the number of stored snapshots per product.

The first observation is marked `first-seen`. Later observations are `unchanged`, `price`, `availability`, or `price-and-availability`.

For hands-off monitoring, save a task with a stable `stateStoreName`, then attach an Apify schedule. Every scheduled run compares the new snapshot with the history retained by that named store.

### Webhook

Set an HTTPS `webhookUrl` to receive completed-run JSON when a stored product changes. `webhookOnEveryRun` also sends unchanged runs. If `webhookSecret` is present it is sent as a bearer token. Delivery failures are reported in the run summary and do not discard dataset results.

### Crawler controls

- `maxRequestsPerMinute` enforces a global request rate.
- `maxRequestRetries` controls transient-failure retries.
- `requestHandlerTimeoutSecs` bounds per-page handling time.
- `proxyConfiguration` supports Apify or custom proxies.
- The Actor only requests the URLs supplied in the input and accepts at most 200 per run.

Respect the target site's terms, robots policy, and applicable law. This Actor is designed for public, non-PII product information and does not bypass authentication.

### API example

```bash
curl -X POST "https://api.apify.com/v2/acts/YOUR_ACTOR_ID/runs?token=YOUR_TOKEN&waitForFinish=120" \
  -H "Content-Type: application/json" \
  -d '{"startUrls":[{"url":"https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"}]}'
```

Read product rows from the run's default dataset and the summary from the default key-value store record named `OUTPUT`.

### Billing behavior

The recommended Store configuration is pay per event with one charge for each successfully written dataset item. Failed URLs are reported in `OUTPUT` and do not create a billable product result. A small synthetic Actor-start charge can cover the fixed cost of short runs while keeping buyer cost predictable.

### Limitations

This MVP fetches server-rendered HTML. JavaScript-only pricing may require a future browser-based crawler. Scheduled monitoring is configured through Apify schedules; direct Telegram, Slack, and email adapters remain roadmap items, while the generic webhook is available now.

# Actor input Schema

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

Public product pages to scan. Keep each run focused; at most 200 URLs are accepted.

## `priceSelector` (type: `string`):

Optional CSS selector when automatic JSON-LD and common HTML discovery are not enough.

## `stockSelector` (type: `string`):

Optional CSS selector for availability text.

## `currency` (type: `string`):

Optional three-letter ISO currency code, for example USD or EUR.

## `stateStoreName` (type: `string`):

Named key-value store used to compare products across runs.

## `historyLimit` (type: `integer`):

Maximum number of snapshots retained for each URL.

## `webhookUrl` (type: `string`):

Optional HTTPS endpoint notified when price or availability changes.

## `webhookSecret` (type: `string`):

Optional value sent in the Authorization: Bearer header.

## `webhookOnEveryRun` (type: `boolean`):

When disabled, the webhook is called only if a stored product changed.

## `maxConcurrency` (type: `integer`):

Parallel requests. Lower this for sensitive sites.

## `maxRequestsPerMinute` (type: `integer`):

Global rate limit for this run.

## `maxRequestRetries` (type: `integer`):

Retries after a transient request or handler failure.

## `requestHandlerTimeoutSecs` (type: `integer`):

Maximum processing time for one product page.

## `proxyConfiguration` (type: `object`):

Optional Apify or custom proxy configuration for sites that require it.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
    }
  ],
  "stateStoreName": "price-stock-monitor-state",
  "historyLimit": 100,
  "webhookOnEveryRun": false,
  "maxConcurrency": 5,
  "maxRequestsPerMinute": 120,
  "maxRequestRetries": 3,
  "requestHandlerTimeoutSecs": 45,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

No description

## `summary` (type: `string`):

No description

# 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": [
        {
            "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
        }
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("symphony_bots/apify-actor-factory").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": [{ "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html" }],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("symphony_bots/apify-actor-factory").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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": [
    {
      "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
    }
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call symphony_bots/apify-actor-factory --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=symphony_bots/apify-actor-factory",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/u3WpigWocMjghRvld/builds/NeMuosd9NFdSZpI0d/openapi.json
