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 Coverage


Documentation: https://m4rc0sx.github.io/esiosapy/


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.

Features

  • Simple API: Easy-to-use client for accessing ESIOS data
  • Sync & Async: Both synchronous and asynchronous clients
  • Type Hints: Full type annotations with strict mypy support
  • Retry Logic: Automatic retry with exponential backoff for network errors
  • CLI: Command-line interface for quick data exploration
  • Logging: Built-in logging for debugging
  • Configurable Timeouts: Customizable request timeouts

Installation

esiosapy is available on PyPI and supports Python >=3.10:

pip install esiosapy

Optional dependencies

# Async support (httpx)
pip install esiosapy[async]

# HTML description prettifying (beautifulsoup4)
pip install esiosapy[beautifulsoup]

# All optional dependencies
pip install esiosapy[all]

Quick start

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

Indicators

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

client = ESIOSAPYClient(token="your_esios_api_token")

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

# Search indicators by name
solar = client.indicators.search("solar")

# Get data for an indicator
indicator = indicators[0]
data = indicator.get_data("2021-01-01", "2021-01-02", time_trunc=TimeTrunc.HOUR)

Archives

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

client = ESIOSAPYClient(token="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,
)

# Download, unzip, and clean up
archives[0].download_file(unzip=True, remove_zip=True)

Async usage

import asyncio
from esiosapy import AsyncESIOSAPYClient

async def main():
    async with AsyncESIOSAPYClient(token="your_esios_api_token") as client:
        indicators = await client.indicators.list_all()

asyncio.run(main())

Context manager

Both sync and async clients support context managers for automatic resource cleanup:

with ESIOSAPYClient(token="your_esios_api_token") as client:
    indicators = client.indicators.list_all()

CLI

# List all indicators
esiosapy --token YOUR_TOKEN indicators

# List all archives
esiosapy --token YOUR_TOKEN archives

# Set custom timeout
esiosapy --token YOUR_TOKEN --timeout 60 indicators

Dependencies

esiosapy depends on Pydantic, requests, and tenacity.

Contributing

All contributions are welcome! Please read the contributing guide for details on how to get started.

License

This project is licensed under the GPL-3.0-or-later license. See the LICENSE file for details.

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-3.0.2.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

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

esiosapy-3.0.2-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: esiosapy-3.0.2.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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-3.0.2.tar.gz
Algorithm Hash digest
SHA256 6cdb2386a72c7b2169749b2120d73f643b492e416c2fea152d6121f6ab60a5fd
MD5 1d25e56353ca09a71823d8261118fba9
BLAKE2b-256 51d70e5dadac85e3113cdc5f51106e1bd8c34e834ebe672e81018d7ff78a4946

See more details on using hashes here.

File details

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

File metadata

  • Download URL: esiosapy-3.0.2-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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-3.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e8dc7764cdf39dc0099a384c4c5aabec607daa45b00e5a3e444575d5eee16b8
MD5 99b398052a43c6dce7b39233623a499e
BLAKE2b-256 82530e0b7c45e95bf4b056808ee02d167627cb8c522c54f322911aeb0e8e84c8

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