Ir al contenido

Histórico diario de un territorio

GET
/v1/history
curl --request GET \
--url 'https://api.preciosgasolina.es/v1/history?level=spain&fuel=gasoline_95&days=30'

Media, mínimo y máximo de cada día (hasta 90 días) de un carburante en España o en un territorio, con la variación del periodo.

Herramienta MCP equivalente: get_price_history.

Límite: 120 peticiones/min por IP. Caché: hasta la próxima actualización de los datos (≈ 8:00 y 20:00, hora peninsular).

level
string
Valores permitidos: spain community province municipality

Nivel territorial. community y province usan el código INE (p. ej. 13, 28); municipality, el id de municipio de /v1/territories o /v1/search.

code
string
>= 1 caracteres <= 60 caracteres /^[a-z0-9-]+$/

Código del territorio (INE para comunidad y provincia, id para municipio) o su slug.

fuel
string
por defecto: gasoline_95
Valores permitidos: gasoline_95 gasoline_98 diesel diesel_premium lpg cng

Carburante: gasoline_95, gasoline_98, diesel, diesel_premium, lpg, cng.

days
integer
por defecto: 30 >= 1 <= 90

Días de histórico (1–90).

Correcto: sobre { data, meta }.

Tipo de contenidoapplication/json
object
data
obligatorio
object
key
propiedades adicionales
any
meta
obligatorio
object
api_version
obligatorio
string
request_id
obligatorio
string
last_updated
obligatorio

Fecha y hora de los datos (ISO 8601).

string | null
next_update
obligatorio

Próxima actualización prevista (≈ 8:00 y 20:00, hora peninsular).

string
data_age_seconds
obligatorio
Cualquiera de:
integer
>= -9007199254740991 <= 9007199254740991
stale
obligatorio

True si la fuente no respondió y se sirve la última copia buena.

boolean
source
obligatorio
string
attribution
obligatorio

Texto que debes mostrar junto a los datos (CC BY 4.0).

string
license
obligatorio
string formato: uri
web_url
obligatorio
Cualquiera de:
string formato: uri
Ejemplogenerated
{
"data": {},
"meta": {
"api_version": "example",
"request_id": "example",
"last_updated": "example",
"next_update": "example",
"data_age_seconds": 1,
"stale": true,
"source": "example",
"attribution": "example",
"license": "https://example.com",
"web_url": "https://example.com"
}
}
RateLimit-Policy
string

Política de límites aplicada (borrador IETF).

X-Request-Id
string

Identificador de la petición.

X-Cache
string

Hit, miss o stale.

Parámetros no válidos (INVALID_PARAMETER) o desconocidos.

Tipo de contenidoapplication/problem+json
object
type
obligatorio
string formato: uri
title
obligatorio
string
status
obligatorio
integer
>= -9007199254740991 <= 9007199254740991
detail
obligatorio
string
code
obligatorio

Código estable del error (p. ej. STATION_NOT_FOUND, RATE_LIMITED).

string
request_id
obligatorio
string
instance
string
Ejemplogenerated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"code": "example",
"request_id": "example",
"instance": "example"
}

No encontrado (STATION_NOT_FOUND, PROVINCE_NOT_FOUND…).

Tipo de contenidoapplication/problem+json
object
type
obligatorio
string formato: uri
title
obligatorio
string
status
obligatorio
integer
>= -9007199254740991 <= 9007199254740991
detail
obligatorio
string
code
obligatorio

Código estable del error (p. ej. STATION_NOT_FOUND, RATE_LIMITED).

string
request_id
obligatorio
string
instance
string
Ejemplogenerated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"code": "example",
"request_id": "example",
"instance": "example"
}

Demasiadas peticiones (RATE_LIMITED). Reintenta tras Retry-After.

Tipo de contenidoapplication/problem+json
object
type
obligatorio
string formato: uri
title
obligatorio
string
status
obligatorio
integer
>= -9007199254740991 <= 9007199254740991
detail
obligatorio
string
code
obligatorio

Código estable del error (p. ej. STATION_NOT_FOUND, RATE_LIMITED).

string
request_id
obligatorio
string
instance
string
Ejemplogenerated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"code": "example",
"request_id": "example",
"instance": "example"
}
Retry-After
integer

No disponible temporalmente (TEMPORARILY_UNAVAILABLE). Reintenta tras Retry-After.

Tipo de contenidoapplication/problem+json
object
type
obligatorio
string formato: uri
title
obligatorio
string
status
obligatorio
integer
>= -9007199254740991 <= 9007199254740991
detail
obligatorio
string
code
obligatorio

Código estable del error (p. ej. STATION_NOT_FOUND, RATE_LIMITED).

string
request_id
obligatorio
string
instance
string
Ejemplogenerated
{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"code": "example",
"request_id": "example",
"instance": "example"
}
Retry-After
integer

Fuente de los datos: Ministerio para la Transición Ecológica y el Reto Demográfico (Geoportal de Gasolineras). Datos de la API y del servidor MCP con licencia CC BY 4.0: cita Gasolina hoy y la fuente.