Skip to main content

Unofficial ESIOS API Python library. Up to date and fully equipped.

Project description

esiosapy

Unofficial ESIOS API Python library. Up to date and fully equipped.

Test Release Package version Supported Python versions


from esiosapy.client import ESIOSAPYClient
from esiosapy.models.indicator.time_trunc import TimeTrunc

client = ESIOSAPYClient(
    token="your_token"
)

indicators = client.indicators.list_all()
indicator = indicators[0]

data = indicator.get_data("2021-01-01", "2021-01-02", time_trunc=TimeTrunc.HOUR)

esiosapy allows you to communicate with the ESIOS/REE API in a comfortable and abstract way, so that everything is handled by objects and you will not need to write any raw request.

Installing esiosapy

esiosapy is available on PyPi and it supports Python >=3.8:

pip install esiosapy

User guide

There will be a more detailed in the future.

You need a personal token in order to use the ESIOS API. You can request it in https://api.esios.ree.es/

Archives

from esiosapy.client import ESIOSAPYClient
from esiosapy.models.archive.archive_date_type import ArchiveDateType


# Init client
client = ESIOSAPYClient(
    "your_esios_api_token"
)

# Search files by date range
archives = client.archives.list_by_date_range(
    "2021-01-01T00:00:00.000+01:00",
    "2021-01-02T00:00:00.000+01:00",
    date_type=ArchiveDateType.PUBLICATION,
)

# Get first file. here you should filter with your needed criteria
x = archives[0]

# Download file in current path, unzip and remove zip
x.download_file(unzip=True, remove_zip=True)

To elaborate your filtering criteria, you can check out the attributes of the Archive model.

Indicators

from esiosapy.client import ESIOSAPYClient
from esiosapy.models.indicator.time_trunc import TimeTrunc

# Init client
client = ESIOSAPYClient(
    token="you_esios_api_token"
)

# Get all indicators
indicators = client.indicators.list_all()

# Get first file. here you should filter with your needed criteria
# Usually, you are looking for a specific indicator
indicator = indicators[0]

# Get data between 2 dates, with time_trunc of 1 hour
data = indicator.get_data("2021-01-01", "2021-01-02", time_trunc=TimeTrunc.HOUR)

To elaborate your filtering criteria, you can check out the attributes of the Indicator model.

TO-DO List

  • Archive model handling.
  • Indicator model handling.
  • OfferIndicator model handling.
  • Add docstrings to the entire project.
  • Archive JSON model handling.
  • Auction model handling.
  • Generate wiki with/and more elaborated docs.
  • Add more unit tests.
  • Support date range slicing to avoid long requests/responses.

Dependencies

esiosapy depends on Pydantic and requests.

Contributing

All contributions are welcome via direct contact with me or pull requests, as long as they are well elaborated and follow the conventional commits format.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

esiosapy-2.2.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

esiosapy-2.2.1-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file esiosapy-2.2.1.tar.gz.

File metadata

  • Download URL: esiosapy-2.2.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for esiosapy-2.2.1.tar.gz
Algorithm Hash digest
SHA256 9e7a0440f3578427cfeb1745c02254f1938d7a68f7ccbeec2b6cdf56d3233d3b
MD5 8a506aec5e58b3e9d9d065b2af40f254
BLAKE2b-256 a7513475c38d7c345663893067f82bd6e2514acb21f87ecf52e651929ec90298

See more details on using hashes here.

File details

Details for the file esiosapy-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: esiosapy-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 32.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for esiosapy-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 71fe21eb7a28658dae191c6ca2b15f6acd0c1030ac64810805bde1655bd40bd6
MD5 99f62b80210c8f1dd089ac12b8549db9
BLAKE2b-256 0140c0e25b4481b74dbbb394c3adb8fdbc7b10d670cbe39194504a2e77cd5665

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page