# E-commerce Price & Stock Monitor (`gokhanucar/ecom-price-monitor`) Actor

Monitors product prices, stock levels, availability and ratings from e-commerce sites. Auto-detects listing vs product pages, handles pagination, and outputs clean JSON/CSV. Schedule for daily/weekly price tracking. Retries and error logging built in.

- **URL**: https://apify.com/gokhanucar/ecom-price-monitor.md
- **Developed by:** [Gökhan UÇAR](https://apify.com/gokhanucar) (community)
- **Categories:** E-commerce
- **Stats:** 1 total users, 0 monthly users, 100.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/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## E-commerce Price & Stock Monitor

**Monitor product price, stock and availability automatically** from any category/listing page or direct product URL on [books.toscrape.com](https://books.toscrape.com) — a public e-commerce sandbox site. Give it a category page and it auto-paginates through every product; give it direct product URLs and it scrapes them straight away. Clean, structured data lands in your dataset in seconds, ready to download as JSON, CSV or Excel, or to schedule on the Apify platform for recurring price/stock tracking.

> This Actor targets the books.toscrape.com sandbox as a portfolio demonstration of a production-style monitoring pattern. The same architecture (content-based page detection, auto-pagination, per-item error isolation, scheduled re-runs) is what a real price/stock monitor for a live store would use.

### Why use this Actor?

- **Price monitoring** — track competitor or supplier prices over time by scheduling daily/hourly runs and diffing dataset exports.
- **Stock alerting** — know the moment a product goes out of stock, or drops below a threshold, by feeding the `stockCount` field into your own alerting.
- **Catalog audits** — pull a clean, structured snapshot of an entire category (title, price, rating, category) without writing any scraping code.
- **No browser overhead** — built on `CheerioCrawler` (HTTP + HTML parsing only), so it's fast and cheap to run on the Apify platform compared to a headless-browser actor.

### How to use

1. Open the Actor and go to the **Input** tab.
2. Add one or more **Start URLs** — mix and match freely:
   - A category/listing URL (e.g. the homepage, or a category like `/catalogue/category/books/mystery_3/index.html`) — the Actor follows pagination automatically and visits every product on it.
   - A direct product URL — the Actor scrapes it immediately, no listing page needed.
3. Set **Max products to scrape** (`maxItems`) to cap how many products get scraped in this run (default `100`).
4. Click **Start**. Results stream into the **Dataset** tab as they're scraped.
5. To monitor a category over time, save the run as a **Task** and add a **Schedule** (Apify Console → Schedules → Create new → pick your Task → set a cron interval, e.g. every 6 hours).

### Input

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `startUrls` | array of `{ url }` | yes | `[{ "url": "https://books.toscrape.com/" }]` | Category/listing and/or direct product URLs. |
| `maxItems` | integer | no | `100` | Stops the run once this many products have been scraped. |

Example input:

```json
{
    "startUrls": [
        { "url": "https://books.toscrape.com/catalogue/category/books/mystery_3/index.html" },
        { "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html" }
    ],
    "maxItems": 50
}
````

### Output

Each scraped product is one row in the **Dataset**, and the full set is also written as a CSV file to the **Key-value store** under the key `OUTPUT_CSV` (visible in the Storage tab once a run finishes). You can also export the dataset directly from the Console in JSON, CSV, Excel, XML or RSS.

Example dataset item:

```json
{
    "title": "A Light in the Attic",
    "price": 51.77,
    "currency": "GBP",
    "availability": "In stock (22 available)",
    "stockCount": 22,
    "rating": 3,
    "category": "Poetry",
    "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
    "scrapedAt": "2026-06-27T08:26:11.488Z"
}
```

#### Data fields

| Field | Type | Description |
|---|---|---|
| `title` | string | Product title. |
| `price` | number | Current price, numeric only (no currency symbol). |
| `currency` | string | 3-letter currency code, derived from the price symbol (`£`→GBP, `$`→USD, `€`→EUR). |
| `availability` | string | Raw availability text as shown on the page. |
| `stockCount` | number | null | Units in stock, parsed out of `availability` when present. |
| `rating` | number | null | 1–5 star rating. |
| `category` | string | null | Product category from the page breadcrumb. |
| `url` | string | Final product page URL. |
| `scrapedAt` | string | ISO 8601 timestamp of when the item was scraped. |

### Pricing

This Actor uses `CheerioCrawler` (plain HTTP requests, no browser), so it's cheap to run: roughly 100 products take ~25 seconds of compute. On the [Apify Free plan](https://apify.com/pricing), that's a negligible fraction of the monthly compute-unit allowance — you can comfortably run scheduled monitoring on hundreds of products per day for free.

### Tips

- Point `startUrls` at a narrow category instead of the homepage to monitor a focused product set with fewer requests.
- Lower `maxItems` for quick test runs; raise it (or omit a low value) for full catalog snapshots.
- Combine with Apify's [Schedule](https://docs.apify.com/platform/schedules) feature for recurring monitoring, and the [Webhooks](https://docs.apify.com/platform/integrations/webhooks) feature to get notified when a run finishes.

### FAQ & limitations

- **Is this legal?** books.toscrape.com is a public sandbox built specifically for scraping practice — there's no Terms-of-Service concern here. For any real store, always check `robots.txt` and the site's ToS before scraping.
- **What if a page fails to load or doesn't look like a product/listing page?** The Actor logs it and continues; a count and list of failed URLs is printed in the run log at the end. No partial/incorrect records are pushed for a failed page.
- **Does it support free-text search?** Not currently — books.toscrape.com's search is JavaScript-driven and doesn't expose a crawlable results page. Category/listing and direct product URLs are fully supported.
- Found a bug or want this adapted to a different e-commerce site? Open an issue on the Actor's Issues tab — custom adaptations are available on request.

### Local development

```bash
npm install
apify run            # uses storage/key_value_stores/default/INPUT.json as input
npm test             # unit tests for the pure parsers/CSV builder + a live crawl smoke test
```

To deploy:

```bash
apify login
apify push
```

# Actor input Schema

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

Category/listing URLs (auto-paginated) and/or direct product URLs to monitor.

## `maxItems` (type: `integer`):

Stops once this many products have been scraped. Listing pages are auto-paginated only as far as needed to reach this limit.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://books.toscrape.com/"
    }
  ],
  "maxItems": 100
}
```

# Actor output Schema

## `results` (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/"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gokhanucar/ecom-price-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": [{ "url": "https://books.toscrape.com/" }] }

# Run the Actor and wait for it to finish
run = client.actor("gokhanucar/ecom-price-monitor").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/"
    }
  ]
}' |
apify call gokhanucar/ecom-price-monitor --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "E-commerce Price & Stock Monitor",
        "description": "Monitors product prices, stock levels, availability and ratings from e-commerce sites. Auto-detects listing vs product pages, handles pagination, and outputs clean JSON/CSV. Schedule for daily/weekly price tracking. Retries and error logging built in.",
        "version": "1.0",
        "x-build-id": "tO0OXN8oIJreaEtQd"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/gokhanucar~ecom-price-monitor/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-gokhanucar-ecom-price-monitor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/gokhanucar~ecom-price-monitor/runs": {
            "post": {
                "operationId": "runs-sync-gokhanucar-ecom-price-monitor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/gokhanucar~ecom-price-monitor/run-sync": {
            "post": {
                "operationId": "run-sync-gokhanucar-ecom-price-monitor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "startUrls"
                ],
                "properties": {
                    "startUrls": {
                        "title": "Start URLs",
                        "type": "array",
                        "description": "Category/listing URLs (auto-paginated) and/or direct product URLs to monitor.",
                        "default": [
                            {
                                "url": "https://books.toscrape.com/"
                            }
                        ],
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "maxItems": {
                        "title": "Max products to scrape",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Stops once this many products have been scraped. Listing pages are auto-paginated only as far as needed to reach this limit.",
                        "default": 100
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
