# Spain Fuel Prices – Every Gas Station, Official Data (`shikimokami/spain-fuel-prices`) Actor

Official prices of gasoline, diesel, LPG, CNG, hydrogen and more at all ~11,500 gas stations in Spain, live or for any past day. Filter by province, town, postal code, brand, fuel or distance and get the cheapest stations first. Straight from Spanish Government open data.

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

## Pricing

from $0.30 / 1,000 stations

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

## Spain Fuel Prices – Every Gas Station, Official Data ⛽

Get the **official, up-to-date prices of every gas station in Spain** (about 12,000 stations) in seconds: gasoline 95 and 98, diesel, premium diesel, LPG/autogas, CNG, LNG, hydrogen, AdBlue and more. The data comes straight from the Spanish Government's fuel price service (Ministerio para la Transición Ecológica, *Geoportal de Hidrocarburos*), which stations are legally required to keep updated.

No scraping of fragile websites, no proxies, no CAPTCHAs: just clean, structured data you can filter, sort and download as JSON, CSV or Excel.

### What can you do with it?

- 🔎 **Find the cheapest stations** in a province, town or postal code, or around any point (e.g. the 10 cheapest diesel stations within 5 km).
- 🚚 **Fleet and logistics cost control**: plan refuelling stops and check what your drivers pay.
- 📊 **Market and competitor monitoring**: track a brand's prices against the competition, every day.
- 📈 **Historical analysis**: get the official closing prices of any past day.
- 🗺️ **Maps and apps**: every station comes with coordinates, address, brand and opening hours.

### Input

All filters are optional. With no input you get every station in Spain.

| Field | What it does |
|---|---|
| **Provinces** | One or more provinces (e.g. Madrid, Barcelona, Málaga). |
| **Municipality or town** | Text contained in the municipality or town name (accents ignored). |
| **Postal codes** | One or more postal codes or prefixes, e.g. `28001, 28002` or `080`. |
| **Brand** | e.g. `Repsol`, `Ballenoil`, `Plenoil`, `Costco`, or `Unbranded`. |
| **Fuel types** | Only stations selling at least one of these fuels. |
| **Latitude / Longitude / Radius** | Adds the distance to each station and keeps only the ones within the radius. |
| **Sort by** | Cheapest first (by the first selected fuel) or nearest first. |
| **Maximum results** | e.g. `10` with *Cheapest first* gives the 10 cheapest stations. |
| **Historical date** | Official closing prices of a past day (YYYY-MM-DD). |

#### Example: the 10 cheapest diesel stations within 5 km of Puerta del Sol (Madrid)

```json
{
  "fuelTypes": ["dieselA"],
  "latitude": "40.4168",
  "longitude": "-3.7038",
  "radiusKm": 5,
  "sortBy": "price",
  "maxResults": 10
}
```

### Output

One record per station. Prices are in **euros per litre** (per kg for hydrogen and gas). Only the fuels the station actually sells are included, and `fuels` lists them.

```json
{
  "stationId": "16519",
  "name": "Plenergy",
  "brand": "Plenergy",
  "address": "Calle Genal, 20",
  "postalCode": "29400",
  "locality": "Ronda",
  "municipality": "Ronda",
  "municipalityId": "4537",
  "province": "Málaga",
  "provinceCode": "29",
  "region": "Andalucía",
  "regionCode": "01",
  "latitude": 36.752667,
  "longitude": -5.15625,
  "openingHours": "L-D: 24H",
  "open24h": true,
  "saleType": "public",
  "fuels": [
    "gasoline95E5",
    "dieselA"
  ],
  "gasoline95E5": 1.629,
  "dieselA": 1.729,
  "pricesDate": "2026-10-14",
  "pricesTime": "18:00",
  "distanceKm": 65.58,
  "source": "Ministerio para la Transición Ecológica (Geoportal de Hidrocarburos)",
  "sourceUrl": "https://geoportalgasolineras.es/"
}
```

Price fields: `gasoline95E5`, `gasoline95E10`, `gasoline95E5Premium`, `gasoline95E25`, `gasoline95E85`, `gasoline98E5`, `gasoline98E10`, `renewableGasoline`, `dieselA`, `dieselPremium`, `dieselB` (agricultural), `renewableDiesel` (HVO), `biodiesel`, `bioethanol`, `lpg`, `cng`, `lng`, `bioCng`, `bioLng`, `hydrogen`, `adblue`, `ammonia`, `methanol`.

Every run also saves a free **SUMMARY** record in the key-value store with the number of stations, the average, minimum and maximum price of each fuel and the cheapest station for each one.

### Pricing

You only pay for the stations you get (pay per result). A whole province usually costs a few cents; all of Spain costs a few dollars. Use the filters and *Maximum results* to get exactly what you need.

### How fresh is the data?

Stations must report every price change, and the official service is refreshed every 30 minutes. Each record includes the date and time of the official update (`pricesDate`, `pricesTime`). Historical runs return the official closing prices of the chosen day.

### FAQ

**Is this legal?** Yes. The data is published by the Spanish Government as open data and may be reused, citing the source. Each record includes the source.

**Can I schedule it?** Yes. Use Apify schedules to run it every day (or every hour) and send the results to Google Sheets, a webhook, your database or any of Apify's integrations.

**Why are some stations missing?** By default only stations open to the public are returned. Turn on *Include restricted-sale stations* to also get stations that only sell to members or fleets.

### Made by

The team behind [CuántoGasta Gasolina](https://cuantogasta.github.io/gasolina/), a free website with the cheapest gas stations in every town in Spain.

# Actor input Schema

## `provinces` (type: `array`):

Only stations in these provinces. Leave empty for all of Spain (about 12,000 stations).

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

Only stations whose municipality or town contains this text (accents and case are ignored), e.g. «Málaga» or «Alcalá».

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

One or more postal codes or prefixes separated by commas, e.g. «28001, 28002» or «080» for all of Barcelona city.

## `brand` (type: `string`):

Only stations of this brand or sign, e.g. «Repsol», «Ballenoil», «Costco». «Unbranded» for independent stations.

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

Only stations that sell at least one of these fuels. The first one is used when sorting by price. Leave empty to include every station.

## `latitude` (type: `string`):

Your point, e.g. «40.4168». Adds the distance in km to every station and enables the radius filter.

## `longitude` (type: `string`):

Your point, e.g. «-3.7038».

## `radiusKm` (type: `integer`):

Only stations within this distance of the point above.

## `sortBy` (type: `string`):

Order of the results.

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

Stop after this many stations (0 = no limit). Combine with «Cheapest first» to get e.g. the 10 cheapest stations.

## `date` (type: `string`):

Get the official closing prices of a past day (YYYY-MM-DD). Leave empty for the current live prices.

## `includeRestrictedSale` (type: `boolean`):

Also include stations that only sell to members or fleets (not open to the public).

## Actor input object example

```json
{
  "provinces": [
    "28"
  ],
  "fuelTypes": [],
  "sortBy": "none",
  "maxResults": 0,
  "includeRestrictedSale": false
}
```

# Actor output Schema

## `stations` (type: `string`):

One record per gas station with its official prices.

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

Number of stations, average, minimum and maximum price of each fuel and the cheapest station for each one.

# 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 = {
    "provinces": [
        "28"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("shikimokami/spain-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 = { "provinces": ["28"] }

# Run the Actor and wait for it to finish
run = client.actor("shikimokami/spain-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 '{
  "provinces": [
    "28"
  ]
}' |
apify call shikimokami/spain-fuel-prices --silent --output-dataset

```

## MCP server setup

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