# Supplier CSV Price & Stock Delta Guard (`fioshstick/supplier-feed-guard`) Actor

Read-only supplier CSV comparison with whole-feed guards for stock resets, truncation, duplicate SKUs and price jumps. Private pilot.

- **URL**: https://apify.com/fioshstick/supplier-feed-guard.md
- **Developed by:** [Matt Pinion](https://apify.com/fioshstick) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 1,000 results

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

## Supplier CSV Price & Stock Delta Guard — pilot

Compare two supplier CSV exports before passing changed price/stock rows into an import workflow. Runs entirely on supplied text; no storefront access, crawling, merchant passwords or data mutation. This pilot is not currently a paid public listing.

Supply `previousCsv` and `currentCsv`, using the same headers and currency/unit conventions. Defaults are `sku,price,stock`; `columns` accepts exact alternate header names. SKUs remain case sensitive and retain leading zeroes. Numbers must use unsigned plain decimal notation, period decimal separator, no currency symbols/grouping, and stock must be integral. Blank, negative and ambiguous values block the report.

The report blocks all import output when either feed has duplicates, invalid numbers/rows, empty data, more than 10% missing SKUs, price changes over 30%, or more than 20% of formerly positive-stock matched items becoming zero. Fractions are configurable in \[0,1]. New and missing products are reported but never emitted as import instructions. Missing SKUs are never treated as zero stock. These are anomaly thresholds, not proof the remaining data is correct.

Outputs: `OUTPUT` JSON contains status, counts, issues, source line references, SHA256 hashes and exact change records, including signed priceDelta and stockDelta for changed existing SKUs. `UPDATES.csv` is produced only for ready reports and contains changed existing SKUs. Formula-leading SKUs are apostrophe escaped for spreadsheet safety; this changes the identifier in the CSV. Use the JSON exact SKU if your downstream importer requires the original identifier. Do not import escaped identifiers blindly. No platform-specific import compatibility is claimed.

Limits: comma-separated UTF-8 CSV text only, 2 MB and 20,000 rows per feed; no URL fetching, Excel, PDFs, currency conversion, variant creation, automatic baseline selection or store writes. Your automation supplies both snapshots each time. A passing report does not guarantee profitability, correct currency, tax treatment or accurate supplier data. Only upload data you are authorized to process; inputs/results are stored in your Apify run storage under Apify retention settings. No feed content is printed in logs.

Local use: `python3 main.py example-input.json`. Tests: `python3 -m unittest -v test_guard.py`. In Apify, inspect OUTPUT and require `status == "ready"` before considering UPDATES.csv. Never build downstream import logic around run success alone: blocked and invalid-input reports can finish normally.

Commercial hypothesis: pay per completed comparison, proposed $0.25, unvalidated. No payment event is implemented in this private prototype. No customers, subscriptions, income, or payout readiness are claimed. Category demand comes from historical paid supplier-import testimony; standalone willingness to pay remains unproven.

# Actor input Schema

## `previousCsv` (type: `string`):

Pre-filled with synthetic example data for testing. Replace with your previous supplier CSV before real use. UTF-8 CSV text with sku,price,stock headers by default; no URLs or credentials.

## `currentCsv` (type: `string`):

Pre-filled with synthetic example data for testing. Replace with your current supplier CSV before real use. UTF-8 CSV text with sku,price,stock headers by default; no URLs or credentials.

## `columns` (type: `object`):

Exact header names; identifiers remain case sensitive.

## `maxRemovedFraction` (type: `number`):

Block output above this fraction. 0.10 means ten percent.

## `maxPriceChangeFraction` (type: `number`):

Block output above this fraction. 0.10 means ten percent.

## `maxZeroedFraction` (type: `number`):

Block output above this fraction. 0.10 means ten percent.

## Actor input object example

```json
{
  "previousCsv": "sku,price,stock\n001,10,5\nB,20,4\n",
  "currentCsv": "sku,price,stock\n001,11,6\nB,20,4\n",
  "columns": {
    "sku": "sku",
    "price": "price",
    "stock": "stock"
  },
  "maxRemovedFraction": 0.1,
  "maxPriceChangeFraction": 0.3,
  "maxZeroedFraction": 0.2
}
```

# Actor output Schema

## `report` (type: `string`):

OUTPUT contains the comparison status and, for valid feeds, counts, deltas and safety issues. Invalid input produces status invalid_input and an error. A blocked report must not be used as an import instruction.

## `updatesCsv` (type: `string`):

UPDATES.csv is created only when the comparison permits CSV output. It is absent for blocked or invalid input; in those cases this URL returns 404. Always inspect the JSON report before downloading or importing updates. The Actor never writes to a merchant store.

# 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 = {
    "previousCsv": `sku,price,stock
001,10,5
B,20,4`,
    "currentCsv": `sku,price,stock
001,11,6
B,20,4`
};

// Run the Actor and wait for it to finish
const run = await client.actor("fioshstick/supplier-feed-guard").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 = {
    "previousCsv": """sku,price,stock
001,10,5
B,20,4
""",
    "currentCsv": """sku,price,stock
001,11,6
B,20,4
""",
}

# Run the Actor and wait for it to finish
run = client.actor("fioshstick/supplier-feed-guard").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 '{
  "previousCsv": "sku,price,stock\\n001,10,5\\nB,20,4\\n",
  "currentCsv": "sku,price,stock\\n001,11,6\\nB,20,4\\n"
}' |
apify call fioshstick/supplier-feed-guard --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,fioshstick/supplier-feed-guard"
        }
    }
}
```

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/GWruXTRStDDaMG33A/builds/W3QqTfmv6FRW2bJ1U/openapi.json
