Skip to main content

Indicator

Represents ESIOS indicator metadata.
id
int
required
Unique identifier for the indicator
name
str
required
Full name of the indicator
short_name
str
default:""
Short name or abbreviation for the indicator
description
str
default:""
Detailed description of what the indicator measures
raw
dict[str, Any]
default:"{}"
Raw API response data (excluded from serialization)

Methods

from_api

@classmethod
def from_api(cls, data: dict[str, Any]) -> Indicator
Builds an Indicator instance from raw API JSON response. Parameters:
  • data (dict): The raw indicator object from the ESIOS API response
Returns:
  • Indicator: Parsed indicator instance
Example:
from esios.models.indicator import Indicator

api_data = {
    "id": 1001,
    "name": "PVPC 2.0 TD",
    "short_name": "PVPC",
    "description": "Precio voluntario para el pequeño consumidor 2.0 TD"
}

indicator = Indicator.from_api(api_data)
print(indicator.id)  # 1001
print(indicator.name)  # "PVPC 2.0 TD"

IndicatorValue

Represents a single data point from an indicator time series.
value
float
required
The numeric value of the data point
datetime
datetime
required
Timestamp of the data point in local time
datetime_utc
datetime | None
default:"None"
Timestamp of the data point in UTC
tz_time
str | None
default:"None"
Timezone identifier for the data point
geo_id
int | None
default:"None"
Geographic identifier for the data point
geo_name
str | None
default:"None"
Geographic name/region for the data point
Example:
from datetime import datetime
from esios.models.indicator import IndicatorValue

value = IndicatorValue(
    value=0.12345,
    datetime=datetime(2024, 1, 15, 10, 0),
    datetime_utc=datetime(2024, 1, 15, 9, 0),
    tz_time="Europe/Madrid",
    geo_id=3,
    geo_name="Peninsula"
)

print(f"Price: {value.value} at {value.datetime}")

Build docs developers (and LLMs) love