Mexico Gas Prices API by Station (Official CNE)
Pricing
from $3.00 / 1,000 station rows
Mexico Gas Prices API by Station (Official CNE)
Get today's gas prices at every Mexican gas station from the official CNE feed: regular, premium and diesel MXN/liter, permit number, coordinates, distance. For fleets, station owners and AI agents: sort by cheapest, area min/max/avg, no API key. JSON, CSV, API or MCP; $3 per 1,000 stations.
Pricing
from $3.00 / 1,000 station rows
Rating
0.0
(0)
Developer
Japan Open Data
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
12 hours ago
Last modified
Categories
Share
Mexico Gas Prices API by Station (Official CNE Data)
Get today's gas prices at every Mexican gas station near any point: regular (Magna), premium and diesel price per liter in MXN, with the station's CNE permit number, coordinates and distance. The data is the official daily price feed of Mexico's energy regulator, the Comisión Nacional de Energía (CNE), covering about 13,800 stations nationwide. Search by latitude/longitude and radius, sort by nearest or cheapest, and optionally add one summary row with the minimum, maximum and average price of each fuel in the area — one flat JSON row per station, no API key needed.
- Official data: the prices that gas station permit holders report to the CNE (formerly the CRE — Comisión Reguladora de Energía), published daily. Open data under CC BY 4.0.
- Precios de gasolina hoy por estación: gasolina Magna, Premium y diésel for every gasolinera within your radius, in pesos per liter.
- Cheapest gas near a location:
sortBy: "price"returns the cheapest stations first for the fuel you choose. - Area benchmark in one row:
includeSummary: trueadds min / max / average per fuel for all stations within the radius — the "competitor price range" that gas station owners pay monitoring services for. - Pay only for results: $3 per 1,000 station rows. "Nothing found" and error rows are free.
What can you do with the Mexico Gas Prices API?
- Trucking, logistics and fleets. Find the cheapest diesel around a depot or along a route, check fuel card receipts against the reported price, and pick refuelling stops. Run it once per stop (e.g. every 50–100 km) with
fuelType: "diesel"andsortBy: "price". - Gas station owners and operators. Monitor your competitors' prices every day: all stations within 3–10 km of your station with permit number, prices and distance, plus the local min / max / average in one summary row.
- Price comparison apps, analysts and AI agents. Feed a map or a chatbot ("where is the cheapest premium near Guadalajara?"), compare regional fuel prices and inflation, or build your own daily price history by scheduling the Actor.
How to use
- Click Start with the default input: you get the 50 nearest stations within 5 km of central Mexico City (Zócalo).
- Enter the latitude and longitude of your point (see common city centers below) and a radius in km.
- Optionally choose a fuel type (regular, premium, diesel) and sort by price to get the cheapest stations first.
- Turn on Add a price summary row to get the area's min / max / average prices.
- Download the results as JSON, CSV or Excel, or call the Actor via API / MCP (see below). Use Apify Schedules to collect prices every day.
This Actor takes coordinates, not addresses or city names (the official feed has no address, state or city fields). Common centers: Mexico City 19.4326,-99.1332, Guadalajara 20.6597,-103.3496, Monterrey 25.6866,-100.3161, Puebla 19.0414,-98.2063, Tijuana 32.5149,-117.0382, Querétaro 20.5888,-100.3899, Mérida 20.9674,-89.5926.
Input
Only latitude and longitude are required, and both have defaults.
| Input | Type | Default | What it does |
|---|---|---|---|
latitude | number | 19.4326 | Latitude of the search center (Mexico is about 14 to 33). |
longitude | number | -99.1332 | Longitude of the search center (negative in Mexico, about -118 to -86). |
radiusKm | number | 5 | Only stations within this distance are returned (0.1–3000 km; 3000 covers all of Mexico). |
fuelType | any / regular / premium / diesel | any | any = every station with at least one price. A specific fuel returns only stations that report it, and price sorting uses it. |
sortBy | distance / price | distance | Nearest first, or cheapest first for the chosen fuel (regular when fuelType is any; stations without that price go last). |
maxResults | integer | 50 | Maximum number of station rows (1–20,000). |
includeSummary | boolean | false | Adds one rowType: "summary" row with station count and min / max / average price per fuel for all matching stations in the radius (not only the returned ones). |
Input example
The 3 cheapest stations for regular gasoline within 5 km of central Mexico City, plus the area summary:
{"latitude": 19.4326,"longitude": -99.1332,"radiusKm": 5,"fuelType": "regular","sortBy": "price","maxResults": 3,"includeSummary": true}
Output
Real output from the input above (run on 2026-09-19; source shortened): one summary row and three station rows.
{"status": "ok","rowType": "summary","searchLatitude": 19.4326,"searchLongitude": -99.1332,"radiusKm": 5.0,"fuelType": "regular","stationCount": 96,"regularMin": 22.59, "regularMax": 24.49, "regularAvg": 23.73, "regularStationCount": 96,"premiumMin": 22.97, "premiumMax": 29.99, "premiumAvg": 28.8, "premiumStationCount": 94,"dieselMin": 26.87, "dieselMax": 27.19, "dieselAvg": 26.99, "dieselStationCount": 30,"currency": "MXN","fetchedAt": "2026-09-19T04:47:43Z","source": "Comisión Nacional de Energía (CNE), Mexico - Precios de expendio de gasolinas y diésel (datos.gob.mx, CC BY 4.0); ..."}
{"status": "ok","rowType": "station","placeId": "9985","permitNumber": "PL/8939/EXP/ES/2015","name": "CORPORACION GASOLINERA MILLENIUM SA DE CV","holderType": "company","latitude": 19.43856,"longitude": -99.119,"distanceKm": 1.63,"regularPrice": 22.59,"premiumPrice": 27.99,"dieselPrice": null,"currency": "MXN","fetchedAt": "2026-09-19T04:47:43Z","source": "Comisión Nacional de Energía (CNE), Mexico - Precios de expendio de gasolinas y diésel (datos.gob.mx, CC BY 4.0); ..."}
| placeId | permitNumber | name | holderType | distanceKm | regular | premium | diesel |
|---|---|---|---|---|---|---|---|
| 9985 | PL/8939/EXP/ES/2015 | CORPORACION GASOLINERA MILLENIUM SA DE CV | company | 1.63 | 22.59 | 27.99 | null |
| 10893 | PL/3203/EXP/ES/2015 | CONSORCIO GASOLINERO PLUS SA DE CV | company | 1.666 | 22.59 | 27.99 | null |
| 8346 | PL/6363/EXP/ES/2015 | null | individual_redacted | 4.586 | 22.77 | 22.97 | null |
Invalid input and searches with no stations return one free row that says what to change (real output):
{"status": "not_found", "fetchedAt": "2026-09-19T04:36:43Z", "searchLatitude": 35.68, "searchLongitude": 139.76, "radiusKm": 5, "error": "No gas stations with reported prices within 5 km of 35.68,139.76; the point is outside Mexico; use Mexican coordinates (latitude about 14 to 33, longitude about -118 to -86, e.g. 19.4326,-99.1332 for Mexico City)."}{"status": "error", "fetchedAt": "2026-09-19T04:36:25Z", "error": "\"fuelType\" must be one of: \"any\", \"regular\", \"premium\", \"diesel\"."}
Output fields
| Field | Meaning |
|---|---|
status | ok, not_found or error |
rowType | station (one gas station) or summary (area statistics, only with includeSummary) |
placeId | Station ID in the CNE feed (stable, use it to track a station over time) |
permitNumber | The station's CNE/CRE retail permit number (permiso de expendio, e.g. PL/8939/EXP/ES/2015) |
name | Permit holder's name — only for companies and organizations, otherwise null (see Privacy) |
holderType | company (name contains a legal form such as S.A. de C.V.) or individual_redacted (name removed) |
latitude, longitude | Station coordinates |
distanceKm | Straight-line distance from your search point (km) |
regularPrice, premiumPrice, dieselPrice | Reported price per liter in MXN; null when the station does not report that fuel |
currency | Always MXN (Mexican pesos, VAT included, as posted at the pump) |
fetchedAt | When this Actor downloaded the feed (UTC). The feed has no per-price timestamp. |
source | Data source, license and changes (attribution) |
searchLatitude, searchLongitude, radiusKm, fuelType, stationCount | Summary / not_found rows: the search and how many stations matched |
regularMin … dieselAvg, regularStationCount … | Summary row: min / max / average price and number of stations with a price, per fuel |
error | On not_found / error rows: one sentence explaining what to change |
How much does it cost?
This Actor uses Pay per event pricing — you pay for results, not for compute time:
| Event | Price | When it is charged |
|---|---|---|
Result row (result-row) | $0.003 ($3 per 1,000 rows) | Each ok row: each station row, and the summary row when you ask for it |
| Actor start | $0.001 | Once per run |
not_found and error rows are free.
| Example | Rows | Cost |
|---|---|---|
| Default run (50 nearest stations in central Mexico City) | 50 | about $0.15 |
| Cheapest 5 diesel stations near a truck stop | 5 | about $0.016 |
| Daily competitor check: 30 stations around your station + summary, every day for a month | 31 × 30 | about $2.82 / month |
Area benchmark only (maxResults: 1 + summary) | 2 | about $0.007 |
- Keep
maxResultssmall when you only need the nearest or cheapest stations; the summary row already covers all stations in the radius. - Set the maximum cost per run when you start the Actor to cap spending. If the limit is reached, the Actor stops cleanly and says so in the status message.
Use via API / MCP (AI agents)
Apify API (HTTP). Run the Actor and get the rows in one call:
curl -X POST "https://api.apify.com/v2/acts/japan-open-data~mexico-fuel-station-prices/run-sync-get-dataset-items?token=<YOUR_APIFY_TOKEN>" \-H "Content-Type: application/json" \-d '{"latitude": 20.6597, "longitude": -103.3496, "radiusKm": 10, "fuelType": "diesel", "sortBy": "price", "maxResults": 10}'
Python (apify-client):
from apify_client import ApifyClientclient = ApifyClient("<YOUR_APIFY_TOKEN>")run = client.actor("japan-open-data/mexico-fuel-station-prices").call(run_input={"latitude": 25.6866, "longitude": -100.3161, # Monterrey"radiusKm": 8, "fuelType": "premium", "sortBy": "price", "maxResults": 20, "includeSummary": True,})for row in client.dataset(run["defaultDatasetId"]).iterate_items():print(row["status"], row.get("rowType"), row.get("permitNumber"), row.get("premiumPrice"), row.get("distanceKm"))
MCP (Claude, ChatGPT, Cursor and other AI agents). Add this Actor as a tool through the Apify MCP server (https://mcp.apify.com), for example with ?tools=japan-open-data/mexico-fuel-station-prices. An agent only needs {"latitude": <lat>, "longitude": <lon>}.
Recommended agent settings:
- "Cheapest diesel near X" →
{"latitude": .., "longitude": .., "radiusKm": 10, "fuelType": "diesel", "sortBy": "price", "maxResults": 5}. - "What do gas prices look like around X?" →
includeSummary: truewith a smallmaxResults(e.g. 5) — the summary row already has min / max / average. - Convert an address or city to coordinates first; the Actor does not geocode.
- Always check
status; onnot_found/errorshow theerrorsentence to the user.
FAQ
How fresh are the prices? The CNE updates the feed daily (around 18:00 Mexico City time). Every run downloads the current feed, so you always get the latest published prices; fetchedAt shows when.
Can I search by city, state or address? Not directly — the official feed only has coordinates. Use a city center from the list above, or geocode the address first.
Can I get the station brand (Pemex, Oxxo Gas, …) or street address? No. The feed has the permit holder and permit number, not the brand or address.
Is it legal to use this data commercially? Yes. The CNE publishes the data as open data under Creative Commons Attribution 4.0, which allows commercial use and adaptation with attribution. Each row's source field and the section below carry that attribution; keep it if you republish the data.
Why do some stations have no name? About 9% of permits belong to private persons. To avoid outputting personal names, only company and organization names are returned (see Privacy).
Known limitations
- Coordinates only. No address, state or city search (not in the official feed) and no geocoding.
- No station brand or address. The feed has the permit holder, not the brand or street address.
- Straight-line distance, not driving distance.
- Prices as reported. Prices are reported by the stations; the CNE does not guarantee them, and the pump price can differ. A few values are far from the local average and are returned as reported.
- Two diesel prices. A few stations report diesel twice (probably regular diesel and ultra-low-sulfur DUBA diesel); the first valid price in the feed is used.
- Mexico only. Points outside Mexico return a free
not_foundrow. - Cost limit. If your maximum cost per run is lower than the price of one row, the dataset stays empty and the status message explains why.
Data source and license
- Source: Comisión Nacional de Energía (CNE), Mexico — Precios de expendio de gasolinas y diésel (prices reported by permit holders under the regulator's agreement A/041/2018), public daily XML feeds linked from https://www.cne.gob.mx/ConsultaPrecios/GasolinasyDiesel/GasolinasyDiesel.html . The CNE's fuel price data is published as open data on datos.gob.mx (dataset "Petrolíferos", https://www.datos.gob.mx/dataset/petroliferos).
- License: Creative Commons Attribution 4.0 International (CC BY 4.0), https://creativecommons.org/licenses/by/4.0/ .
- Changes made by this Actor: the price and station feeds are joined by
place_id(stations present in only one feed are dropped), stations are filtered by distance and fuel, placeholder prices (below 5 or above 100 MXN, e.g.0.01) are returned asnull, names of permit holders who may be private persons are removed, and if a station reports the same fuel twice, the first valid price is used. Summary statistics are calculated by this Actor. - Not affiliated: this Actor is an independent project and is not affiliated with, endorsed by or sponsored by the CNE, the CRE or the Government of Mexico.
- Access: one run downloads the two public feeds once (about 6 MB in total) and identifies itself in the User-Agent.
Privacy
About 9% of stations are held by private persons (individual permit holders). To avoid outputting personal names, name is only returned when it contains a company or organization legal form (S.A. de C.V., S.A., S. de R.L., S.A.P.I., S.A.B., S.C., S.P.R. de R.L., cooperatives, "sin tipo de sociedad" public bodies, …; case, dot and spacing variants included). All other stations get name: null and holderType: "individual_redacted" — this may also hide a few organizations whose registered name has no legal form. Permit number, coordinates and prices describe the business location and are always returned.
More from Japan Open Data
- US Hail History by Location (NOAA NEXRAD Radar) — every hail day near any U.S. latitude/longitude with max estimated hail size, from NOAA NEXRAD radar.
- TSA Checkpoint Travel Numbers (Daily, Weekly & YoY) — daily U.S. TSA airport checkpoint traveler counts as clean JSON, with weekly averages and year-over-year change.
- Japan Postal Code & Address in English — look up Japanese postal codes and addresses in English/romaji, kanji and kana, from Japan Post's official data.
- US Storm Reports API: Hail, Wind & Tornado (NWS) — U.S. hail, wind, tornado and flood reports from official NWS Local Storm Reports within hours (last 7 days), filterable by state or radius.
Feedback
Found a wrong value or need another field (e.g. brand, state, route search)? Open an issue on the Actor's Issues tab with your input and what you expected.