# Mexico Gas Prices by Station: Gasoline, Diesel (CNE, daily) (`pracadata/mexico-fuel-prices`) Actor

Daily retail gasoline (regular, premium) and diesel prices for every gas station in Mexico reported to the CNE, in MXN, USD and EUR, with station location, state and municipality. Daily archive since 2026-10-25, updated weekly. API and AI-agent (MCP) ready.

- **URL**: https://apify.com/pracadata/mexico-fuel-prices.md
- **Developed by:** [Lucas Huber Pissaia](https://apify.com/pracadata) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 station price rows

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

## Mexico Gas Prices by Station: Gasoline, Diesel (CNE, daily)

### What does it do?

Returns **daily retail fuel prices per gas station in Mexico**, from the price file that every fuel permit holder reports to the national energy commission (CNE): **regular gasoline, premium gasoline and diesel, one row per station, product and day** (about **37,000 station prices a day from about 13,800 stations in all 32 states**), in one clean schema with prices in **MXN, USD and EUR**, the station's coordinates and its official state and municipality (INEGI). The CNE feed shows only the current day and keeps no history, so this archive starts on the first day it was captured, **25 October 2026**, and grows every day. Use it as an API, schedule it, or call it as an MCP tool from an AI agent (see "Use with AI agents (MCP)").

**Data last updated: 30 October 2026** (latest prices in the data: day 29 October 2026; CNE feed captured up to 30 Oct 2026; the `RUN_SUMMARY` of every run carries `data_build_date` and `data_until`). Refreshed weekly, daily granularity.

*Palabras clave: precios de gasolina por estación y municipio, precios de gasolina regular, premium y diésel en México, CNE, Comisión Nacional de Energía.*

**Try before you pay:** the municipality-level prices (median, quartiles, minimum and maximum by municipality, product and day) and the daily coverage table, with the rejected-row counts, are a free dataset on Hugging Face: <https://huggingface.co/datasets/pracadata/mexico-fuel-prices>. Check the schema, the coverage notes and the quality there, then come back for the per-station rows and the API. The Brazilian equivalent (weekly, ANP) is [`pracadata/brazil-fuel-prices`](https://apify.com/pracadata/brazil-fuel-prices).

### Read this first: coverage and limitations

- **Short history.** The archive starts on **25 October 2026**, the first day this project captured the CNE feed. There is no earlier history and none can be reconstructed. A few days of data show no trend: do not read one into them.
- **Prices are reported by the permit holders and are not audited.** The CNE publishes what each station reports. Typing errors and stale prices exist. Do not use the data as an official price reference.
- **Rejected rows.** Every day about **19** price rows are dropped for being outside 5 to 60 MXN per litre (so far all filler values such as `0.01` or `1`), and about **20** rows from stations that report two different prices for the same product on the same day (none of the two is kept, because there is no way to know which is right). About **111** exact duplicates a day are collapsed into one row (the price stays). The counts per day are in the free Hugging Face dataset (`fuel_coverage_daily_mx`).
- **About 0.6% of the stations in the CNE registry have no municipality** (wrong coordinates at the source: `0, 0`, empty or far from any municipality). Almost all of them report no price. Among the stations **with a price**, about 4 a day (0.03%) have `geo_flag` `no_municipality` and null state and municipality; their rows are still returned. A state or municipality filter leaves those rows out.
- **The state and municipality of a station are derived by us** from the station's coordinates (point in polygon on the INEGI municipal boundaries, December 2025), not reported by the CNE. A station with wrong coordinates can land in the wrong municipality. Ciudad de México is split by INEGI into 16 alcaldías, each one a municipality here.
- **Sale price to the public only** (price at the pump, MXN per litre). No purchase price and no other fuels (no LPG, no CNG).
- **The day of a price (`reference_date`).** The CNE updates the feed once a day at **18:00 Mexico City time (UTC-6)**. A price file captured between 18:00 on day *D* and 17:59 on day *D+1* is day *D* (`reference_date = date(capture time in UTC-6 − 18 hours)`); if several versions were captured in that window, the last one wins.
- **Nominal pesos.** USD and EUR are indicative conversions at the ECB reference rate of the previous business day.

### Why use it?

- **Prices at the pump, by station, with a history that does not exist anywhere else.** The CNE shows today's prices and forgets yesterday's; this archive keeps every day it captures, with the duplicates and filler values of the feed resolved by explicit rules.
- **Location and administrative codes ready to join.** Latitude, longitude, state and municipality (INEGI codes) on every row.
- **USD and EUR next to MXN** at the ECB reference rate of the previous business day. The rates themselves are never returned.
- **Follow the same station over time** with `station_id` (the CNE permit id), or compare municipalities and states by day.

### What data can it return?

One dataset, **one row per gas station × product × day**:

| Field | Meaning |
|---|---|
| `reference_date` | Day of the price (YYYY-MM-DD), the CNE feed day (see above) |
| `station_id` | CNE permit id of the station, for example `CNE/PL/138/EXP/ES/2025` |
| `lat`, `lon` | Station coordinates as reported to the CNE (WGS84) |
| `state`, `state_code` | Official INEGI state name and 2-digit code |
| `municipality`, `municipality_code` | Official INEGI municipality name and 5-digit code |
| `product` | `gasoline` (regular), `gasoline_premium` or `diesel` |
| `price_mxn`, `price_usd`, `price_eur` | Price per litre in each currency, always present |
| `price`, `price_currency` | The price in the currency chosen with `currency` (default USD), and which one |
| `geo_flag` | `ok`, `invalid_coords` or `no_municipality` (the price is kept in all cases) |
| `source` | The literal citation on every row: **Fuente: Comisión Nacional de Energía (CNE), precios reportados por los permisionarios (Acuerdo A/041/2018)**, with the link to the CNE page |

No station name, no permit holder's name, no address and no exchange rate in the output. All prices are MXN per litre.

### How to use it

1. Add filters: `state`, `municipality`, `product`, `station_id`, dates. All are optional.
2. Without dates you get the **latest 7 days** of the data. `date_from` and `date_to` take any day (inclusive).
3. Set **Maximum rows** (default 10,000, ceiling 1,000,000). Rows are charged one by one, so this is also your cost cap.
4. Run it and download the dataset as JSON, CSV or Excel, or read it through the API.

`state` takes the official INEGI name, ignoring case and accents (`Nuevo Leon`), the abbreviation (`CDMX`, `NL`, `BC`, `Jal.`), a common short name (`Coahuila`, `Veracruz`, `Michoacán`, `Edomex`) or the 2-digit code (`09`). Note that `México` is the state around the capital; the capital is `Ciudad de México` or `CDMX`. `municipality` takes the official INEGI name (ignoring case, accents and punctuation) or the 5-digit code (`14039` = Guadalajara). A state or municipality that does not exist is refused. Several municipalities share a name (there are 7 `Benito Juárez`): add `state`, or the run covers all of them (`RUN_SUMMARY.matched_municipalities` says how many).

#### Input examples

Each example below was run against the current data (days 25 to 29 October 2026). Row counts and cost (US$ 2 per 1,000 rows) are noted; the Pricing tab is authoritative.

Regular gasoline at every station in Ciudad de México, the last 3 days (1,160 rows, about US$ 2.32):

```json
{ "state": ["CDMX"], "product": ["gasoline"], "date_from": "2026-10-27", "max_rows": 2000 }
```

Diesel in Guadalajara, Jalisco, the latest 7 days (350 rows, about US$ 0.70):

```json
{ "municipality": ["Guadalajara"], "state": ["Jalisco"], "product": ["diesel"], "max_rows": 1000 }
```

Premium gasoline in Nuevo León, the latest day only (711 rows, about US$ 1.42):

```json
{ "state": ["NL"], "product": ["gasoline_premium"], "date_from": "2026-10-29", "max_rows": 1000 }
```

Gasoline in Tijuana since the start of the archive, with the `price` column in euros (1,220 rows, about US$ 2.44):

```json
{ "municipality": ["Tijuana"], "state": ["Baja California"], "product": ["gasoline"], "date_from": "2026-10-25", "currency": "EUR", "max_rows": 2000 }
```

Every station in the country, one day (37,276 rows, about US$ 74.55):

```json
{ "date_from": "2026-10-29", "date_to": "2026-10-29", "max_rows": 40000 }
```

Follow one station over time by its permit id (10 rows, about US$ 0.02):

```json
{ "station_id": ["CNE/PL/138/EXP/ES/2025"], "date_from": "2026-10-25", "max_rows": 100 }
```

#### Output example

```json
{ "reference_date": "2026-10-27", "station_id": "CNE/PL/633/EXP/ES/2026", "lat": 19.36326, "lon": -99.19012, "state": "Ciudad de México", "state_code": "09",
  "municipality": "Benito Juárez", "municipality_code": "09014", "product": "gasoline", "price_mxn": 23.97, "price_usd": 1.2862, "price_eur": 1.1535, "price": 1.2862,
  "price_currency": "USD", "geo_flag": "ok",
  "source": "Fuente: Comisión Nacional de Energía (CNE), precios reportados por los permisionarios (Acuerdo A/041/2018), https://www.cne.gob.mx/ConsultaPrecios/GasolinasyDiesel/GasolinasyDiesel.html" }
```

### Use with AI agents (MCP)

The Apify MCP server lets an AI agent find this Actor in the Store, read its input schema and call it as a tool. The agent discovers it with `search-actors` and `fetch-actor-details`, runs it with `call-actor` (the run's `maxTotalChargeUsd` goes in `callOptions`, not in the Actor input) and reads the rows with `get-dataset-items`. Running Actors needs an Apify account; searching and reading details does not.

**Connect.** The hosted server is `https://mcp.apify.com` (sign-in through the browser, OAuth). To give the agent this Actor as its own tool, add it to the `tools` parameter:

```
https://mcp.apify.com?tools=pracadata/mexico-fuel-prices
```

- **Claude (Desktop or web):** Settings → Connectors → Add custom connector, paste the URL above, sign in to Apify.
- **Cursor, VS Code and other clients with an `mcpServers` file:**

```json
{
  "mcpServers": {
    "apify": { "url": "https://mcp.apify.com?tools=pracadata/mexico-fuel-prices" }
  }
}
```

Without a browser (servers, CI), use a token instead: add `"headers": { "Authorization": "Bearer <APIFY_TOKEN>" }` next to `url`. The Apify docs also describe a configurator at <https://mcp.apify.com> and the CLI command `apify mcp install <client>`.

**What an agent should know.** Always set `max_rows` (it caps the cost) and a small **maximum charge per run**: one day for the whole country is 37,000 rows (US$ 74). Use `state` by name, abbreviation or code, `municipality` by name or 5-digit code, and `station_id` to follow a station. The data is **updated weekly with daily granularity**; read `RUN_SUMMARY.data_until` for how recent it is, and note that the history is short (it starts on 2026-10-25). For municipality-level statistics, the free Hugging Face dataset is smaller and cheaper (see "Try before you pay").

| Question | Input (fields) | Rows | Cost | Suggested max charge |
|---|---|---|---|---|
| "What does regular gasoline cost in Ciudad de México over the last 3 days, in dollars?" | `state` CDMX, `product` gasoline, `date_from` 2026-10-27. Read `price_usd` | 1,160 | US$ 2.32 | US$ 3 |
| "Diesel prices in Guadalajara over the last 7 days" | `municipality` Guadalajara, `state` Jalisco, `product` diesel | 350 | US$ 0.70 | US$ 1 |
| "Where is premium gasoline cheapest in Nuevo León today?" | `state` NL, `product` gasoline_premium, `date_from` the latest day. Sort by `price_mxn` | 711 | US$ 1.42 | US$ 2 |
| "Did this station change its price?" | `station_id`, `date_from` 2026-10-25 | (varies) | US$ 2 per 1,000 rows | US$ 1 (cap with `max_rows`) |

The first question as the exact input an agent sends:

```json
{ "state": ["CDMX"], "product": ["gasoline"], "date_from": "2026-10-27", "currency": "USD", "max_rows": 1500 }
```

### Pricing

Pay per event. There is one event, and rows are charged before they are delivered.

| Event | When | Price |
|---|---|---|
| `station-price-row` | each row returned | US$ 2 per 1,000 rows |

Rows are charged in batches, and the Actor stops when your *maximum charge per run* is reached: you never get a row you were not charged for, and you are never charged for a row you did not get. `RUN_SUMMARY` says so (`stopped_by_spending_limit`, and `charged`, the events actually charged). The default is the latest 7 days with data, about 186,000 rows (US$ 373), so set `max_rows` and your maximum charge on purpose.

### Privacy

Each row carries the **CNE permit id (`station_id`) and the coordinates (`lat`, `lon`)** of a gas station, as the CNE publishes them in its price file. These identify a business establishment; some stations are run by a sole trader, so the establishment can point to a person. The rows contain **no names** (neither the station's nor the permit holder's), no addresses, no tax ids and no data about customers. Treat the data as public business records and do not use it to identify, locate or contact individuals. Removal requests and data-protection questions go to `lucashpissaia@gmail.com`.

### Source and attribution

- **Fuente: Comisión Nacional de Energía (CNE), precios reportados por los permisionarios (Acuerdo A/041/2018).** The price file that the permit holders must report under agreement A/041/2018 of the Comisión Reguladora de Energía, published by the CNE: <https://www.cne.gob.mx/ConsultaPrecios/GasolinasyDiesel/GasolinasyDiesel.html>. Every row carries this citation in `source`.
- **Fuente: INEGI, Marco Geoestadístico, diciembre de 2025.** Municipal boundaries, names and codes, used under the INEGI "Términos de Libre Uso de la Información" (commercial use allowed with credit to INEGI as author): <https://www.inegi.org.mx/inegi/terminos.html>. The assignment of each station to a municipality is our own derived work, not an INEGI product, and INEGI has not endorsed it.
- **Fuente: Banco Central Europeo**, euro reference exchange rates (used for `price_usd` and `price_eur`). The rates are never returned.

### Licence and terms

- **Source terms.** This is official public data of the Mexican government, redistributed with attribution. **The CNE page publishes no licence or terms of use** for the price file. Check the source terms for your use, and cite the sources above if you publish.
- **Unofficial.** This Actor is a derived, **unofficial** work and is **not affiliated with, endorsed by or approved by the CNE or INEGI**. Do not use it as a regulated price reference without checking the CNE.
- **Use:** internal use (your own analysis, models, reports and products built on top of the data). Do **not** resell or redistribute the raw rows in volume or as a substantially similar dataset or API.
- **No warranty:** the data is provided as is, from public sources, with the limitations above. It is not an appraisal and not official.
- **Withdrawal:** if the CNE or INEGI restrict the reuse of their data, the Actor may be withdrawn. Takedown requests: `lucashpissaia@gmail.com`.

### Known limitations

- **Short history, from 2026-10-25 on.** Earlier dates return no rows.
- **Reported, not audited prices** (see "Read this first"); obvious filler values and conflicting reports are rejected, other errors may remain.
- **Municipality is derived from the coordinates**, and about 0.03% of the stations with a price have none (`geo_flag` `no_municipality`); a geographic filter leaves them out.
- **Currencies.** `price_usd` and `price_eur` use the ECB reference rate of the previous business day, or the latest one in the 7 days before it (USD/MXN is a cross rate), and are null when no such rate exists. They are indicative conversions of the pump price; the rate is not returned.
- **Prices are nominal.** No inflation adjustment.
- **One price per station and product per day**: the last version of the CNE file captured in the day window.
- **A day without a new capture has no rows.** The capture stores a version only when the CNE file changes; the feed has changed every day so far.

### FAQ and support

**How fresh is the data?** The CNE updates its file daily at 18:00 Mexico City time; the data here is refreshed weekly, with daily granularity. `RUN_SUMMARY.data_until` is the last day with data and `data_build_date` is when this build was made.

**Can I get everything?** Yes: set `max_rows` to 1,000,000 and page by date range. One day is about 37,000 rows.

**Is there a free sample?** Yes, the municipality-level prices on Hugging Face (see "Try before you pay").

**Can I use it from an AI agent?** Yes. Pay-per-event Actors are available as MCP tools on Apify; the input fields above are the tool arguments. See "Use with AI agents (MCP)".

Found a problem or need another field? Use the Issues tab.

# Actor input Schema

## `state` (type: `array`):

One or more Mexican states by official INEGI name (case and accents are ignored: `Nuevo Leon` = `Nuevo León`), by abbreviation (`CDMX`, `NL`, `BC`, `Jal.`), by common short name (`Coahuila`, `Veracruz`, `Michoacán`, `Edomex`) or by 2-digit code (`09` = Ciudad de México, `14` = Jalisco). Optional. Combined with `municipality`, it narrows it (useful for names that repeat across states, such as Benito Juárez). A state that does not exist is refused. Note that `México` is the state surrounding the capital.

## `municipality` (type: `array`):

One or more municipalities, by official INEGI name (case, accents and punctuation are ignored: `Merida`, `mérida` and `MÉRIDA` are the same) or by 5-digit municipality code (`09014` = Benito Juárez, Ciudad de México; `14039` = Guadalajara). Several municipalities share a name (there are 7 `Benito Juárez`): add `state`, or the run covers all of them (`RUN_SUMMARY.matched_municipalities` says how many). A name that does not exist is refused. Up to 200 values.

## `product` (type: `array`):

One or more of `gasoline` (regular grade), `gasoline_premium` (premium) and `diesel`. All in MXN per litre. No value means every product.

## `date_from` (type: `string`):

First day, format YYYY-MM-DD. Optional; the default is 6 days before `date_to` (7 days in total). The day is the CNE `reference_date`: the official feed turns over at 18:00 Mexico time, so a day starts the evening before (see README). The archive starts on 2026-10-25.

## `date_to` (type: `string`):

Last day, format YYYY-MM-DD, inclusive. Optional; the default is the latest day in the data (see `data_until` in the run summary).

## `station_id` (type: `array`):

One or more station ids exactly as in the `station_id` column (the CNE permit id of the station, for example `CNE/PL/138/EXP/ES/2025`; case is ignored). Optional, up to 500. Use it to follow the same stations over time.

## `max_rows` (type: `integer`):

Maximum number of rows returned (1 to 1,000,000; default 10,000). Rows are charged one by one, so this is also the cost cap: 10,000 rows is US$ 20. Set a small value (for example 10) to test a query. If the filter matches more rows, the rest is not returned: `RUN_SUMMARY.capped_by_max_rows` is true. The whole country for one day is about 37,000 rows.

## `currency` (type: `string`):

Which currency fills the `price` column (`price_currency` says which). `price_mxn`, `price_usd` and `price_eur` are always present. USD and EUR use the ECB reference rate of the previous business day, or the latest one in the 7 days before it (USD/MXN is a derived cross rate), and are null when no rate exists; MXN is the price as reported to the CNE. Default: USD.

## Actor input object example

```json
{
  "state": [
    "Jalisco",
    "CDMX"
  ],
  "municipality": [
    "Guadalajara"
  ],
  "product": [
    "gasoline"
  ],
  "date_from": "2026-10-25",
  "date_to": "2026-10-29",
  "station_id": [
    "CNE/PL/138/EXP/ES/2025"
  ],
  "max_rows": 100,
  "currency": "USD"
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset with the returned rows

## `files` (type: `string`):

Key-value store with RUN_SUMMARY

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

RUN_SUMMARY: applied filters, rows returned and charged, data build date, first and last day in the data, sources and whether the maximum charge stopped the run

# 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 = {
    "max_rows": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("pracadata/mexico-fuel-prices").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 = { "max_rows": 10 }

# Run the Actor and wait for it to finish
run = client.actor("pracadata/mexico-fuel-prices").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 '{
  "max_rows": 10
}' |
apify call pracadata/mexico-fuel-prices --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,pracadata/mexico-fuel-prices"
        }
    }
}
```

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/RY3kylErlpCkMwTwm/builds/8OgWxnH5RdqOflbtH/openapi.json
