# Spain Fuel Prices - Cheapest Petrol Stations (MITECO data) (`hydramill/fuel-prices`) Actor

Live prices of every Spanish petrol station from the Ministry's open data, filtered by province, municipality, postal code or radius, sorted by cheapest or nearest. Clean numbers, area average and saving per station.

- **URL**: https://apify.com/hydramill/fuel-prices.md
- **Developed by:** [Hydramill](https://apify.com/hydramill) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 90.9% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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

## Spain Fuel Prices - cheapest petrol stations, official data

Live prices of **every petrol station in Spain** (about 11,500) from the Spanish Ministry's open data service, filtered the way drivers and fleets actually search: by **province, municipality, postal code or a radius around a point**, for the **fuels you choose**, sorted **cheapest** or **nearest** first.

Each station comes back as one clean row: real numbers (no `"1,859"` strings), coordinates, distance, opening hours, the price of your fuel, the **area average** and **how much you save** compared to it.

> Resum en català i resumen en español [al final](#català).

### Why this actor

- **Official source, no scraping.** It reads the Ministry's public REST service (the data behind *Geoportal Gasolineras*), which every station must report to by law. No blocking, no proxies, no CAPTCHA.
- **Fast and cheap to run.** It downloads only the narrowest file the Ministry offers for your area: one municipality is a few KB, a province ~1 MB. All of Spain (~12 MB) only when you ask for it.
- **Clean numeric output.** Prices are numbers in € per unit, `null` when a station doesn't sell that fuel, with the unit (`EUR/l`, or `EUR/kg` for CNG/LNG/hydrogen) next to them.
- **Typo-proof "cheapest".** Stations sometimes publish typos such as 0.019 €/l. Those are ignored (band 0.30-4.00 €/l), so they never show up as the cheapest station.
- **Context per row.** `areaAveragePrice` and `savingVsAverage` tell you whether a price is actually good for the area you searched.
- **Forgiving input.** `Barcelona`, `08`, `València`, `Valencia`, `A Coruña`, `La Coruña`, `L'Hospitalet de Llobregat`, `Hospitalet de Llobregat (L')` all work. Postal codes work as exact codes (`08005`) or prefixes (`080`).
- **Docs in English, Catalan and Spanish.**

#### How it compares (Apify Store, checked 2026-10-31)

Several Store actors read the same Ministry service, e.g. *Spain Fuel Prices - Cheapest Petrol Stations* (`sn41lz/spain-fuel-prices`, ~$1 / 1,000 stations), *Spain Fuel Prices - Every Gas Station* (`shikimokami/spain-fuel-prices`, from $0.30 / 1,000), *Spain Fuel Prices - Live Gas Station Prices* (`tikitakaclaw/fuel-prices-es`, $0.20 / 1,000, province + price range filters), *Fuel Prices from Official Sources* (`gratifying_graph/fuel-prices-official`, multi-country, $1 / 1,000) and *Spain Fuel Station Prices - MINCOTUR* (`nexgensignal/es-fuel-station-price-records`). This one differs by: downloading only the narrowest endpoint (municipality / province inferred from the postal code), the typo filter on "cheapest", the per-row area average and saving, accent/article-insensitive names, and Catalan/Spanish documentation. It has no historical prices (current prices only) and no brand filter yet.

### Input

Every field is optional. The narrowest area wins: **municipality > province > postal code > all of Spain**.

| Field | Type | Example | Notes |
|---|---|---|---|
| `province` | string | `"Barcelona"` or `"08"` | Name (accents/case ignored, Castilian and regional names) or 2-digit INE code. |
| `municipality` | string | `"Abrera"` | Needs `province` or `postalCode` (names repeat across provinces). Digits = the Ministry's own municipality id (Barcelona = `881`, not the INE code). |
| `postalCode` | string | `"08005"` / `"080"` | 5 digits = exact, fewer = prefix. Its first two digits pick the province to download. |
| `latitude`, `longitude` | number | `41.387`, `2.17` | Search point. Adds `distanceKm` to every row. |
| `radiusKm` | number | `5` | Keep only stations within this distance of the point. |
| `fuelTypes` | string\[] | `["dieselA", "g95e5"]` | Stations selling at least one of them. The **first** one drives sorting and the `price` columns. Empty = every station, with every fuel it sells. |
| `sort` | `cheapest` | `nearest` | `"cheapest"` | Default: cheapest with a fuel type, else nearest with a point, else by station id. |
| `maxResults` | integer | `20` | Default 100, max 20,000. You pay only for the rows returned. |

Fuel codes: `g95e5` (Gasolina 95 E5), `g95e5Premium`, `g95e10`, `g95e25`, `g95e85`, `g98e5` (Gasolina 98 E5), `g98e10`, `gasolineRenewable`, `dieselA` (Gasóleo A, normal diesel), `dieselPremium`, `dieselB` (agricultural), `dieselRenewable`, `biodiesel`, `bioethanol`, `lpg` (GLP / autogas), `cng` (GNC), `lng` (GNL), `bioCng`, `bioLng`, `hydrogen`, `methanol`, `ammonia`, `adblue`. API callers may also send `diesel`, `gasolina95`, `95`, `98`, `glp`, `gnc`, `gnl`.

Example: the 20 cheapest diesel stations within 5 km of Plaça de Catalunya, Barcelona:

```json
{
  "province": "Barcelona",
  "fuelTypes": ["dieselA", "g95e5"],
  "latitude": 41.387,
  "longitude": 2.17,
  "radiusKm": 5,
  "sort": "cheapest",
  "maxResults": 20
}
```

More examples: `{ "postalCode": "08005", "fuelTypes": ["g95e5"] }` (one postal code), `{ "province": "Girona", "municipality": "Girona", "fuelTypes": ["lpg"] }` (autogas in a town), `{ "latitude": 40.4168, "longitude": -3.7038, "radiusKm": 3, "sort": "nearest" }` (nearest stations to Puerta del Sol, any fuel).

### Output

One dataset item per station (real run, Abrera, 2026-10-31):

```json
{
  "stationId": "15652",
  "brand": "BALTRAN S.A",
  "address": "AVENIDA ENERGIA, 9",
  "postalCode": "08630",
  "locality": "ABRERA",
  "municipality": "Abrera",
  "municipalityId": "861",
  "province": "BARCELONA",
  "provinceId": "08",
  "latitude": 41.509222,
  "longitude": 1.896833,
  "distanceKm": null,
  "fuelType": "dieselA",
  "price": 1.79,
  "unit": "EUR/l",
  "areaAveragePrice": 1.867,
  "savingVsAverage": 0.077,
  "prices": { "dieselA": 1.79, "g95e5": null },
  "schedule": "L-D: 24H",
  "open24h": true,
  "publicSale": true,
  "priceUpdatedAt": "2026-10-31T14:00:00+01:00",
  "source": "Ministerio para la Transición Ecológica y el Reto Demográfico - Geoportal Gasolineras (precios de carburantes)"
}
```

| Field | Meaning |
|---|---|
| `price`, `unit` | Price of the first requested fuel, `null` if the station doesn't sell it. |
| `areaAveragePrice` | Average price of that fuel over **every** station that matched your filters (not only the rows returned). |
| `savingVsAverage` | `areaAveragePrice - price` in € per litre/kg. Positive = cheaper than the area. |
| `prices` | Requested fuels (or all fuels sold, when none requested) → € per unit. |
| `distanceKm` | From your point, `null` without a point. |
| `publicSale` | `false` = restricted to members/fleets. |
| `priceUpdatedAt` | When the Ministry published these prices (it republishes every 30 minutes). |

The Console shows two table views ("Cheapest stations" and "Location"); the full item is in the JSON / CSV / Excel export and the API.

### Use cases

- Fleet and delivery companies: cheapest diesel along a depot's area, scheduled every morning.
- Price comparison sites and apps: a ready, clean feed per municipality or postal code.
- Journalists and analysts: price gaps between towns, provinces or brands; regular snapshots for time series.
- Drivers and automations: "cheapest 95 near home" every evening to Slack, Telegram, Google Sheets (via Apify integrations).

### Pricing

Pay per event: you pay **per station returned** (event `station-result`) plus Apify's small start fee, never for stations that were filtered out. `maxResults` caps the cost of a run, and the actor stops cleanly when your maximum cost per run is reached. A typical "20 cheapest in my town" run costs a fraction of a cent. See the Pricing tab for the current price.

### Data source and licence

**Ministerio para la Transición Ecológica y el Reto Demográfico** (MITECO) - *Geoportal Gasolineras*, REST service "PreciosCarburantes": <https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/help>. Public-sector information reusable under Ley 37/2007 and Real Decreto 1495/2011, citing the source, without altering the data and showing the date of the last update. Every row carries `source` and `priceUpdatedAt` (the Ministry's last update) for that purpose. This actor is not affiliated with or endorsed by the Ministry.

### Limits

- Current prices only (no history). The Ministry republishes every 30 minutes; prices are what the stations reported, the actor can't detect a plausible but wrong price.
- A point/radius search without province, municipality or postal code downloads all of Spain (~12 MB). Add a province to make it faster.
- Mainland, Balearic and Canary stations are included; Ceuta and Melilla too. Restricted-sale stations are included and flagged with `publicSale: false`.
- If the Ministry's service is down or changes its format the run fails with a clear message instead of returning wrong data.

### Català

Preus en temps real de totes les benzineres d'Espanya, amb dades oficials del Ministeri per a la Transició Ecològica. Filtra per província, municipi, codi postal o radi al voltant d'un punt, tria els carburants (`dieselA` gasoil, `g95e5` benzina 95, `g98e5`, `lpg` GLP...) i ordena per més barata o més propera. Cada fila porta preus numèrics, coordenades, horari, la mitjana de la zona i l'estalvi respecte a ella. Pagues només per benzinera retornada.

### Español

Precios en tiempo real de todas las gasolineras de España, con datos oficiales del Ministerio para la Transición Ecológica y el Reto Demográfico. Filtra por provincia, municipio, código postal o radio alrededor de un punto, elige los carburantes (`dieselA` gasóleo A, `g95e5` gasolina 95, `g98e5`, `lpg` GLP...) y ordena por más barata o más cercana. Cada fila trae precios numéricos, coordenadas, horario, la media de la zona y el ahorro frente a ella. Pagas solo por gasolinera devuelta.

# Actor input Schema

## `province` (type: `string`):

Province name (Barcelona, València, A Coruña, Illes Balears...) or its 2-digit INE code (08, 46, 15...). Accents and case are ignored.

## `municipality` (type: `string`):

Municipality name, e.g. "L'Hospitalet de Llobregat" or "Hospitalet de Llobregat (L')". Needs Province or Postal code, since names repeat across provinces. Digits are taken as the Ministry municipality id (Barcelona = 881, not the INE code).

## `postalCode` (type: `string`):

5 digits = exact match (08005). Fewer digits = prefix (080 = Barcelona city, 08 = Barcelona province). The first two digits also pick the province to download.

## `latitude` (type: `number`):

WGS84 latitude of the search point, e.g. 41.387 (Plaça de Catalunya, Barcelona).

## `longitude` (type: `number`):

WGS84 longitude of the search point, e.g. 2.17.

## `radiusKm` (type: `number`):

Keep only stations within this distance of the point (needs latitude and longitude).

## `fuelTypes` (type: `array`):

Keep stations that sell at least one of these. The FIRST one drives price sorting and the price / unit / areaAveragePrice / savingVsAverage columns. Empty = every station, with every fuel it sells in prices.

## `sort` (type: `string`):

cheapest = by the price of the first fuel type (needs a fuel type). nearest = by distance to the point (needs latitude/longitude). Default: cheapest when a fuel type is given, else nearest when a point is given, else by station id.

## `maxResults` (type: `integer`):

Maximum stations returned (and charged). Area averages are still computed over every match.

## Actor input object example

```json
{
  "province": "Barcelona",
  "municipality": "Barcelona",
  "postalCode": "08005",
  "latitude": 41.387,
  "longitude": 2.17,
  "radiusKm": 5,
  "fuelTypes": [
    "dieselA",
    "g95e5"
  ],
  "sort": "cheapest",
  "maxResults": 20
}
```

# Actor output Schema

## `results` (type: `string`):

One item per station, cheapest or nearest first, with prices, area average and saving.

# 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 = {
    "province": "Barcelona",
    "municipality": "Barcelona",
    "fuelTypes": [
        "dieselA",
        "g95e5"
    ],
    "sort": "cheapest",
    "maxResults": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("hydramill/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 = {
    "province": "Barcelona",
    "municipality": "Barcelona",
    "fuelTypes": [
        "dieselA",
        "g95e5",
    ],
    "sort": "cheapest",
    "maxResults": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("hydramill/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 '{
  "province": "Barcelona",
  "municipality": "Barcelona",
  "fuelTypes": [
    "dieselA",
    "g95e5"
  ],
  "sort": "cheapest",
  "maxResults": 20
}' |
apify call hydramill/fuel-prices --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,hydramill/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/OHVczaulFwLhIhDn3/builds/2xcduGVtC4dNhHoYM/openapi.json
