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’s catalog is per-warehouse — the same product ID can have a different price or be unavailable in a different warehouse, and online checkout requires the cart’s warehouse to match the delivery address. Set your warehouse once with mercadona set-postal and every subsequent search, cart, and checkout command automatically uses the right region without any extra flags. set-postal resolves a Spanish postal code to its serving warehouse via POST /api/postal-codes/actions/change-pc/, reads the x-customer-wh response header, and saves both postal_code and warehouse to ~/.mercadona/config.toml [defaults]. No login is needed — this is an anonymous call and is safe to run before authenticating.
mercadona set-postal 28022   # Madrid (east) → mad1
mercadona set-postal 28013   # Madrid (centre) → mad3
mercadona set-postal 08001   # Barcelona → bcn1
A successful run prints:
ok — postal code 28022 → warehouse mad1 (saved to ~/.mercadona/config.toml)
→ search, cart and checkout now default to this warehouse (override per-command with --wh).
If the postal code is undeliverable (no warehouse returned by the API), the command errors and leaves config.toml untouched. Pass --json to get a machine-readable result:
mercadona set-postal 28022 --json
{
  "postal_code": "28022",
  "warehouse": "mad1"
}

Known warehouse codes

The table below lists the warehouse codes confirmed in the source and README. Within a city, the correct code depends on which distribution centre serves that specific postcode — two postcodes in the same city can map to different warehouses.
City / RegionWarehouse codeExample postal
Madrid (most areas)mad128022
Madrid (centre)mad328013
Barcelonabcn108001
Valenciavlc1
Sevillasvq1
Baleares (Mallorca)3842
Use set-postal with a specific postcode rather than hard-coding a warehouse code — it queries the live API and handles any future redistricting automatically.

Override the warehouse per command

Any command that reads catalog data or writes the cart accepts a --wh flag that takes precedence over the saved default for that one invocation:
mercadona search sobrasada --wh 3842         # Baleares catalog
mercadona product 5044 --wh bcn1             # Barcelona price
mercadona cart get --wh mad1                 # Madrid cart (must match delivery address)

Precedence

Active warehouse is resolved in this order — highest wins:
PrioritySource
1 (highest)--wh flag on the command
2config.toml [defaults].warehouse (set by set-postal)
3 (lowest)Built-in default: mad1

import-har also saves the warehouse

If you authenticate with mercadona import-har, the CLI reads the warehouse from the captured session headers and writes it to [defaults].warehouse automatically — the same way set-postal does. Either approach produces the same result in config.toml.

Why it matters: catalog vs. price

Prices are identical nationwide — Mercadona’s “Siempre Precios Bajos” policy means the same product costs the same in Madrid, Barcelona, Valencia, Sevilla, and the Balearic Islands:
for wh in mad1 bcn1 vlc1 svq1 3842; do
  mercadona product 5044 --wh $wh --json
done
idProductmad1bcn1vlc1svq13842
5044Arroz redondo Hacendado1.20€1.20€1.20€1.20€1.20€
4740AOVE Hacendado4.95€4.95€4.95€4.95€4.95€
10379Leche entera Hacendado5.76€5.76€5.76€5.76€5.76€
What does differ is which products exist in each warehouse. Regional specialties are only stocked locally — for example, Baleares carries 28 sobrasada products while Madrid carries 19, including items like [20869] Sobrasada de Mallorca Can Pere Joan and [53114] Sobrasada cerdo negro de Mallorca that are absent from mad1:
mercadona search sobrasada --wh mad1 --json | jq .nbHits   # 19
mercadona search sobrasada --wh 3842 --json | jq .nbHits   # 28
A product ID that resolves in one warehouse may return a 404 in another — always use the warehouse that matches your delivery address.
For online checkout, the cart’s warehouse must match the delivery address. A mismatch causes checkout to fail at the API level. Run mercadona set-postal <your-postcode> once to align the two before building a cart you intend to submit.

Build docs developers (and LLMs) love