# Metro Peru Scraper (`barefoot_grade/metro-peru-scraper`) Actor

Product price search on Metro, Peru's leading grocery chain. Search by keyword and get structured records: name, brand, price, list price, stock, unit data, price-per-kg and URLs.

- **URL**: https://apify.com/barefoot\_grade/metro-peru-scraper.md
- **Developed by:** [Philip Kirkbride](https://apify.com/barefoot_grade) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.40 / 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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Metro Peru — product search & price scraper

Search Metro Peru's full online grocery catalog and get clean, structured prices in PEN on every run — names, brands, per-kilo prices, stock and product URLs.

🇵🇪 **Peru** · storefront: `www.metro.pe` · prices in **PEN** (PE)

Every run returns normalized product records — name, brand, current and list price in PEN, per-kilogram price, stock level, product and image URLs — ready for datasets, spreadsheets or dashboards. Fast, structured results: no manual copy-paste.

### Use cases

- **Grocery price monitoring** — track daily and weekly price moves on Peruvian staples (rice, milk, oil, sugar) across Metro's catalog.
- **Basket comparison** — pair with the sibling chain scrapers (Wong, PlazaVea, Vivanda) and find the cheapest basket item by item; the normalized `pricePerKg` makes unit-price comparison trivial.
- **Promo tracking** — `price` vs `listPrice` exposes active discounts; `inStock` and `availableQuantity` flag availability gaps before promotions go live.
- **Assortment and catalog feeds** — brand, pack size (`unitMultiplier`, `measurementUnit`), image and URL fields for PIM imports, search indexes or price pages.
- **Market research** — build historical price series for CPG category analysis in the Peruvian market.

### What it returns

- `productKey` — stable unique product ID for this store; join and dedupe on this, never the bare `id`
- `name` / `brand` — product display name and brand
- `price` / `listPrice` / `currency` — current and list price; the currency for this store is always PEN
- `unitMultiplier` / `measurementUnit` — pack size (a 5 kg bag → multiplier 5, unit kg)
- `pricePerKg` — normalized per-kilogram price when the weight is known, `null` otherwise
- `availableQuantity` / `inStock` — stock count (99999 means effectively unlimited) and availability flag
- `url` / `imageUrl` — product page and product image
- `store` / `searchQuery` / `categoryResolved` — run provenance: store slug, the query used, and whether the optional category filter resolved

### Input

- `search` — **required**; free-text product search, e.g. `arroz`
- `category` — optional; free-text category to scope the search against the store's own category tree (e.g. `huevos`)
- `maxPages` — 1–5 result pages (default 1; 24 products per page)
- `maxResults` — cap on returned products (default 50, max 200)
- `requestDelaySecs` — politeness delay between result pages (default 1.0 s)

This record always searches `www.metro.pe` — no store selection is needed (or offered); every record of this family is fixed to one storefront.

### Example queries

{"store": "metro", "search": "arroz", "maxResults": 10}
{"store": "metro", "search": "leche gloria", "category": "lácteos", "maxResults": 5}
{"store": "metro", "search": "pollo entero", "maxResults": 5}
{"store": "metro", "search": "detergente", "maxResults": 20}

### Output example

```json
[
  {
    "productKey": "metro.pe:34075",
    "name": "Arroz Extra 5 kg",
    "brand": "Marca Blanca",
    "price": 26.9,
    "listPrice": 29.9,
    "currency": "PEN",
    "unitMultiplier": 5,
    "measurementUnit": "kg",
    "availableQuantity": 147,
    "pricePerKg": 5.38,
    "inStock": true,
    "url": "https://www.metro.pe/arroz-extra-5kg/p",
    "imageUrl": "https://www.metro.pe/arquivos/ids/34075/arroz-extra.jpg",
    "store": "metro",
    "searchQuery": "arroz",
    "categoryResolved": true
  }
]
```

### Quirks

- Metro shares its product catalog with Wong (both are Cencosud chains), so overlapping product IDs are normal — always join and dedupe on `productKey`, never the bare `id`.
- Category scoping uses Metro's own category tree: a `category` name that resolves on another chain may not resolve here. When it doesn't, the run still completes as a plain search and records carry `categoryResolved: false`.
- Pack sizes dominate pricing on groceries — compare offers on `pricePerKg` (or `price / unitMultiplier`), not shelf price.

# Actor input Schema

## `search` (type: `string`):

Required product search term (e.g. 'arroz'), sent as the storefront's full-text query. Exactly the inputs listed here are implemented; there is no detail-enrichment flag in v1.

## `category` (type: `string`):

Optional free-text category to scope the search (e.g. 'huevos'). Matched case-insensitively (accent-insensitive) against the store's own category tree; on a unique match the search is restricted to that category, which removes off-topic hits such as egg cutters for 'huevos'. If nothing or several categories match, the run falls back to the plain full-text search and every record carries categoryResolved=false.

## `maxPages` (type: `integer`):

Search-result pages to fetch (24 products per page).

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

Stop after this many products.

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

Minimum 0.5 seconds.

## Actor input object example

```json
{
  "search": "arroz",
  "maxPages": 1,
  "maxResults": 50,
  "requestDelaySecs": 1
}
```

# Actor output Schema

## `results` (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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("barefoot_grade/metro-peru-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("barefoot_grade/metro-peru-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 '{}' |
apify call barefoot_grade/metro-peru-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,barefoot_grade/metro-peru-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/0mdTP5gGrvzvCgMHo/builds/iiuqc1WWVImKENgWv/openapi.json
