Discover/Gob API
live

Gob APIcne.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.

Endpoint health
verified 3d ago
get_municipalities
get_fuel_prices
get_all_fuel_prices
get_states
4/4 passing latest checkself-healing
Endpoints
4
Updated
26d ago

What is the Gob 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.

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.
Call it over HTTPgrab 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'
Python SDK · recommended

Typed, relational, agent-ready

A generated client with real types, enums, and the links between objects — the structure a flat JSON response can't carry. Autocompletes in your editor and reads cleanly to coding agents.

  • Fully typed · autocompletes
  • Objects link to objects
  • Typed errors & pagination

Typed Python client. Set up the SDK in your uv project, then pull this API’s typed client:

uv add parse-sdk
uv run parse init
uv run parse add --marketplace cne-gob-mx-api

uv run parse add --marketplace pulls a pinned snapshot of this canonical API — it won’t change underneath you. To customize it, subscribe and swap to your own copy.

"""Walkthrough: CNE Mexico Fuel Prices — browse states, drill into municipalities, compare prices."""
from parse_apis.cne_mexico_fuel_prices_api import CneMexicoFuelPrices, EntidadId, NotFoundError

client = CneMexicoFuelPrices()

# List all states — limit caps total items fetched.
for state in client.states.list(limit=5):
    print(state.entidad_federativa_id, state.nombre)

# Drill into a specific state using the EntidadId enum.
aguascalientes = client.state(entidad_federativa_id=EntidadId._01)

# List municipalities in that state.
for muni in aguascalientes.municipalities.list(limit=3):
    print(muni.municipio_id, muni.nombre)

# Take one municipality and get its fuel prices.
first_muni = aguascalientes.municipalities.list(limit=1).first()
if first_muni:
    for price in first_muni.fuel_prices(limit=5):
        print(price.numero, price.producto, price.precio_vigente)

# Get all fuel prices across the entire state (aggregates all municipalities).
try:
    for station in aguascalientes.fuel_prices.list(limit=3):
        print(station.direccion, station.producto, station.precio_vigente)
except NotFoundError as exc:
    print(f"State not found: {exc}")

print("exercised: states.list / state() / municipalities.list / fuel_prices / fuel_prices.list")
All endpoints · 4 totalmissing one? ·

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": "Baja California",
          "entidad_federativa_id": "02"
        }
      ]
    },
    "status": "success"
  }
}

About the Gob API

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.

Reliability & maintenanceVerified

The Gob API is a managed, monitored endpoint for cne.gob.mx — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when cne.gob.mx changes and a check fails, the API is automatically queued for repair and re-verified. It is built to keep working as the site underneath it changes.

This isn't an official cne.gob.mx API — it's an independent, maintained REST wrapper over public data. Where the source has no official API (or only a limited one), Parse gives you a stable contract over a source that never promised one, and keeps it current. Need a new endpoint or field? You can revise it yourself in plain English and the agent rebuilds it against the live site in minutes — contributing the change back to the shared API is free.

Last verified
3d ago
Latest check
4/4 endpoints passing
Maintenance
Monitored & self-healing
Will this API break when the source site changes?+
It's built not to. Every endpoint is health-checked on a schedule with automated test probes. When the source site changes and a check fails, the API is automatically queued for repair and re-verified — that's the self-healing layer. Each API page shows when its endpoints were last verified. And because marketplace APIs are shared, any fix reaches everyone using it.
Is this an official API from the source site?+
No — Parse APIs are independent, managed REST wrappers over publicly available data. That is the point: where a site has no official API (or only a limited one), Parse gives you a maintained, monitored endpoint for that data and keeps it working as the site changes — so you get a stable contract over a source that never promised one.
Can I fix or extend this API myself if I need a new endpoint or field?+
Yes — and you don't have to wait on us. This API was generated by the Parse agent, which stays attached. Describe the change in plain English ("add an endpoint that returns reviews", "fix the price field") in the revise box on the API page or via the revise_api MCP tool, and the agent rebuilds it against the live site in minutes. Contributing the change back to the public API is free.
What happens if I call an endpoint that has an issue?+
Errors are machine-readable: a bad call returns a clean status with the list of available endpoints and a repair hint, so an agent (or you) can recover or trigger a fix instead of failing silently. Confirmed failures feed the automatic repair queue.
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,000100 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 cne.gob.mx.
Related APIs in Government PublicSee all →
gasprices.aaa.com API
Access national, state, and metro-level gas prices from AAA in real time. Compare fuel costs across regions, view historical price trends, check EV charging rates, and browse the latest AAA fuel market news.
ocu.org API
Find real-time gas prices and locations at stations across Spain by searching your address or postal code, with filtering options by fuel type, brand, and distance radius. Compare prices per liter, calculate total tank costs, and get detailed station information including coordinates and price ratings to find the best deals near you.
fuelradar.com.au API
Search for fuel stations across Australia and compare current prices by fuel type and location. Retrieve detailed station information, view the cheapest stations nationally, and track price trends and state-by-state comparisons.
petrolspy.com.au API
Find the cheapest fuel prices across Australian petrol stations in real-time by searching your area, comparing prices by fuel type, and viewing detailed station information. Quickly locate the best deals near you by specifying your geographic region and fuel preferences.
fuelwatch.gov.sg API
Find fuel prices across Western Australia by searching stations by suburb, comparing daily and monthly price trends, and viewing detailed station information. Track fuel price movements across different regions and fuel types to identify the cheapest options nearby.
metro.sk API
Check current fuel prices at Metro Cash & Carry gas stations throughout Slovakia and locate available stores in your area. Get real-time pricing information to find the best deals at participating Metro locations.
airnav.com API
Find current aviation fuel prices at any US airport, including pricing for 100LL, Jet A, UL94, SAF, and Mogas from Fixed Base Operators along with their service type and contact details. Compare fuel availability and costs across multiple FBOs at your destination airport to plan your flight operations.
amazon.com.mx API
Search and discover products on Amazon Mexico with real-time pricing, detailed product information, offers, and bestseller lists. Compare prices instantly, get search suggestions, and find current deals to help you make informed shopping decisions.