# Peru Supermarket Scraper (`bewildered_hart/peru-supermarket-scraper`) Actor

- **URL**: https://apify.com/bewildered_hart/peru-supermarket-scraper.md
- **Developed by:** [Oscar D. Villegas Aguirre](https://apify.com/bewildered_hart) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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

## Peru Supermarket Scraper — plazaVea & Tottus

Collect public product listings and PEN prices from **plazaVea and Tottus in Peru**. Search by text or browse a retailer category, then receive a consistent dataset with product names, brands, prices, images and product links.

The Actor uses native HTTP requests: plazaVea's public VTEX catalog and Tottus's embedded JSON. **No browser automation, retailer login or proxy is configured.**

Use the results for price research, catalog comparisons and periodic snapshots in your own workflow. This Actor retrieves a current snapshot; it does not maintain historical price comparisons or send alerts.

### Start with a small search

In Apify Console, open the Actor's **Input**, switch to JSON if needed, and use:

```json
{
    "retailers": ["plazavea", "tottus"],
    "mode": "search",
    "queries": ["arroz"],
    "maxItemsPerQuery": 10
}
```

Start the run, wait for **SUCCEEDED**, and open its dataset. This input scans up to 10 catalog positions per retailer, not 10 across both stores. Fewer records may be saved when a listing lacks the required fields or prices.

Download the results using the dataset export options in Apify Console. A successful build alone does not prove a successful extraction: inspect the run status, logs and dataset.

### What you get

Each saved record has exactly these 13 fields:

| Field         | Type            | Meaning                                                                                      |
| ------------- | --------------- | -------------------------------------------------------------------------------------------- |
| `scraped_at`  | string          | ISO timestamp when the record was normalized                                                 |
| `retailer`    | string          | `plazavea` or `tottus` for the supported scope                                               |
| `sku`         | string          | Retailer's product ID, not its variant/SKU ID                                                |
| `ean`         | string or null  | First plazaVea SKU's barcode; null for Tottus                                                |
| `title`       | string          | Product name                                                                                 |
| `brand`       | string          | Product brand                                                                                |
| `category`    | string          | plazaVea top-level category, or Tottus category-listing label; empty when no name is exposed |
| `currency`    | string          | Always `PEN`                                                                                 |
| `price`       | number          | Public selling price from the selected source                                                |
| `list_price`  | number          | Public regular/list price from the selected source                                           |
| `available`   | boolean or null | plazaVea's availability flag; **null for Tottus**, not inferred from delivery text           |
| `image_url`   | string or null  | First product image, or null when missing/invalid                                            |
| `product_url` | string          | Link to the product on the retailer's website                                                |

Illustrative Tottus record; these prices are an example, not a live quote:

```json
{
    "scraped_at": "2026-11-16T16:00:00.000Z",
    "retailer": "tottus",
    "sku": "113707060",
    "ean": null,
    "title": "Arroz Faraon Extra Bolsa 5 Kg",
    "brand": "FARAON",
    "category": "",
    "currency": "PEN",
    "price": 23.9,
    "list_price": 26.9,
    "available": null,
    "image_url": "https://media.tottus.com.pe/tottusPE/41086701_1/public",
    "product_url": "https://www.tottus.com.pe/tottus-pe/articulo/113707060/arroz-faraon-extra-bolsa-5-kg"
}
```

#### How prices are selected

- **plazaVea:** first SKU, first seller's `commertialOffer.Price` and `ListPrice`. Zero prices and products marked unavailable are retained.
- **Tottus:** `internetPrice` for `price`, and `normalPrice` for `list_price`, selected by price type rather than array order. Card-exclusive `cmrPrice` is **not** substituted for the ordinary selling price.
- Records missing required identity, brand or price fields are skipped with warnings. In particular, Tottus records without both required price types are not saved. No missing prices or stock values are fabricated.

### Input reference

| Field              | Default        | Accepted values / behavior                                               |
| ------------------ | -------------- | ------------------------------------------------------------------------ |
| `retailers`        | `["plazavea"]` | Use `plazavea`, `tottus`, or both                                        |
| `mode`             | `"search"`     | `search` or `category`                                                   |
| `queries`          | `["arroz"]`    | Non-empty text strings in search mode, such as `arroz` or `leche gloria` |
| `categoryPaths`    | `[]`           | Non-empty retailer-specific paths in category mode                       |
| `maxItemsPerQuery` | `20`           | Integer 1–500; catalog positions scanned per retailer and query/category |

EAN values can be supplied as search text, but neither adapter guarantees exact barcode matching.

The code and input interface retain legacy `metro` and `wong` options. **They are not live-verified or part of the current supported offering.** Use plazaVea and Tottus only.

### Category examples

Category identifiers are retailer-specific. Run categories for the two retailers separately; a Tottus category is not a VTEX slug.

#### plazaVea

```json
{
    "retailers": ["plazavea"],
    "mode": "category",
    "categoryPaths": ["abarrotes"],
    "maxItemsPerQuery": 5
}
```

#### Tottus

```json
{
    "retailers": ["tottus"],
    "mode": "category",
    "categoryPaths": ["CATG16076/Carnes"],
    "maxItemsPerQuery": 5
}
```

For Tottus, include the actual `CATG...` identifier and category label from its listing URL. Category paths can change; an example is not a guarantee of future availability.

### Request limits and reliability

- Requests run sequentially, with a **400 ms pause** between requests across all retailers and queries.
- HTTP **429/503** receives two retries, with 800 ms and 1600 ms pauses. Other HTTP errors fail the run.
- Each fetch has a **30-second timeout**.
- plazaVea uses inclusive VTEX windows of up to 50 products. Tottus uses one-based page numbers and its observed 48-product pages.
- Extraction stops at the configured scan cap, empty pages or the relevant pagination boundary. Tottus repeated or misnumbered pages fail instead of silently producing repeated output.
- Invalid JSON, missing Tottus embedded data or access restrictions fail visibly; no anti-bot bypass is implemented.
- Already saved records remain available if a later request fails. A failed run can therefore have partial output.
- Overlapping queries and repeated runs may produce duplicates. There is no global deduplication.

#### Important limitations

Prices and availability reflect the retailer's default public context, which may differ by seller, sales channel, location and time. They are not guaranteed checkout prices or complete inventory information.

Tottus is read from inert `__NEXT_DATA__` JSON; scripts in the page are never executed. Its stock and EAN are not verified, and search listings do not expose a usable category name. Page-format changes may require adapter maintenance.

The Actor does not guarantee exhaustive catalog coverage. Respect retailer terms, robots policies and applicable data-use requirements. No personal customer information is intentionally collected.

### Troubleshooting

| Symptom                               | What to check                                                                                              |
| ------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| Fewer records than the cap            | Inspect warnings for missing fields/prices; the cap counts positions scanned, not valid records guaranteed |
| No category results                   | Check the current retailer category path; do not mix Tottus CATG paths with VTEX slugs                     |
| HTTP 403, repeated 429/503 or timeout | Inspect the run log and retailer availability; do not bypass restrictions                                  |
| Tottus `available` is null            | Expected: delivery messages do not verify inventory                                                        |
| Run failed after saving products      | Inspect the partial dataset and `SCRAPE_STATE`; failure does not delete earlier results                    |
| Duplicate products                    | Check overlapping queries or repeated local runs; deduplication is not implemented                         |

The default key-value store's `SCRAPE_STATE` record contains `savedItems`, `status` and `updatedAt`. On a graceful abort, the Actor cancels requests, settles pending writes, saves this tally and exits. **This is not a resume cursor.** Restarting can repeat products.

### Local development and verification

Use a patched Node 24 release for the installed development toolchain, npm and Apify CLI. The Docker builder uses Node 24 and the production image uses Node 20.

On Windows with Node 24.19.0, a local plazaVea category test saved its records but failed during process shutdown with `UV_HANDLE_CLOSING`. This also occurred with compiled JavaScript. Node 24.20.0 includes a [Windows assertion fix](https://nodejs.org/en/blog/release/v24.20.0). A controlled rerun of the unchanged compiled Actor on portable Node 24.20.0 exited successfully and validated all 5 records; all 18 unit tests also passed. Use a patched runtime for local verification. The existing global Node installation was not changed. Do not count a run with a nonzero exit code as passed, even if records were saved.

```sh
npm ci
npm test
npm run build
npm run lint
apify validate-schema
```

Run the existing examples:

```sh
npm run test:local
npm run test:local:tottus
apify run --no-purge --input-file examples/plazavea-category.json
apify run --no-purge --input-file examples/tottus-category.json
```

The first command uses `storage/key_value_stores/default/INPUT.json`; the second uses `examples/tottus-search.json` and scans 50 positions to exercise two pages.

Local runs preserve storage and append results under `storage/datasets/default/`. Apify CLI may replace the local default INPUT with the selected input file. Back up a custom INPUT before testing. **Local storage is not uploaded to Apify Console.**

Local tests have exercised both adapters with real products. A platform build and run are still required to validate deployment from Apify's environment.

### Deployment and Store setup — maintainers

The `.actorignore` upload allowlist includes only the 15 audited build files. Local instructions, task logs, tests and storage are excluded. Apify CLI always includes `.actor/` files regardless of ignore patterns, so `test/deployment.test.ts` also rejects unexpected files there and external Docker contexts. Update the allowlist and its regression test deliberately when adding build inputs; never keep credentials in `.actor/` or source files.

1. Log in to the intended account with `apify login`.
2. Deploy with `apify push`. This creates or updates the Actor named in `.actor/actor.json`; confirm the destination before running it.
3. Confirm the platform build succeeds, then run the small two-retailer search above and inspect the dataset and actual run cost.
4. In the Actor's Publishing settings, complete the required listing information and sample output. The owner must review and accept the Store Publishing Terms.
5. Configure a deliberate price before enabling paid use. The **`apify-default-dataset-item`** synthetic event can charge per default-dataset record already saved by `Actor.pushData()`; do not add a second charge for the same output.
6. Complete the account's required payout/billing verification, publish to Store, and verify the public page. Publication does not require publishing source code.

The Store Pricing tab is the authoritative price for customers. A scan cap is not a spending limit. Publishing enables distribution but does **not** guarantee usage, revenue or profit; price selection requires observed platform costs. This repository does not assert that Store publication or monetization has already been activated.

### References

- [VTEX Search API](https://developers.vtex.com/docs/api-reference/search-api)
- [Apify publishing requirements](https://docs.apify.com/actors/publishing/publish)
- [Apify pay-per-event pricing](https://docs.apify.com/actors/monetize/pay-per-event)
- [Apify monetization setup](https://docs.apify.com/actors/monetize/set-up-monetization)
- [Apify payout requirements](https://docs.apify.com/actors/monetize/monthly-payouts)

# Actor input Schema

## `retailers` (type: `array`):

VTEX catalogs for plazaVea, Metro and Wong, or Tottus embedded catalog JSON without a browser.

## `mode` (type: `string`):

Search by text/EAN or browse a retailer-specific category path.

## `queries` (type: `array`):

Text or EAN queries; non-empty in search mode.

## `categoryPaths` (type: `array`):

VTEX category slugs, or Tottus CATG identifier/label (e.g. CATG16076/Carnes). Run different category formats separately.

## `maxItemsPerQuery` (type: `integer`):

Maximum catalog positions scanned per retailer and query/category. Invalid records are skipped.

## Actor input object example

```json
{
  "retailers": [
    "plazavea"
  ],
  "mode": "search",
  "queries": [
    "arroz",
    "leche gloria"
  ],
  "categoryPaths": [
    "abarrotes",
    "bebidas",
    "lacteos"
  ],
  "maxItemsPerQuery": 20
}
```

# Actor output Schema

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

No description

## `state` (type: `string`):

No description

# 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 = {
    "queries": [
        "arroz",
        "leche gloria"
    ],
    "categoryPaths": [
        "abarrotes",
        "bebidas",
        "lacteos"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("bewildered_hart/peru-supermarket-scraper").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 = {
    "queries": [
        "arroz",
        "leche gloria",
    ],
    "categoryPaths": [
        "abarrotes",
        "bebidas",
        "lacteos",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("bewildered_hart/peru-supermarket-scraper").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 '{
  "queries": [
    "arroz",
    "leche gloria"
  ],
  "categoryPaths": [
    "abarrotes",
    "bebidas",
    "lacteos"
  ]
}' |
apify call bewildered_hart/peru-supermarket-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,bewildered_hart/peru-supermarket-scraper"
        }
    }
}
```

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/yNVRC7OAkbe6AY0Sj/builds/zuDnNvGXzzS1OteLa/openapi.json
