# Shopify 3PL Fulfillment Profile & Catalog Shifts (`practical_ai_lab_jp/pal-shopify-3pl-fulfillment-profile-sizing`) Actor

Size a prospective Shopify merchant for a 3PL quote from one store URL: weight bands, heavy items, shipping split and SKU complexity, with a stored baseline that flags later catalog shifts.

- **URL**: https://apify.com/practical_ai_lab_jp/pal-shopify-3pl-fulfillment-profile-sizing.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 shopify 3pl profile 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 3PL Fulfillment Profile & Catalog Shifts

Size a prospective Shopify merchant for a third-party logistics (3PL) quote from **one store URL**. The Actor reads the store's public `/products.json` feed (only if the store's `robots.txt` allows it), builds a fulfillment profile, saves a baseline snapshot, and on later runs flags catalog shifts that change handling needs.

It is a pre-quote screening aid for sales engineers who only have the merchant's public catalog as evidence. It does not replace the merchant's own SKU master.

### What you get from one run

One joined, severity-ranked list of findings (dataset and CSV), grouped into five buyer outcomes:

| Outcome | Question it answers | Example findings |
| --- | --- | --- |
| `WEIGHT_MIX` | What parcel mix am I pricing? | Weight coverage, band shares, median and 90th percentile weight |
| `HEAVY_BULKY_HANDLING` | Which items need heavy-parcel or freight handling? | Heavy-item list with product links, bulky keyword candidates (heuristic) |
| `SHIPPING_SPLIT` | How much of the catalog is physical? | Shipping-required versus digital variants, mixed products |
| `SKU_COMPLEXITY` | How hard is onboarding and slotting? | SKU tier, variants per product, missing or duplicate SKU codes |
| `CATALOG_SHIFT` | Did the catalog change since I last looked? | `BASELINE_CREATED` on the first run; added/removed SKUs, newly heavy items, heavier weight bands, shipping-flag changes on repeat runs |

Every finding has a severity (`CRITICAL`, `HIGH`, `MEDIUM`, `LOW`, `INFO`), a short quote action, the value (and baseline value on repeat runs), a sample size, and citation URLs (the public feed pages or product pages the finding is based on).

### Quick start: one URL, no uploads

1. Open the Actor and enter the merchant's storefront URL in **Shopify store URL**, for example `https://your-prospect-store.example`.
2. Run it. That is the only required input.
3. Read the **Severity-ranked quote findings** view in the dataset, or download `QUOTE_FINDINGS.csv` / `OUTPUT` from the key-value store of the run.

Minimal input:

```json
{
    "storeUrl": "https://your-prospect-store.example"
}
```

Only the domain is used. Paths and query strings are ignored, `http://` and IP addresses are refused.

### First run and repeat runs

- **First run:** there is no earlier state, so the run status is `BASELINE_CREATED`. You get the full sizing profile plus a finding named `BASELINE_CREATED`, and a compact snapshot of the catalog is stored.
- **Repeat run:** the same input compares today's catalog with the stored baseline. The run status is `CHANGES_DETECTED` or `NO_CHANGES`. Changed records are emitted as `CATALOG_SHIFT` findings, ranked together with the current sizing findings, so the most important item is always the first row.

Baselines are stored per store domain in a **named key-value store** (default name `pal-3pl-profile-baselines`) in your Apify account. A named store is used because default run storages are discarded per run and could not carry state to the next run. The state is one compact record per domain (variant ids, grams, shipping flag, product handles), capped at 50,000 variants.

Baseline modes:

- `rolling` (default): each run is compared with the previous run, then replaces the baseline.
- `fixed`: each run is compared with the first stored baseline, which stays until you set **Reset baseline**. Use this to compare against the catalog as it was when you quoted.

### Scheduling later runs

The Actor does not run by itself and sends no alerts. To monitor a prospect or customer:

1. Save the input as an Apify **Task**.
2. Add an Apify **Schedule** to that task (for example weekly).
3. Optionally add an Apify webhook or integration on the task if you want to be notified. That is configured on the platform, not inside this Actor.

Keep the same input (and the same baseline storage name) so every run finds the previous baseline.

### Input

| Field | Default | Notes |
| --- | --- | --- |
| `storeUrl` | required | One HTTPS storefront URL |
| `maxProducts` | 500 | 10 to 2000; larger catalogs are marked truncated |
| `heavyThresholdKg` | 10 | Variants at or above this declared weight are heavy items |
| `baselineMode` | `rolling` | `rolling` or `fixed` |
| `resetBaseline` | false | Ignore the stored baseline and create a new one |
| `maxListedItems` | 10 | Cap for per-item rows (heavy items, bulky candidates, changed items) |
| `timeoutSecs` | 120 | Total network time budget |
| `requestDelaySecs` | 1 | Pause between requests to the store |
| `stateStoreName` | `pal-3pl-profile-baselines` | Named store that holds baselines |

### Output

- **Dataset:** first record is a `SUMMARY` (status, sample size, headline metrics, caveats), followed by `FINDING` records in severity order. Two dataset views are provided: findings and summary.
- **`OUTPUT` (key-value store):** the same findings plus the full profile as JSON, including all weight bands and heavy-item lists.
- **`QUOTE_FINDINGS.csv` (key-value store):** the findings as CSV for spreadsheets or a CRM. Cells that start with a spreadsheet formula character are prefixed with an apostrophe.

Illustrative record format (synthetic values for a made-up store, not a real result):

```json
{
    "recordType": "FINDING",
    "rank": 1,
    "store": "shop.example.com",
    "runStatus": "CHANGES_DETECTED",
    "outcome": "CATALOG_SHIFT",
    "severity": "HIGH",
    "code": "NEWLY_HEAVY_ITEMS",
    "title": "2 variants are newly at or above 10 kg",
    "quoteAction": "Add heavy-parcel or freight handling to the quote for these items.",
    "metric": "newlyHeavyVariants",
    "value": 2,
    "citations": ["https://shop.example.com/products/example-item"],
    "sampleSize": 6
}
```

#### How severity is assigned

- Weight coverage below 30% is `HIGH`, below 70% is `MEDIUM`.
- Heavy items are `HIGH` when the heaviest is 25 kg or more, or heavy variants are 20% or more of weighed variants; otherwise `MEDIUM`.
- Catalog with no shipping-required variants is `HIGH`; a digital share of 25% or more is `MEDIUM`.
- SKU tier by shipping-required variants: under 100 `INFO`, 100 to 499 `LOW`, 500 to 1999 `MEDIUM`, 2000 or more `HIGH`.
- SKU churn since the baseline is `HIGH` at 25% or more of the baseline (and at least 20 variants), `MEDIUM` at 10% or more (and at least 10), otherwise `LOW`.
- Newly heavy items are `HIGH`; a move to a heavier weight band or items that now require shipping are `MEDIUM`.

These are screening rules, not pricing rules. Tune your own thresholds in your quote process.

### Safety and politeness

- Only HTTPS storefront domains are accepted. IP addresses, `localhost`, internal suffixes, credentials in URLs and non-standard ports are refused.
- Every host is resolved first and refused if any address is private, loopback, link-local or otherwise non-public. The connection is made to the validated address.
- `robots.txt` is read and evaluated for this crawler before every storefront request, including redirect targets. If robots rules disallow the feed, or robots access cannot be verified (for example HTTP 401, 403 or 5xx), the run stops and fetches nothing.
- Requests, response sizes and total time are bounded; redirects are limited and re-validated at each hop. Only the public products feed is requested. There is no login, no proxy, no contact collection and no personal data collection.

### Billing

The code declares one pay-per-event event named `shopify-3pl-profile-report`, charged once after a run has produced its report. Runs that stop with an error (invalid input, robots denial, no feed, empty feed, network failure) are never charged. No payable plan or price is configured in this repository; any pricing is set separately on the platform.

### Limitations and sample-size caveats

- **Weights are merchant-declared.** The feed's `grams` value is whatever the merchant entered. Zero means unset and is excluded from bands, so band shares describe only variants that declare a weight. Check the weight coverage finding before relying on shares.
- **No dimensions, inventory or order volume.** Cube, storage space, throughput and seasonal peaks cannot be sized from a public catalog. "Bulky" candidates come from a keyword heuristic on titles, types and tags and will have false positives and misses.
- **SKU count is variant count.** Bundles, kits, hidden or unpublished products, draft products and B2B-only catalogs are not visible. Products with very many variants may be cut off by the platform's feed limits.
- **Small or truncated samples.** Catalogs with fewer than 30 products make shares and medians volatile (a `SMALL_SAMPLE` finding is added). Catalogs above `maxProducts` are truncated (a `CATALOG_TRUNCATED` finding is added); totals are then a lower bound, and added/removed comparisons are skipped while overlapping variants are still compared.
- **Availability.** Not every store exposes `/products.json`; some disable it, password-protect the store, or disallow it in `robots.txt`. In those cases the run fails with a clear message and no output is stored or billed.
- **Change detection compares snapshots, not events.** A product added and removed between two runs is invisible, and edits are only seen when a run happens. Currency and prices are not analysed.
- The Actor is built for public Shopify storefronts; it does not scrape Google Maps, Amazon or any marketplace.

### Local development

The tests are fully offline (fake network, in-memory state). From the project folder:

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

The Actor itself needs the Apify SDK (`pip install -r requirements.txt`) and runs with `python -m src`.

# Actor input Schema

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

One HTTPS storefront URL of the prospective merchant, for example https://www.allbirds.com. Only the domain is used; the Actor reads the public /products.json feed if the store's robots.txt allows it.

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

Upper bound on products read from the public feed (100 per page). Catalogs larger than this are marked as truncated.

## `heavyThresholdKg` (type: `number`):

Variants with a declared weight at or above this value are listed as heavy items.

## `baselineMode` (type: `string`):

rolling: every run compares with the previous run and then replaces the baseline. fixed: every run compares with the first stored baseline, which is kept until you reset it.

## `resetBaseline` (type: `boolean`):

Ignore any stored baseline for this store and create a new one in this run.

## `maxListedItems` (type: `integer`):

Maximum heavy items, bulky candidates and changed items emitted as separate rows.

## `timeoutSecs` (type: `integer`):

Network work stops when this budget is used up.

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

Pause between requests to the store. Keep at 1 or higher to stay polite.

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

Name of the key-value store that keeps one compact baseline per store domain. A named store is used because default stores are discarded per run. Change only if you want separate baseline sets.

## Actor input object example

```json
{
  "storeUrl": "https://www.allbirds.com",
  "maxProducts": 500,
  "heavyThresholdKg": 10,
  "baselineMode": "rolling",
  "resetBaseline": false,
  "maxListedItems": 10,
  "timeoutSecs": 120,
  "requestDelaySecs": 1,
  "stateStoreName": "pal-3pl-profile-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 = {
    "storeUrl": "https://www.allbirds.com"
};

// Run the Actor and wait for it to finish
const run = await client.actor("practical_ai_lab_jp/pal-shopify-3pl-fulfillment-profile-sizing").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://www.allbirds.com" }

# Run the Actor and wait for it to finish
run = client.actor("practical_ai_lab_jp/pal-shopify-3pl-fulfillment-profile-sizing").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://www.allbirds.com"
}' |
apify call practical_ai_lab_jp/pal-shopify-3pl-fulfillment-profile-sizing --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-3pl-fulfillment-profile-sizing"
        }
    }
}
```

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/ZzTtrsr8lA3uTOMHs/builds/HqOr5pnsH6DpOe3Nk/openapi.json
