# Shopify Store Scraper (`ghostgrid/shopify-store-scraper`) Actor

Scrape products from Shopify stores via /products.json API with HTML fallback.

- **URL**: https://apify.com/ghostgrid/shopify-store-scraper.md
- **Developed by:** [GhostGrid](https://apify.com/ghostgrid) (community)
- **Categories:** E-commerce, Lead generation, Automation
- **Stats:** 2 total users, 2 monthly users, 85.7% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 1,000 product scrapeds

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

## Shopify Store Scraper

Scrapes product data from Shopify stores with optional price and stock change tracking.

Most Shopify stores expose a `/products.json` endpoint that returns structured JSON. This actor uses that endpoint by default and falls back to HTML scraping when it's not available.

### Input

| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `storeUrl` | string | yes | - | Base URL of the Shopify store |
| `maxItems` | integer | no | 100 | Max products to return |
| `collection` | string | no | - | Collection handle to scrape (e.g. `all`, `frontpage`) |
| `track_changes` | boolean | no | false | Enable price/stock change tracking via KV store baseline |
| `baseline_key` | string | no | `product-baseline` | KV store key for storing the product baseline |

### Output

Each product item contains:

- `title` - Product name
- `url` - Product page URL
- `price` - Price from first variant
- `compare_at_price` - Original price if on sale
- `vendor` - Brand/vendor name
- `product_type` - Product category
- `tags` - List of tags
- `images` - List of image URLs
- `variants` - List of variant objects (id, title, price, sku, availability)
- `description` - HTML description

#### Change Tracking Records

When `track_changes` is enabled, additional records are pushed to the dataset:

**price\_change** - When a product's price differs from the baseline:

- `type`, `product_url`, `product_title`, `old_price`, `new_price`, `change_amount`, `change_percent`, `crawled_at`

**stock\_change** - When a product's availability changes:

- `type`, `product_url`, `product_title`, `old_available`, `new_available`, `crawled_at`

**new\_product** - When a product appears that was not in the baseline:

- `type`, `product_url`, `product_title`, `price`, `crawled_at`

**removed\_product** - When a baseline product is no longer found:

- `type`, `product_url`, `product_title`, `last_price`, `crawled_at`

### Usage

Basic scrape:

```json
{
  "storeUrl": "https://example.myshopify.com",
  "maxItems": 50,
  "collection": "all"
}
```

With change tracking:

```json
{
  "storeUrl": "https://example.myshopify.com",
  "maxItems": 50,
  "track_changes": true
}
```

### How it works

1. Tries `GET /products.json` (paginated, 250 per page)
2. If that fails, crawls HTML collection and product pages with BeautifulSoup
3. Pushes each product to the Apify dataset
4. If `track_changes` is enabled, loads the previous baseline from the KV store, compares prices and stock, pushes change records, then saves the new baseline

### Running locally

```bash
pip install -r requirements.txt
APIFY_TOKEN=your_token python -m shopify_scraper
```

# Actor input Schema

## `storeUrl` (type: `string`):

The base URL of the Shopify store (e.g. https://example.myshopify.com or https://example.com)

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

Maximum number of products to scrape.

## `collection` (type: `string`):

Optional collection handle to scrape (e.g. 'all', 'frontpage').

## `track_changes` (type: `boolean`):

Enable price and stock change tracking. Stores a baseline snapshot in the KV store and compares against it on each run.

## `baseline_key` (type: `string`):

Key used to store/retrieve the product baseline in the KV store.

## Actor input object example

```json
{
  "storeUrl": "https://b2b-demo-store.myshopify.com",
  "maxItems": 5,
  "track_changes": false,
  "baseline_key": "product-baseline"
}
```

# 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 = {
    "storeUrl": "https://b2b-demo-store.myshopify.com",
    "maxItems": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("ghostgrid/shopify-store-scraper").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 = {
    "storeUrl": "https://b2b-demo-store.myshopify.com",
    "maxItems": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("ghostgrid/shopify-store-scraper").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 '{
  "storeUrl": "https://b2b-demo-store.myshopify.com",
  "maxItems": 5
}' |
apify call ghostgrid/shopify-store-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

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