Access to API of esios (REE) Spanish Electrical Network

19 visualizaciones (últimos 30 días)
Pablo Diaz
Pablo Diaz el 24 de Mzo. de 2022
Respondida: Chetan el 5 de En. de 2024
I am trying to work with electrical data from the Spanish Electricity Network. They have an API (https://api.esios.ree.es/) with a token, but even I have the token I can not enter. Debugging errors in my script. I do not know how to pass the parameters the API requires ...I guess I have to use webread or webwrite, but how?
I have found some examples about how to proceed in Python and R but not in Matlab and I can´t translate them from one to another.
Thanks a lot
Pablo
  2 comentarios
Andrea Zarbano
Andrea Zarbano el 9 de En. de 2023
Hello Pablo,
same here, have you found a solution?
thanks
Jesús López
Jesús López el 14 de En. de 2023
Hi there, I am Jesús and I am a trainer and consultant of Python in topics related to Data, Statistics and Artificial Intelligence. I have been training at energy companies (COGEN, IGNIS and INVESYDE) to teach them Python and how to use the ESIOS API.
Now I have created the lessons in a step by step tutorial to download any type of data from ESIOS API, you may take a look here: https://resolvingpython.podia.com/simulacion-dashboard-red-electrica-con-esios-api-en-python

Iniciar sesión para comentar.

Respuestas (1)

Chetan
Chetan el 5 de En. de 2024
I Understand that you are trying to incorporate your token and additional parameters into a `webread` call. You're on the right track with using `webread` and `weboptions` to craft the necessary headers for your HTTP request. Since the token is already in the possession, it must be included in the HTTP header for authentication purposes during the API request.
Here's a straightforward example illustrating how to configure the headers and employ `webread` for API interaction:
% Your API token
token = 'YOUR_API_TOKEN_HERE';
% Desired API endpoint
apiURL = 'https://api.esios.ree.es/some_endpoint';
% HTTP header configuration with any type of configration Bearer or other
options = weboptions('HeaderFields', {'Authorization', ['Token token="' token '"']});
% API request execution
data = webread(apiURL, options);
% Output the retrieved data
disp(data);
The `weboptions` function is utilized here to tailor the `webread` function's options, particularly the HTTP headers. We are setting the `Authorization` header with the token as mandated by the ESIOS API's format.
To include extra parameters in your request, simply append them to the `webread` call like this:
% Extra parameters
params = {'param1', 'value1', 'param2', 'value2'};
% API request with added parameters
data = webread(apiURL, params, options);
Make sure to replace `'param1'`, `'value1'`, `'param2'`, and `'value2'` with the actual names and values of the parameters specified by the API.
For additional information, MATLAB's documentation on web services might be useful:
Hope it helps
Kind regards,
Chetan Verma

Categorías

Más información sobre Call Python from MATLAB en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by