# Shopify Store Assortment Comparison (`practical_ai_lab_jp/pal-shopify-assortment-compare`) Actor

Compare selected store assortments, overlap and published price bands using bounded product feeds. For Shopify market intelligence and category managers. Check the live Pricing tab and input limits.

- **URL**: https://apify.com/practical_ai_lab_jp/pal-shopify-assortment-compare.md
- **Developed by:** [Practical AI Lab](https://apify.com/practical_ai_lab_jp) (community)
- **Categories:** E-commerce, Developer tools
- **Security:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 store assortment comparison reports

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

## Shopify Store Assortment Comparison

Compares **2-3 public Shopify stores** using their public `/products.json` feeds and returns vendor and category assortment, price bands, overlapping SKUs, and change-friendly JSON/CSV. Built by PAL (Practical AI Lab).

No Amazon or Google access, no proxies, no logins, no private data. Only the public product feed and `robots.txt` of the stores you list are requested.

### Safety and politeness

- **robots.txt is honored.** If it disallows `/products.json`, that store is skipped. If `robots.txt` cannot be read (anything other than 200, 404 or 410), the Actor fails closed for that store. A `Crawl-delay` (capped at 10 s) is respected.
- **SSRF protection.** Only `https` on the default port, no credentials, no IP-literal or internal-looking host names. Every host is resolved first, and the request is refused if any answer is a non-public address. The connection is then pinned to the validated IP.
- **Redirects** are followed manually (max 3), re-validated at every hop, and limited to the same site (a `www.` toggle is allowed). Use a store's final domain if it redirects elsewhere.
- **Bounded**: at most 2,500 products per store, 40 requests per store, 6 MB per response, uncompressed responses only, a configurable delay (default 1 s) and timeout. Stores are read one after another.
- Only fields needed for comparison are kept (no descriptions, images or customer data).

### Output

Dataset rows by `recordType`:

| recordType | Content |
|---|---|
| `summary` | Stores, totals, overlapping SKUs, SKUs in every store, shared vendors, currency note. |
| `store_summary` | Products, variants, vendors, categories, min/median/max price, on-sale and unavailable variants. |
| `price_band` | Products per price band per store. |
| `vendor_assortment`, `category_assortment` | Products, variants and median price per store for each vendor or product type. |
| `sku_overlap` | SKUs found in 2+ stores (normalized: trimmed, case-insensitive), cheapest store and price delta %. |
| `product_variant` | One row per variant with a stable `rowKey` (`store:variantId`) and a `rowHash`. |
| `change` | Only when `previousSnapshot` is given: added, removed, price-changed and availability-changed variants. |
| `store_error` | A store that could not be read (never charged). |

Key-value store: `products.csv`, `sku_overlap.csv`, `vendor_assortment.csv`, `category_assortment.csv`, `SNAPSHOT` (compact `rowKey -> [hash, price, available]`) and `OUTPUT`.

To track changes, pass the previous run's `SNAPSHOT` as `previousSnapshot` in the next run.

### Input

`storeUrls` (2-3), `maxProductsPerStore` (default 500), `priceBands` (default `[25, 50, 100, 200, 500]`), `requestDelaySeconds`, `timeoutSeconds`, `includeProductRows`, `previousSnapshot`.

### Limits

- `products.json` does not state a currency. Prices stay in each store's own currency, so compare price bands across stores only when the currencies match.
- Some stores disable or restrict the feed. These are reported as `store_error`. If fewer than 2 stores can be read, the run fails without a charge.
- SKU overlap needs stores to fill in SKUs.

### Pricing event

Pricing uses pay-per-event. The billing event name is `shopify-assortment-compare-report`, charged once per successful comparison. Failed runs and `store_error` rows are not charged.

### Local tests

```
python3 -m unittest discover -s tests
```

All tests are offline (fake transport and resolver).

# Actor input Schema

## `storeUrls` (type: `array`):

Public Shopify storefront domains or https URLs, for example https://example-store.com. Two or three different stores. Use each store's final domain because cross-domain redirects are refused.

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

Upper bound on products read from each store (250 per request).

## `priceBands` (type: `array`):

Ascending band edges in store currency. Default \[25, 50, 100, 200, 500] gives bands 0-25, 25-50, 50-100, 100-200, 200-500 and 500+.

## `requestDelaySeconds` (type: `number`):

Minimum pause between requests to the same store. A larger robots.txt Crawl-delay (max 10 s) wins.

## `timeoutSeconds` (type: `integer`):

Timeout for each request.

## `includeProductRows` (type: `boolean`):

Push one change-friendly row per variant (stable rowKey and rowHash).

## `previousSnapshot` (type: `object`):

Optional SNAPSHOT record from an earlier run. Adds `change` rows for added, removed, price-changed and availability-changed variants.

## Actor input object example

```json
{
  "maxProductsPerStore": 500,
  "priceBands": [
    25,
    50,
    100,
    200,
    500
  ],
  "requestDelaySeconds": 1,
  "timeoutSeconds": 15,
  "includeProductRows": true
}
```

# Actor output Schema

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

Structured records from this Actor run; downloadable as JSON or CSV.

# 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("practical_ai_lab_jp/pal-shopify-assortment-compare").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("practical_ai_lab_jp/pal-shopify-assortment-compare").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 practical_ai_lab_jp/pal-shopify-assortment-compare --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,practical_ai_lab_jp/pal-shopify-assortment-compare"
        }
    }
}
```

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/jSnbXwqcoKE9sFPif/builds/SVAend8LJGx83FlvG/openapi.json
