Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ivorpad/mercadona-cli/llms.txt

Use this file to discover all available pages before exploring further.

Mercadona CLI operates in two modes. The anonymous read mode — search, batch pricing, product detail, and category browsing — requires no login and works from any IP. The authenticated mode — cart management, checkout, and order placement — requires a browser login once to seed a refresh token, after which the CLI renews the session headlessly. This guide walks through both.
1

Install the CLI

The quickest cross-platform install is via npm:
npm install -g @ivorpad/mercadona
Or, on macOS and Linux, use the curl installer:
curl -fsSL https://raw.githubusercontent.com/ivorpad/mercadona-cli/main/install.sh | sh
Confirm the binary is on your PATH:
mercadona version
See Installation for all options including manual binary download and building from source.
2

Search for products

Search the catalog using plain text. No login is required — searches go directly to Algolia.
mercadona search queso --limit 5
Example output:
[51110] Queso rallado mozzarella pizza-Roma Hacendado — 1.60€  (8.000€/kg)
[52234] Queso tierno Hacendado — 2.35€  (11.750€/kg)
[51112] Queso parmesano rallado Hacendado — 1.85€  (18.500€/kg)
[51099] Queso manchego curado Hacendado — 3.15€  (15.750€/kg)
[51120] Queso en lonchas light Hacendado — 1.60€  (13.333€/kg)
Each result shows the product id, name, price, and reference price per unit weight or volume. Pass --json to get the full Algolia hit object for agent consumption.Use --fresh to drop frozen (Congelados) and canned (Conservas) aisles from results, surfacing the fresh product when a bare term would otherwise top-rank the preserved version:
mercadona search mejillon --fresh --limit 1
3

Batch-price a shopping list

batch resolves many search terms in approximately one request, returning the top hit per term with its price. Write your list line by line and pipe it in:
printf 'queso\ncarne\nmayonesa\n' | mercadona batch -f -
Example output:
• queso     → [51110] Queso rallado mozzarella pizza-Roma Hacendado — 1.60€ (8.000€/kg)
• carne     → [34157] Carne de pimiento choricero Hacendado — 1.55€ (11.072€/kg)
• mayonesa  → [13406] Mayonesa Hacendado — 1.20€ (2.400€/L)
Or save your list to a file and pass it with -f:
mercadona batch -f lista.txt
Once you have product ids, price the basket exactly with total. It reads <id> [qty] lines (inline # comments are ignored) and sums in integer cents — fractional quantities work for weight items:
printf '51110 2\n13406 1\n' | mercadona total -f -
Or save a basket file and pass it with -f:
mercadona total -f basket.txt
4

Get product details

Fetch the full detail for a single product by its id — price, packaging format, canonical URL, and nutrition data when available:
mercadona product 13406
Example output:
[13406] Mayonesa Hacendado
  precio: 1.20€  (2.400€/L)
  formato: Bote
  url: https://tienda.mercadona.es/product/13406/mayonesa-hacendado-bote
Add --json to get the full structured response including product_information.nutritional_information, nutrition_information (allergens and ingredients), brand, ean, origin, and details:
mercadona product 13406 --json
5

Explore categories

Print the full category tree to see what top-level and nested categories are available:
mercadona categories
Fetch all products in a specific category by its id. Category 118 is Arroz (rice):
mercadona categories --id 118 --json
The --json flag returns the raw API response, which you can pipe into jq for filtering. For example, find every product in a category that has a price decrease flagged:
mercadona categories --id 112 --json | jq '.. | objects | select(.price_decreased==true)'
6

Authenticate and manage your cart (optional)

Authenticated commands require a browser sign-in once to capture a refresh token. The recommended method is import-har.Set your warehouse first. Product ids and prices are per-warehouse; online checkout requires the cart’s warehouse to match your delivery address. Resolve your postal code to the correct warehouse and save it as the default:
mercadona set-postal 28022
Import a HAR file. In your browser, open DevTools → Network, sign in to tienda.mercadona.es (by email or Google), then export the HAR from the Network panel (the download icon → “Export HAR…”). Import it:
mercadona import-har --file tienda.mercadona.es.har
This writes the durable refresh_token to ~/.mercadona/config.toml (mode 0600). Every future 401 token_not_valid response triggers an automatic headless token refresh — no browser needed again.Alternative methods. If you already have a refresh token, seed it directly with set-refresh <token>. For a quick one-off session without a refresh token, use import-curl with a DevTools “Copy as cURL” string — note that it cannot auto-renew when the access token expires. login --user … --password … also exists but requires a recaptcha_token and fails for Google accounts; import-har is strongly preferred. See Authentication for the full details.Confirm authentication:
mercadona whoami
Expected output:
ok — customer id=<your-customer-id>
Inspect and build a cart:
mercadona cart get --json
mercadona cart add 51110 2 --max 80
Apply many lines at once with cart set-many. It prices the basket first, so --max can refuse before any write happens:
printf '51110 2\n13406 1\n' | mercadona cart set-many -f - --max 80
Pass 0 as the quantity to remove a line. Use cart clear to empty the entire cart in one write.
Every command accepts --json to emit structured data to stdout with logs and errors on stderr and exit code 1 on failure. This makes all commands safe to pipe directly into jq, agent tool calls, or shell scripts without parsing human-readable text.

Next steps

Authentication

Learn the full HAR import flow, the curl import fallback, and how headless token refresh works.

Command Reference

Complete syntax and flags for every command, including common flags like --wh, --lang, and --json.

Build docs developers (and LLMs) love