# Shopify Supplement Claims Compliance Review (`practical_ai_lab_jp/pal-shopify-supplement-claims-compliance-review`) Actor

Screen one Shopify store's public product copy for unsupported health claims and get a severity-ranked review queue with neutral rewrites and change tracking between runs.

- **URL**: https://apify.com/practical_ai_lab_jp/pal-shopify-supplement-claims-compliance-review.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, 60.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 review completeds

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 Supplement Claims Compliance Review

Give this Actor **one Shopify store URL**. It reads the store's public product feed (only where `robots.txt` allows it), screens product copy against a transparent claim-risk lexicon, and returns a **severity-ranked review queue** (JSON and CSV) with the matched phrase, the product URL and a suggested neutral rewrite. It also saves a baseline snapshot, so on later runs it tells you which risky wording is **newly introduced** and which flagged wording has been **fixed**.

It is built for compliance leads at supplement, skincare and wellness brands, and for marketplace trust teams who would otherwise review hundreds of listings by hand.

> This is a screening aid, not legal advice or a compliance certification. It flags wording for a human to review.

### What makes it different from a plain keyword scan

- **One joined workflow**, not a single check: ranked findings, a per-product risk scoreboard, newly introduced wording, and remediation confirmation come from the same run.
- **Change tracking built in.** The first run creates a baseline (`BASELINE_CREATED`). Later runs report `NEW_WORDING`, `NEW_PRODUCT`, `UNCHANGED` and `RESOLVED` items.
- **Transparent lexicon.** Every finding carries a rule ID, category, severity and a plain-language rationale. See [Lexicon](#lexicon).
- **Fewer obvious false alarms.** Standard disclaimers ("not intended to diagnose, treat, cure, or prevent any disease") and simple negations ("does not cure ...") are not flagged, and you can add your own allowed phrases.
- **Strict access rules.** robots.txt is checked before every storefront request, and requests are bounded and SSRF-protected.

### Quick start (one URL)

1. Open the Actor and set **Store URL** to a store you operate or are permitted to review, e.g. `https://shop.example.com`.
2. Run it. Nothing else is required.
3. The first run returns `runStatus: "BASELINE_CREATED"`. Every finding listed is existing wording to review; no change can be reported yet.
4. Fix wording in your store, then run again with the same input. The run returns `DELTA_REPORT` with what is new and what was resolved.

Sample input you can copy:

```json
{
    "storeUrl": "https://shop.example.com"
}
```

A fuller example using optional settings:

```json
{
    "storeUrl": "https://shop.example.com",
    "maxProducts": 250,
    "minSeverity": "low",
    "extraPhrases": ["miracle formula"],
    "allowedPhrases": ["fight cancer awareness"],
    "unchangedSampleSize": 5,
    "stateStoreName": "pal-claims-review-state"
}
```

### Scheduling later runs

The Actor does **not** schedule itself and does **not** send alerts. To monitor a store over time:

1. Run it once to create the baseline.
2. In Apify, create a **Schedule** (for example weekly) that runs the Actor with the **same input**, including the same `stateStoreName`.
3. Read the dataset or `REVIEW_QUEUE.csv` after each scheduled run. If you want notifications, attach an Apify integration or webhook to the run yourself.

The baseline is stored per store domain in a **named key-value store** (default name `pal-claims-review-state`), because a run's default store does not persist after the run on the Apify platform. If you clear `stateStoreName`, the Actor falls back to the run's default store (`Actor.get_value` / `Actor.set_value`), which only persists across local runs. Changing `minSeverity`, `extraPhrases`, `allowedPhrases`, or a new lexicon version triggers `BASELINE_REFRESHED`: the baseline is replaced and no changes are reported for that run, so old and new settings are never compared.

### Output

**Dataset** (default) - filter by `recordType`:

| recordType | What it is |
|---|---|
| `SUMMARY` | Always first. `runStatus` (`BASELINE_CREATED`, `BASELINE_REFRESHED`, `DELTA_REPORT` or a refusal code), counts, coverage, robots information, next step, limitations. |
| `FINDING` | One per product, field and phrase, ranked by severity and priority. Includes `phrase`, `productUrl`, `snippet`, `rationale`, `suggestedRewrite`, `changeStatus`. |
| `PRODUCT_RISK` | Per-product roll-up (top 50): `riskScore`, severity counts, top phrases. |
| `RESOLVED` | Previously flagged wording that is gone since the last run. |

First runs list every finding. Repeat runs list **changed** findings plus a small **sample** of unchanged ones (`isSample: true`, size set by `unchangedSampleSize`).

**Key-value store** (this run):

- `OUTPUT` - the summary.
- `REVIEW_QUEUE.json` - the full queue, product scoreboard and resolved items.
- `REVIEW_QUEUE.csv` - the full ranked queue for spreadsheets (cells starting with `=`, `+`, `-` or `@` are prefixed with `'` to prevent formula injection).

Illustrative record shape (not a real run):

```json
{
    "recordType": "FINDING",
    "rank": 1,
    "severity": "high",
    "changeStatus": "NEW_WORDING",
    "productTitle": "Example Product",
    "productUrl": "https://shop.example.com/products/example-product",
    "field": "description",
    "ruleId": "DIS-001",
    "phrase": "cures diabetes",
    "suggestedRewrite": "Remove the disease name and the treat/cure/prevent verb from 'cures diabetes'. ..."
}
```

### Four buyer outcomes

1. **Prioritized review queue** - triage hundreds of listings by severity without reading them all (`FINDING` records, CSV/JSON).
2. **Newly introduced risky wording** - after a baseline, see `NEW_WORDING` and `NEW_PRODUCT` items first (change tracking between scheduled runs).
3. **Product risk scoreboard** - find the listings with the most or most severe issues (`PRODUCT_RISK`).
4. **Remediation check** - confirm previously flagged wording was removed (`RESOLVED`).

### Lexicon

Rule categories (version `2026.11.1`, English only): disease claims (treat/cure/prevent plus a named condition, disease-fighting adjectives, cure-all language, COVID protection), medication replacement, biomarker claims (blood pressure, sugar, cholesterol), regulator approval and professional endorsement, proof wording ("clinically proven"), guarantees, blanket safety claims, weight-loss outcomes, pain relief, antimicrobial claims, hormone claims, cosmetic structure claims, immune "boost" claims, and detox claims. Severities are `high`, `medium` and `low`; the priority score keeps severity bands separate (title matches, repeats and new wording raise the score within a band only).

Hedging words like "helps" or "supports" do not make a disease claim acceptable, so they are not used to suppress findings. General structure/function wording such as "supports healthy immune function" is not flagged.

### Safety and limits

- Only `https://` store URLs on port 443; credentials, IP addresses, localhost and internal-style hostnames are refused.
- Hostnames are resolved and **every** returned address must be public; connections go to the validated address (with normal certificate verification) to resist DNS rebinding.
- Redirects are followed at most 3 times and only within the same site (`example.com` and `www.example.com`).
- `robots.txt` is fetched and checked for the `PALClaimsComplianceReview` user agent before every storefront request, with `*` and `$` pattern support. Disallowed, access-restricted (401/403) or unretrievable robots.txt means the run is refused. A missing robots.txt (404/410) is treated as no restrictions. Crawl delays above 10 seconds are refused.
- Only `/products.json` is read: at most 100 products per page, 4 MiB per page, `maxPages` pages (default 5) and `maxProducts` products (default 250, max 1000). No login, proxies, contact data or personal data are used.
- Memory use is small (256 MB minimum) and requests run one at a time.

### Pricing and errors

The code defines one pricing event, `review-completed`, which is charged at most once per run and only after the outputs and baseline have been stored. **No payable plan is configured in this project.** Refused or failed runs (invalid input, blocked host, robots denial, no public product feed, network errors) are marked as failed and never charged.

### Limitations and caveats

- **Pattern screening, not judgment.** Expect false positives and false negatives; a clean result does not prove compliance.
- **Coverage.** Only title, description, tags and product type from the public feed are read. Images, reviews, metafields, theme text, landing pages, ads and other languages are not reviewed. Stores that disable `/products.json` or block it in robots.txt cannot be reviewed. Unpublished or hidden products are not visible.
- **Sample size.** On small catalogs (under 30 products) category counts and risk shares are descriptive only. Change detection compares with one previous snapshot, so one quiet run says little about long-term behaviour.
- **Partial runs.** If a product or page limit is reached (`coverageComplete: false`), "new product" labels can be artifacts of which products were returned, and removals are not reported.
- **Jurisdiction.** The lexicon reflects common US-style supplement and cosmetic claim concerns. Other regions have different rules.
- **Persisted state.** The saved snapshot stores product IDs, handles, shortened titles and finding fingerprints (bounded to 2000 products). If the named store is deleted, the next run creates a new baseline.

### Development

Tests are fully offline (mock transports, resolvers, storage and billing):

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

Layout: `src/safety.py` (URL and IP validation), `src/robots.py`, `src/client.py` (bounded client), `src/catalog.py` (feed parsing), `src/lexicon.py`, `src/analysis.py`, `src/changes.py` and `src/state.py` (baseline and deltas), `src/report.py`, `src/workflow.py` (orchestration), `src/main.py` (Apify SDK 3.x entrypoint).

# Actor input Schema

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

The prefilled example-wellness-store.com is a fictional zero-network sample, not a real merchant. Replace it with one public HTTPS Shopify storefront URL you own or are authorized to review. Only the site origin is used.

## `maxProducts` (type: `integer`):

Upper bound on products read from the public product feed. The effective cap is the smaller of this value and maxPages x 100.

## `maxPages` (type: `integer`):

Upper bound on product feed pages requested (100 products per page).

## `minSeverity` (type: `string`):

Hide findings below this level. Changing it creates a fresh baseline on the next run.

## `extraPhrases` (type: `array`):

Optional house-policy phrases (3-80 characters, up to 50) flagged as medium severity. Changing this creates a fresh baseline.

## `allowedPhrases` (type: `array`):

Optional phrases you have already cleared. Findings that fall inside one of these phrases are not reported. Changing this creates a fresh baseline.

## `unchangedSampleSize` (type: `integer`):

On repeat runs, how many unchanged findings to include in the dataset as a sample next to the changed ones. The full queue is always saved to the key-value store.

## `maxFindingsOutput` (type: `integer`):

Upper bound on finding records pushed to the dataset (highest priority first).

## `requestDelaySecs` (type: `number`):

Minimum pause between requests. A longer crawl delay in robots.txt is honored; delays above 10 seconds cause the run to be refused.

## `requestTimeoutSecs` (type: `integer`):

Timeout for each HTTPS request.

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

Named key-value store that keeps the baseline between runs (3-63 lowercase letters, digits or hyphens). Keep it the same on every scheduled run. Leave empty to use the run's default store, which does not persist between cloud runs.

## Actor input object example

```json
{
  "storeUrl": "https://example-wellness-store.com",
  "maxProducts": 250,
  "maxPages": 5,
  "minSeverity": "low",
  "unchangedSampleSize": 5,
  "maxFindingsOutput": 1000,
  "requestDelaySecs": 1,
  "requestTimeoutSecs": 20,
  "stateStoreName": "pal-claims-review-state"
}
```

# 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 = {
    "storeUrl": "https://example-wellness-store.com"
};

// Run the Actor and wait for it to finish
const run = await client.actor("practical_ai_lab_jp/pal-shopify-supplement-claims-compliance-review").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://example-wellness-store.com" }

# Run the Actor and wait for it to finish
run = client.actor("practical_ai_lab_jp/pal-shopify-supplement-claims-compliance-review").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 '{
  "storeUrl": "https://example-wellness-store.com"
}' |
apify call practical_ai_lab_jp/pal-shopify-supplement-claims-compliance-review --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-supplement-claims-compliance-review"
        }
    }
}
```

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/ScT4wDHmH5R7ysumY/builds/yGg0ne2XEoxaL8EXd/openapi.json
