# Price Per Unit Calculator: Amazon, Walmart & Grocery (`nerolabs/price-per-unit-calculator`) Actor

Works out price per unit (item, load, 100 g, oz, 100 ml, fl oz) from Amazon, Walmart or grocery scraper rows, CSV or Sheet, ranks best value per search and flags overpriced and bigger packs that cost more. Per product. MCP, x402.

- **URL**: https://apify.com/nerolabs/price-per-unit-calculator.md
- **Developed by:** [Adam Pearce](https://apify.com/nerolabs) (community)
- **Categories:** E-commerce, Automation, AI
- **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 product analyzeds

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

## Price Per Unit Calculator: Amazon, Walmart & Grocery

**Which product in a search is really the cheapest, once you divide by what is in the pack?** Give this actor the product rows your Amazon, Walmart or grocery scraper already returned (a dataset, CSV or Google Sheet) and it **reads the pack size from every title, puts every product in a search on one unit and ranks the best value**: per item, per load, per 100 g or oz, per 100 ml or fl oz.

A 150 load bottle of detergent can cost more per load than the 100 load bottle of the same brand. A 16 pack of coffee pods can cost more per pod than a 10 pack. A shelf price on special changes the whole ranking. A raw scrape shows prices, not value. This actor shows value, and flags the traps.

No scraping, no login, no AI fees: plain rules on rows you already have, so the same rows always give the same answer, for a tenth of a cent a product.

### Who uses it

- **Amazon and Walmart sellers**: see where your listing sits per unit against every rival in the search, and whether your bigger pack is priced worse per unit than your smaller one.
- **Deal sites, coupon and comparison sites**: the real best value per search, ready to publish.
- **Grocery price trackers and analysts** (Woolworths, Coles, ALDI, Tesco, Costco): every product on one unit, on special prices included.
- **Brands and category managers**: price ladders by pack size, and which rivals undercut you per unit.
- **AI agents and n8n or Make flows**: run the scraper, then ask "which one is the best value?" in one call.

### Works with the rows you already have

- **Amazon**: junglee/Amazon-crawler, apt_marble/amazon-search-results-scraper and look-alikes. junglee search rows hide Amazon's own unit price in `getPriceBeforeDiscount`; this actor spots that and reports it as `storeUnitPrice`, not as an old price.
- **Walmart, Target and grocery scrapers** (Woolworths, Coles, ALDI, Tesco, Costco and others): a lower `discount_price` or special price is used as the paying price, and the store's own unit price (`$4.25 / 1L`) is read and checked against ours.
- **Your own sheet**: one row per product with a `title` (or name) and a `price`, plus optional size, brand, url and a search or category column. Column names are read loosely, and money objects like `{value, currency}` are understood.

### How it works (plain words)

1. **The pack size is read from the title** and any size column: counts (ct, pods, capsules, tablets, sheets, rolls, servings), loads or washes, g, kg, oz, lb, ml, l, fl oz, gallons, and multipacks ("Pack of 6", "6 x 330 ml", "45 Ct, 2 Pack", "1.5L x 6"). Screen sizes, watts, months and the like are ignored.
2. **Products are grouped** by their search term or category (or the column you choose).
3. **Each group is put on one unit**: the unit most products in it have. For detergent, per load wins over per fl oz, because loads are what you buy. Imperial units are used when most of the group is imperial.
4. **Ranked** cheapest per unit first, with the gap to the group median: best value, good value, fair, overpriced, very overpriced.
5. **Bigger-pack traps**: a bigger pack of the same brand that costs more per unit than a smaller one is flagged, with the smaller pack named.

### What you get

One row per product, cheapest per unit first within each group:

| Field | What it means |
|---|---|
| `group`, `rankInGroup`, `groupCompared` | The search or group, the rank in it, and how many were compared |
| `verdict` | `best_value`, `good_value`, `fair`, `overpriced`, `very_overpriced`, `not_compared` |
| `title`, `brand`, `id`, `url` | The product |
| `price`, `currency` | The paying price (a lower special price wins) |
| `unitPrice`, `unitLabel` | Price on the group's one unit, e.g. 0.1597 per load |
| `groupMedianUnitPrice`, `gapPct` | The group median and how far above or below it this product is |
| `sizeRead`, `quantity` | The pack size read, and the words it came from |
| `storeUnitPrice` | The unit price the store showed, and which unit it matches |
| `flags` | e.g. `bigger_pack_costs_more_per_unit`, `size_not_found`, `other_unit_only` |
| `why` | One plain line explaining the verdict |

**The OUTPUT record**: products read and compared, and per group the unit used, median, cheapest, dearest, spread (dearest divided by cheapest), overpriced count, bigger-pack traps and notes.

### Input

| Field | What it does |
|---|---|
| Datasets | One or more product scraper datasets (in an integration, `{{resource.defaultDatasetId}}`) |
| File or Google Sheet URL | CSV, Excel, JSON or JSON Lines |
| Product rows | Rows as JSON, for a quick run or an AI agent call |
| Compare within this column | Group by a column, or `all` to compare everything together |
| Compare on | Auto, or force per item, per load, per weight or per volume |
| Overpriced above the median by | 25% by default |
| Minimum products to compare | 3 by default |
| Only overpriced and bigger-pack traps | Just the problems |
| Keep my columns | Copies your input row into each output row |
| Also save as a file | CSV or Excel copy |
| Also append to a named dataset | Track unit prices across weekly runs |

Run it with no input and it analyzes a public example file (made-up brands), so you can see the output first.

### Pricing

Pay per event, no subscription:

- **$0.001 per product read** with a title and a price (1,000 products = $1). Rows without a title or price are free.
- **$0.01 per CSV or Excel file**, only if you ask for one.

### Agent-ready

Pay per event, limited permissions and plain JSON in and out, so AI agents can call it through the Apify MCP server or pay per call with x402 at the Nero Labs Agent Tools shop (`POST /unit-price`).

### FAQ

**Does it scrape Amazon or the store?** No. It only reads rows you already have, so it never logs in or touches a store.

**Is it AI?** No. Fixed rules, so results are fast, cheap and repeatable.

**Why was a product not compared?** No pack size was found in its title or size columns, or it only had a different unit from the rest of its group (it then gets `otherUnitPrice`).

**Which currencies?** Any. Products are only compared with others in the same currency.

If it saved you money or time, a review on the Apify Store helps a lot.

# Actor input Schema

## `datasetIds` (type: `array`):

One or more product datasets: junglee/Amazon-crawler, apt_marble/amazon-search-results-scraper, Walmart scrapers, grocery scrapers (Woolworths, Coles, ALDI, Tesco, Costco) and look-alikes. Each row needs a product title (or name) and a price. In a scraper's Integrations tab, set this to {{resource.defaultDatasetId}}.

## `fileUrl` (type: `string`):

A public link to a CSV, Excel, JSON or JSON Lines file of products, or your own sheet with a title column and a price column (optional size, brand, url, search or category column). Google Sheets share links work (set 'Anyone with the link can view').

## `fileFormat` (type: `string`):

Leave on 'Detect automatically' unless the link has no file extension.

## `sheetName` (type: `string`):

Which sheet to read from an Excel workbook. Defaults to the first sheet.

## `data` (type: `array`):

Rows as JSON objects, for a quick run or an AI agent call, e.g. \[{"title": "Tide Liquid Laundry Detergent, 100 Loads, 132 fl oz", "price": 19.94, "searchQuery": "laundry detergent"}]. Scraper rows can be passed as they are.

## `groupBy` (type: `string`):

Which column says which products belong together (a search term, category or URL). Leave empty to use the search or category column the scraper wrote; type all to compare every row together.

## `compareBy` (type: `string`):

The one unit every product in a group is put on. Auto picks the unit most products in the group have.

## `overpricedPct` (type: `integer`):

A product whose unit price is this much above its group median is marked overpriced (2.4 times this is very overpriced).

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

Groups with fewer sized products than this are not ranked.

## `onlyFlagged` (type: `boolean`):

Write only products marked overpriced or very overpriced, or bigger packs that cost more per unit than a smaller pack of the same brand. Filtering does not change the charge.

## `keepInputFields` (type: `boolean`):

Also copy every column of the input row into the output (under input), so ids and your own notes come back with each product.

## `maxResults` (type: `integer`):

How many product rows to write, cheapest per unit first within each group.

## `maxItems` (type: `integer`):

Safety cap on rows read from the input.

## `exportFormats` (type: `array`):

Also save the products as CSV and/or Excel in the run's key-value store (charged once per file).

## `outputDatasetName` (type: `string`):

Also append the rows to a named dataset, for example to track unit prices across weekly runs.

## Actor input object example

```json
{
  "fileUrl": "https://nerolabs-samples.nerolabs.workers.dev/sample-unit-prices.json",
  "fileFormat": "auto",
  "compareBy": "auto",
  "overpricedPct": 25,
  "minGroupSize": 3,
  "onlyFlagged": false,
  "keepInputFields": false,
  "maxResults": 1000,
  "maxItems": 100000
}
```

# Actor output Schema

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

One row per product: search or group, rank, verdict, price, unit price on one unit, gap vs the group median, pack size read, flags, why, store unit price and link.

## `summary` (type: `string`):

Products read and compared, per-group cheapest and dearest, median unit price, spread, overpriced and bigger-pack counts, export links and warnings.

# 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 = {
    "fileUrl": "https://nerolabs-samples.nerolabs.workers.dev/sample-unit-prices.json"
};

// Run the Actor and wait for it to finish
const run = await client.actor("nerolabs/price-per-unit-calculator").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 = { "fileUrl": "https://nerolabs-samples.nerolabs.workers.dev/sample-unit-prices.json" }

# Run the Actor and wait for it to finish
run = client.actor("nerolabs/price-per-unit-calculator").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 '{
  "fileUrl": "https://nerolabs-samples.nerolabs.workers.dev/sample-unit-prices.json"
}' |
apify call nerolabs/price-per-unit-calculator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nerolabs/price-per-unit-calculator"
        }
    }
}
```

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/GkQngfEkqL88Nk0VO/builds/scEGqERVyrHK2HsF4/openapi.json
