Discover/cne.gob.mx API
live

cne.gob.mx APIwww.cne.gob.mx

Query current gasoline and diesel prices for all Mexican gas stations by state and municipality via the CNE cne.gob.mx API. Covers Regular, Premium, and Diesel.

Endpoints
4
Updated
14d ago
Try it

No input parameters required.

api.parse.bot/scraper/8412a138-d867-4a05-a6e1-019af32d5f4e/<endpoint>
Ready to send
Fill in the parameters and hit sign in to send to see live response data here.
Use it in your codegrab a free API key at signup
curl -X GET 'https://api.parse.bot/scraper/8412a138-d867-4a05-a6e1-019af32d5f4e/get_states' \
  -H 'X-API-Key: $PARSE_API_KEY'
All endpoints · 4 totalclick to expand

Get all 32 Mexican states (entidades federativas) with their IDs. Use these IDs to query municipalities and fuel prices.

Input

No input parameters required.

Response
{
  "type": "object",
  "fields": {
    "total": "integer — number of states returned",
    "states": "array of objects with entidad_federativa_id (zero-padded 2-digit string) and nombre (state name)"
  },
  "sample": {
    "data": {
      "total": 32,
      "states": [
        {
          "nombre": "Aguascalientes",
          "entidad_federativa_id": "01"
        },
        {
          "nombre": "Ciudad de México",
          "entidad_federativa_id": "09"
        }
      ]
    },
    "status": "success"
  }
}

About the cne.gob.mx API

The CNE Mexico Fuel Prices API exposes 4 endpoints that return current Regular gasoline, Premium gasoline, and Diesel prices for gas stations across all 32 Mexican states. Starting with get_states to retrieve state IDs, you can drill down to municipality-level station data or pull all prices for an entire state in a single call using get_all_fuel_prices. Each station record includes address, product type, sub-product, and the active price.

Endpoints and Data Coverage

The API is organized as a two-level geographic hierarchy: states (entidades federativas) and municipalities. get_states returns all 32 Mexican states with their zero-padded two-digit IDs and names — these IDs are required inputs for every downstream query. get_municipalities accepts an entidad_id and returns a list of municipality objects, each with an entidad_federativa_id, a zero-padded three-digit municipio_id, and the municipality name.

Station-Level Fuel Prices

get_fuel_prices takes both entidad_id and municipio_id and returns all station-product entries for that municipality. Each entry in the stations array carries a station number (numero), direccion (street address), producto, sub_producto, and precio_vigente (the current numeric price). The total field tells you how many entries were returned. The three fuel products covered are Regular gasoline, Premium gasoline, and Diesel, so a single physical station typically produces three entries.

State-Wide Price Queries

get_all_fuel_prices accepts a required entidad_id and iterates across every municipality in that state, returning a unified stations array and a total_stations count. Because it aggregates across all municipalities, response time can range from 10 to 30 seconds for states with many municipalities. An errors array will appear in the response only when one or more municipality requests fail, letting you identify any gaps in coverage without silently discarding data.

Common use cases
  • Build a fuel price comparison map for Mexican drivers, plotting precio_vigente by direccion for all stations in a municipality.
  • Track daily or weekly price changes for Regular and Premium gasoline across a state using get_all_fuel_prices with scheduled calls.
  • Identify the cheapest diesel corridor along a freight route by querying get_fuel_prices for municipalities along the path.
  • Feed a logistics cost calculator with live diesel prices from specific states to estimate transportation expenses.
  • Monitor regulatory compliance by flagging stations whose precio_vigente deviates significantly from the state average.
  • Populate a mobile app's 'nearest cheap fuel' feature using station addresses and current prices from get_fuel_prices.
  • Aggregate historical price data by state for economic research on fuel inflation in Mexico.
Pricing & limitsSee full pricing →
TierPriceCredits/monthRate limit
Free$0/mo1005 req/min
Hobby$30/mo1,00020 req/min
Developer$100/mo5,000250 req/min

One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.

Frequently asked questions
Does CNE (cne.gob.mx) have an official developer API?+
CNE does not publish a documented public developer API. The fuel price data is available through their public consultation page at cne.gob.mx/ConsultaPrecios/GasolinasyDiesel/GasolinasyDiesel.html, but there is no official API with authentication, versioning, or an SLA.
What does each entry in the `stations` array actually contain?+
Each object in stations represents one fuel product at one station. It includes numero (station identifier), direccion (address), producto (fuel category), sub_producto (fuel sub-type), precio_vigente (the active price as a number), and entidad_federativa_id as an integer. A single physical station will appear as multiple entries — one per fuel product carried.
Does the API include geographic coordinates (latitude/longitude) for each station?+
Not currently. Station records include direccion (a street address) but no latitude or longitude fields. You can fork this API on Parse and revise it to add a geocoding step that resolves addresses to coordinates.
How fresh are the fuel prices returned by the API?+
Prices reflect the current values published on the CNE public consultation page. CNE updates prices as stations report them, but there is no timestamp field on individual station records in the response, so you cannot determine the exact age of a specific price entry from the API output alone.
Can I filter `get_fuel_prices` results by a specific fuel type, such as only Diesel?+
The endpoint does not support server-side filtering by producto or sub_producto. The full set of station-product entries for the municipality is returned, and filtering by fuel type must be done client-side on the stations array. You can fork this API on Parse and revise it to expose a producto filter parameter.
Page content last updated . Spec covers 4 endpoints from www.cne.gob.mx.
Related APIs in Government PublicSee all →
athletic.net API
Search and analyze cross country and track & field performance data across the US, including athlete profiles, meet results, team rosters, and rankings. Access comprehensive meet information, historical records, and state-level competition data to track athlete progress and discover top performers.
alienvault.com API
Search and analyze global threat intelligence data including indicators of compromise, threat pulses, and adversary profiles from the Open Threat Exchange community. Monitor recent security alerts and access detailed information about threats and adversaries to strengthen your cybersecurity defenses.
eprocurement.gov API
Monitor India's public procurement opportunities by accessing active tenders, bids closing today, global tenders, high-value contracts, and cancelled tenders from the Central Public Procurement Portal. Search tender details, browse participating organizations, and track real-time procurement statistics to stay informed on government contracting opportunities.
maradminbot.com API
Search and retrieve official Marine Corps MARADMIN announcements from Marines.mil, filtering by year, status, and keyword to stay updated on the latest personnel and administrative directives. Get detailed information about specific announcements by number or browse the most recent updates to ensure you never miss critical Marine Corps guidance.
13f.info API
13f.info API
illinoisreportcard.com API
Search and analyze comprehensive performance data for Illinois public schools, districts, and the state, including academic achievements in ELA, math, and science, student demographics, teacher and administrator information, school finances, and environmental conditions. Compare schools side-by-side, track growth metrics, and access accountability ratings and school highlights to make informed decisions about education quality.
customs.gov.mv API
Check import/export duties, tariff classifications, and exchange rates for Maldives customs compliance, plus track vessel movements, company registrations, and declaration statuses. Get real-time data directly from the official customs portal to streamline your trade and logistics operations.
bizapedia.com API
Search for detailed business profiles and contact information from Bizapedia, including company details, employee data, and communication channels. Access comprehensive business intelligence to research companies and build targeted contact lists.