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.
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
Built Distribution
File details
Details for the file esiosapy-1.0.4.tar.gz
.
File metadata
- Download URL: esiosapy-1.0.4.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.18 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31576d3dda7f5d885c85f1577b44cb9f5d5b9ff393fcdb0eef8210957a1d494f |
|
MD5 | fcdb175d32afa3a28dd232f720025adc |
|
BLAKE2b-256 | b0cf1d5976e8b38cf2d80c04b2c2cd7428e940cf8581e663575b3fa029489b3d |
File details
Details for the file esiosapy-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: esiosapy-1.0.4-py3-none-any.whl
- Upload date:
- Size: 30.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.8.18 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d3a1fb6feb1f8950539c7990858e71f0a949b6dd268ee48b28410dcb6f5a02d |
|
MD5 | dad3f740003a4c3af4a00f6e0cbf1d88 |
|
BLAKE2b-256 | d362135e17cb9b227b94fa8403ec1cb08716a9d0aa5add5ea6ffce3fb874b649 |