# Amazon Supplier Offer Variance Audit (`practical_ai_lab_jp/pal-amazon-supplier-offer-variance-audit`) Actor

Compare two dated supplier offer sheets by ASIN and seller and flag total-cost outliers, expiring quotes and incomplete data. Offline, no Amazon fetching.

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

## Pricing

from $20.00 / 1,000 offer key auditeds

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

## Amazon Supplier Offer Variance Audit

Paste two dated supplier offer spreadsheets and get one audit row per exact ASIN and seller. The Actor compares landed offer totals (unit price + shipping + fee), and flags cost outliers, expiring or expired quotes, and incomplete data.

It works only on the data you supply. It does not fetch Amazon pages, call any API, use proxies, or collect personal data.

### What it checks

- **Total-cost change**: baseline vs. comparison total for the same ASIN and seller; flagged at or above your threshold (default 10%), with price, shipping and fee deltas.
- **Peer outliers**: an offer far above or below the median of the other sellers for the same ASIN and currency (needs at least 3 offers by default).
- **Quote validity**: `quote_expired` and `quote_expiring_soon` relative to a reference date; `quote_dates_not_ordered` when the newer sheet is not actually newer.
- **Completeness**: missing or invalid price, shipping, fee, currency, quote date or valid-until date, listed per side.
- **Coverage**: offers present only in one sheet, duplicate rows (newest quote kept), currency mismatches, and invalid ASIN or seller keys.

### Input

Provide `baselineCsv` and `comparisonCsv` (or JSON arrays in `baselineRows` and `comparisonRows`). Columns (aliases such as `supplier`, `vendor`, `price`, `expires` are accepted):

`asin, seller, unit_price, shipping, fee, currency, quote_date, valid_until`

Dates use `YYYY-MM-DD`. Enter `0` for a genuinely zero shipping or fee; an empty cell is treated as missing. The default sample input can be run as is.

### Output

Dataset rows have `asin`, `seller`, `status`, `severity` (`high`, `medium`, `low`, `ok`), `flags`, totals, deltas, peer median, expiry days, and the source row numbers. A `SUMMARY` record in the key-value store holds counts per severity and flag plus caveats.

### Pricing and errors

The code emits one `offer-key-audited` event per audited ASIN/seller key after results are saved. Invalid input (missing sheet, bad reference date, too many rows) fails the run without any charge, and invalid-key rows are not counted. Pricing is not configured in this repository.

### Limitations

- No currency conversion: offers in different currencies are flagged, not compared.
- Totals are per unit as entered; taxes, MOQ tiers, and volume breaks are not modeled.
- Outlier thresholds are simple percentages, not statistical tests. Peer medians from 3 or 4 sellers are weak evidence; treat flags as prompts to check, not conclusions.
- Sheets are limited to 5,000 rows each to keep memory low.
- Seller names match after trimming spaces and ignoring case; different spellings of the same seller are treated as different sellers.
- Results are only as accurate as the spreadsheets supplied.

# Actor input Schema

## `baselineCsv` (type: `string`):

Earlier dated offers. Header row required. Columns: asin, seller, unit_price, shipping, fee, currency, quote_date, valid_until (dates as YYYY-MM-DD). Use 0 for no shipping or fee.

## `comparisonCsv` (type: `string`):

Newer dated offers in the same format as the baseline sheet.

## `baselineRows` (type: `array`):

Alternative to baseline CSV: an array of row objects with the same column names. Used instead of the CSV when not empty.

## `comparisonRows` (type: `array`):

Alternative to comparison CSV: an array of row objects. Used instead of the CSV when not empty.

## `referenceDate` (type: `string`):

Date used to judge quote expiry, as YYYY-MM-DD. Leave empty to use today (UTC).

## `expiryWarningDays` (type: `integer`):

Quotes expiring within this many days are flagged.

## `outlierThresholdPercent` (type: `number`):

Total-cost change or distance from the peer median at or above this percentage is flagged.

## `peerMinOffers` (type: `integer`):

Peer-median checks run only when an ASIN and currency has at least this many seller offers.

## `maxRowsPerSheet` (type: `integer`):

Safety limit that keeps memory low. Larger sheets are rejected without charge.

## Actor input object example

```json
{
  "baselineCsv": "asin,seller,unit_price,shipping,fee,currency,quote_date,valid_until\nB0TEST0001,Alpha Supply,10.00,1.50,0.50,USD,2026-10-01,2026-10-31\nB0TEST0001,Beta Trading,10.50,1.00,0.40,USD,2026-10-01,2026-10-31\nB0TEST0001,Gamma Wholesale,10.20,1.20,0.45,USD,2026-10-01,2026-10-31\nB0TEST0002,Alpha Supply,5.00,0.80,0.20,USD,2026-10-01,2026-10-31",
  "comparisonCsv": "asin,seller,unit_price,shipping,fee,currency,quote_date,valid_until\nB0TEST0001,Alpha Supply,12.80,2.00,0.60,USD,2026-11-01,2026-11-06\nB0TEST0001,Beta Trading,10.60,1.00,0.40,USD,2026-11-01,2026-12-15\nB0TEST0001,Gamma Wholesale,10.30,,0.45,USD,2026-11-01,2026-12-15\nB0TEST0002,Alpha Supply,5.10,0.80,0.20,USD,2026-11-01,2026-11-20",
  "referenceDate": "2026-11-03",
  "expiryWarningDays": 7,
  "outlierThresholdPercent": 10,
  "peerMinOffers": 3,
  "maxRowsPerSheet": 2000
}
```

# 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 = {
    "baselineCsv": `asin,seller,unit_price,shipping,fee,currency,quote_date,valid_until
B0TEST0001,Alpha Supply,10.00,1.50,0.50,USD,2026-10-01,2026-10-31
B0TEST0001,Beta Trading,10.50,1.00,0.40,USD,2026-10-01,2026-10-31
B0TEST0001,Gamma Wholesale,10.20,1.20,0.45,USD,2026-10-01,2026-10-31
B0TEST0002,Alpha Supply,5.00,0.80,0.20,USD,2026-10-01,2026-10-31`,
    "comparisonCsv": `asin,seller,unit_price,shipping,fee,currency,quote_date,valid_until
B0TEST0001,Alpha Supply,12.80,2.00,0.60,USD,2026-11-01,2026-11-06
B0TEST0001,Beta Trading,10.60,1.00,0.40,USD,2026-11-01,2026-12-15
B0TEST0001,Gamma Wholesale,10.30,,0.45,USD,2026-11-01,2026-12-15
B0TEST0002,Alpha Supply,5.10,0.80,0.20,USD,2026-11-01,2026-11-20`,
    "referenceDate": "2026-11-03"
};

// Run the Actor and wait for it to finish
const run = await client.actor("practical_ai_lab_jp/pal-amazon-supplier-offer-variance-audit").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 = {
    "baselineCsv": """asin,seller,unit_price,shipping,fee,currency,quote_date,valid_until
B0TEST0001,Alpha Supply,10.00,1.50,0.50,USD,2026-10-01,2026-10-31
B0TEST0001,Beta Trading,10.50,1.00,0.40,USD,2026-10-01,2026-10-31
B0TEST0001,Gamma Wholesale,10.20,1.20,0.45,USD,2026-10-01,2026-10-31
B0TEST0002,Alpha Supply,5.00,0.80,0.20,USD,2026-10-01,2026-10-31""",
    "comparisonCsv": """asin,seller,unit_price,shipping,fee,currency,quote_date,valid_until
B0TEST0001,Alpha Supply,12.80,2.00,0.60,USD,2026-11-01,2026-11-06
B0TEST0001,Beta Trading,10.60,1.00,0.40,USD,2026-11-01,2026-12-15
B0TEST0001,Gamma Wholesale,10.30,,0.45,USD,2026-11-01,2026-12-15
B0TEST0002,Alpha Supply,5.10,0.80,0.20,USD,2026-11-01,2026-11-20""",
    "referenceDate": "2026-11-03",
}

# Run the Actor and wait for it to finish
run = client.actor("practical_ai_lab_jp/pal-amazon-supplier-offer-variance-audit").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 '{
  "baselineCsv": "asin,seller,unit_price,shipping,fee,currency,quote_date,valid_until\\nB0TEST0001,Alpha Supply,10.00,1.50,0.50,USD,2026-10-01,2026-10-31\\nB0TEST0001,Beta Trading,10.50,1.00,0.40,USD,2026-10-01,2026-10-31\\nB0TEST0001,Gamma Wholesale,10.20,1.20,0.45,USD,2026-10-01,2026-10-31\\nB0TEST0002,Alpha Supply,5.00,0.80,0.20,USD,2026-10-01,2026-10-31",
  "comparisonCsv": "asin,seller,unit_price,shipping,fee,currency,quote_date,valid_until\\nB0TEST0001,Alpha Supply,12.80,2.00,0.60,USD,2026-11-01,2026-11-06\\nB0TEST0001,Beta Trading,10.60,1.00,0.40,USD,2026-11-01,2026-12-15\\nB0TEST0001,Gamma Wholesale,10.30,,0.45,USD,2026-11-01,2026-12-15\\nB0TEST0002,Alpha Supply,5.10,0.80,0.20,USD,2026-11-01,2026-11-20",
  "referenceDate": "2026-11-03"
}' |
apify call practical_ai_lab_jp/pal-amazon-supplier-offer-variance-audit --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-amazon-supplier-offer-variance-audit"
        }
    }
}
```

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/VSbI4TZ03DUWtKb4b/builds/oMXBhX2ddMRtytVGH/openapi.json
