# Shopify Vendor & Assortment Intelligence Report (`practical_ai_lab_jp/pal-shopify-merchant-vendor-intelligence-suite`) Actor

Turns public Shopify storefront feeds into one severity-ranked supplier planning report covering vendor mix, assortment shifts, price dispersion, missing options and new categories, with dated baselines and explicit sampling caveats.

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

## Pricing

from $1.00 / 1,000 supplier planning reports

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

## Shopify Vendor & Assortment Intelligence Report

One run turns public Shopify storefront feeds into a **single severity-ranked supplier planning report** for a multi-brand retail buyer. It does not just list products. It joins five buyer outcomes, compares them with your last dated baseline, and states how much each number can be trusted.

### What the report answers

| Buyer outcome | Question | Example signals |
| --- | --- | --- |
| `vendor_representation` | Which vendors does each store lean on, and is that changing? | vendor concentration, vendor share shift, vendor added, vendor dropped, single-brand store |
| `assortment_shift` | How much did the visible range turn over since the last run? | assortment turnover, price movement on retained products, currency change |
| `price_dispersion` | Where are public prices widely spread or out of line? | category price dispersion, vendor price position, cross-store price gap |
| `option_completeness` | Which products omit an option that their peers publish (for example Size)? | missing expected option |
| `category_launch` | Which categories are new, or look newly launched? | new category versus baseline, recent category launch inferred from published dates |

All findings land in one ranked list (rank 1 is most important) with severity, a priority score, the store, vendor and category they concern, example product links, a suggested next step, and a confidence label. Store summaries and a run summary join to the findings by `storeDomain`.

### Sample input

```json
{
    "storeUrls": [
        "https://www.deadstock.ca",
        "https://bdgastore.com"
    ],
    "maxProductsPerStore": 250,
    "baselineLabel": "autumn-buy",
    "updateBaseline": true,
    "launchWindowDays": 30
}
```

The two stores above are illustrative. Replace them with public storefronts you are permitted to analyze. Only the store root is accepted (no path, query, port or credentials), and at most 10 stores per run.

Run it again on a later date with the **same baseline label** to unlock the cross-run signals. The first run for a store only creates the baseline and reports single-snapshot signals.

### Output

**Dataset** (default). Every record has `recordType`:

- `run_summary`: stores requested, analyzed and failed; findings by severity and outcome; `billableReport`; caveats.
- `store_summary`: one per analyzed store with planning rank, sample size, possible truncation, vendor and category counts, baseline status and date, top score and finding counts.
- `finding`: ranked findings (`rank`, `severity`, `priorityScore`, `buyerOutcome`, `signal`, `storeDomain`, `vendor`, `category`, `headline`, `detail`, `metrics`, `recommendedAction`, `confidence`, `samplingNote`, `sourceUrl`, `exampleUrls`, `baselineDate`, `currency`, `runDate`).
- `store_error`: stores that could not be analyzed, with an error code. These are never charged.

**Key-value store**: `REPORT_SUMMARY` (run summary JSON) and `REPORT.md` (readable report with top findings and caveats).

Severity bands: `high` 70 or more, `medium` 45 to 69, `low` 20 to 44, `info` below 20. Scores are damped by 25% when the sample is limited. Confidence is `limited` or `moderate`, never `high`, because a public feed is only a sample.

### Dated baselines

After the report is delivered, a compact snapshot of each analyzed store (handle, vendor, category, lowest price) is saved to a named key-value store (default `pal-vendor-intel-baselines`). It keeps a latest copy plus dated copies, up to `snapshotRetention` per store and label, and deletes older ones. Baselines are keyed by label and store, so different buying programs do not mix. If the baseline store cannot be read, the run still reports but does not overwrite stored history.

### How each signal works

- **Vendor concentration**: the largest vendor's share of sampled products against your threshold, with an approximate 95% Wilson interval and a concentration index.
- **Vendor share shift**: share change in percentage points, kept only if it also passes a conservative two-proportion noise screen. The screen treats the two samples as independent, which they are not, so it is a noise filter and not a formal test.
- **Assortment turnover**: products added plus removed as a share of all products seen in either run.
- **Price movement**: retained products whose lowest published variant price moved by at least the threshold, shown only when at least 3 products and 10% of compared products moved. Skipped when the currency changed.
- **Category price dispersion**: quartile coefficient of dispersion, (Q3 - Q1) / (Q3 + Q1), per category with enough priced products.
- **Vendor price position**: a vendor's median price against its category median when at least two vendors each have 3 or more priced products.
- **Cross-store price gap**: identical vendor and normalized title in two or more stores that share the same known currency (read from the public store metadata). Stores with unknown or different currencies are never compared.
- **Missing expected option**: an option name present in at least the configured share of a category's products is expected; products lacking it are listed.
- **New category / recent launch**: categories absent from the baseline, plus categories whose products mostly carry recent published dates.

### Safety and limits

- Reads only `/robots.txt`, `/meta.json` and `/products.json?limit=&page=` on the host you supply. No login, no cart or checkout, no contact data, no proxies, no other paths.
- Honors robots.txt (longest-match rules, wildcards, group selection, Crawl-delay). An unreadable robots.txt (anything other than 200, 404 or 410) skips the store, and so does a Crawl-delay above 30 seconds.
- SSRF protection: https only, public domain names only, IP literals and private suffixes rejected, every resolved address must be globally routable, the connection is pinned to the validated address, and redirects are followed only within the same site.
- Bounded work: at most 10 stores, 1,000 products per store (4 pages of 250), 8 MB per response, request pacing of at least 0.5 seconds, stores processed one at a time. Responses are reduced to a few fields immediately to keep memory low.
- Errors are not charged. Failed stores appear as `store_error` records.

### Pricing event

The code declares one pay-per-event name, `supplier-planning-report`, charged at most once per run and only when at least one store was analyzed and the report contains at least one finding. **No payable plan or price is configured in this project.** Whoever publishes it must define the event and its price separately and verify unit economics first.

### Limitations and sample-size caveats

- The public products feed lists **published, public listings only**. It does not show sales, inventory, costs, margin or unpublished items, so nothing here measures demand or profitability.
- **Feed order is not random.** Stores with more products than `maxProductsPerStore` are marked `possiblyTruncated`, and all figures then describe only the sampled window. A feed that has exactly the cap size is also marked possibly truncated.
- Samples under 30 products, truncated samples and truncated baselines produce `limited` confidence and lower scores. Treat small-store percentages as directional.
- Removed products can be genuine delistings, temporary unpublishing, renamed handles or products that fell outside the sampling window.
- Prices use the lowest published variant price in the storefront currency. Discount codes, regional pricing, tax display, bundles and variant mixes are invisible or can differ, so cross-store gaps need a manual check that the items are the same.
- Cross-store matching is exact on vendor plus normalized title. Different naming means no match.
- `recent_category_launch` infers launches from `published_at`, which can be changed by republishing. It is always `limited`.
- Missing-option findings can be legitimate for one-size or single-variant items.
- Not every Shopify store exposes `/products.json`; password-protected, disabled or non-Shopify sites return an error record.
- This Actor reports observations. Confirm important findings on the storefront before acting on them.

### Local checks

Tests run offline with the standard library only:

```
python -m unittest discover -s tests -t .
```

### Project layout

- `src/main.py`: Apify entry point (input, storage, output, charging)
- `src/pipeline.py`: collection and analysis workflow (no Apify imports)
- `src/analysis.py`: buyer-outcome analyzers
- `src/scoring.py`, `src/report.py`: ranking and joined records
- `src/urlsafety.py`, `src/robots.py`, `src/http_client.py`: validation, robots and the bounded transport
- `src/shopify.py`, `src/state.py`, `src/config.py`, `src/pricing.py`: feed parsing, baselines, input, event name
- `tests/`: offline unit tests

# Actor input Schema

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

Public https storefront roots, one per line (for example https://www.deadstock.ca). Paths, query strings, ports and credentials are rejected. Maximum 10 stores.

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

Upper bound on products read from each public feed (250 per request page). Stores with more products are reported as possibly truncated and figures describe the sampled window only.

## `baselineLabel` (type: `string`):

Lowercase letters, digits and hyphens. Runs that share a label are compared with each other. Use a different label for each buying program or watchlist.

## `updateBaseline` (type: `boolean`):

When enabled, a dated snapshot is stored after the report is delivered so the next run can show changes. Disable for ad-hoc what-if runs.

## `launchWindowDays` (type: `integer`):

A category counts as a possible recent launch when most of its products show a published date inside this window. This is an inference from public dates.

## `maxFindings` (type: `integer`):

Findings are ranked by severity and the top results are returned. Store summaries and the run summary are always returned.

## `vendorShiftPoints` (type: `number`):

Minimum change in a vendor's share of the sampled assortment, in percentage points, versus the baseline. A noise screen is applied on top.

## `concentrationTopSharePercent` (type: `number`):

Flag a store when its largest vendor holds at least this share of sampled products.

## `assortmentTurnoverPercent` (type: `number`):

Flag a store when added plus removed products, as a share of all products seen in either run, reaches this level.

## `priceChangeThresholdPercent` (type: `number`):

A retained product counts as repriced when its lowest published variant price moved by at least this percentage.

## `priceDispersionThreshold` (type: `number`):

Quartile coefficient of dispersion, (Q3 - Q1) / (Q3 + Q1), above which a category is flagged. 0.35 is a wide spread.

## `crossStorePriceGapPercent` (type: `number`):

For identical vendor and title listed in two or more stores with the same currency, flag gaps between the lowest and highest published price at or above this level.

## `expectedOptionSharePercent` (type: `number`):

An option name (for example Size) is expected in a category when at least this share of its products publish it. Products without it are reported.

## `minGroupSize` (type: `integer`):

Minimum products in a store or category before percentages and dispersion are reported.

## `newEntityMinProducts` (type: `integer`):

A vendor or category absent from the baseline must have at least this many products to be reported as new.

## `snapshotRetention` (type: `integer`):

Number of dated snapshots retained in the baseline store for each store and label. Older ones are deleted.

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

Minimum pause between requests to the same store. A larger Crawl-delay in robots.txt always wins.

## `requestTimeoutSeconds` (type: `integer`):

Network timeout for each request.

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

Named key-value store that keeps dated baselines between runs. Lowercase letters, digits and hyphens, 3 to 63 characters.

## Actor input object example

```json
{
  "storeUrls": [
    "https://www.deadstock.ca",
    "https://bdgastore.com"
  ],
  "maxProductsPerStore": 250,
  "baselineLabel": "default",
  "updateBaseline": true,
  "launchWindowDays": 30,
  "maxFindings": 150,
  "vendorShiftPoints": 5,
  "concentrationTopSharePercent": 50,
  "assortmentTurnoverPercent": 20,
  "priceChangeThresholdPercent": 5,
  "priceDispersionThreshold": 0.35,
  "crossStorePriceGapPercent": 15,
  "expectedOptionSharePercent": 60,
  "minGroupSize": 5,
  "newEntityMinProducts": 2,
  "snapshotRetention": 8,
  "requestDelaySeconds": 1,
  "requestTimeoutSeconds": 20,
  "stateStoreName": "pal-vendor-intel-baselines"
}
```

# Actor output Schema

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

Download rows from the latest run in JSON/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 = {
    "storeUrls": [
        "https://www.deadstock.ca",
        "https://bdgastore.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("practical_ai_lab_jp/pal-shopify-merchant-vendor-intelligence-suite").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 = { "storeUrls": [
        "https://www.deadstock.ca",
        "https://bdgastore.com",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("practical_ai_lab_jp/pal-shopify-merchant-vendor-intelligence-suite").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 '{
  "storeUrls": [
    "https://www.deadstock.ca",
    "https://bdgastore.com"
  ]
}' |
apify call practical_ai_lab_jp/pal-shopify-merchant-vendor-intelligence-suite --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-merchant-vendor-intelligence-suite"
        }
    }
}
```

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/pZFrrTER3cy7BuudF/builds/TYxckeJsM3NYjaHBu/openapi.json
