Access to API of esios (REE) Spanish Electrical Network

조회 수: 19 (최근 30일)
Pablo Diaz
Pablo Diaz 2022년 3월 24일
답변: Chetan 2024년 1월 5일
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
Andrea Zarbano
Andrea Zarbano 2023년 1월 9일
Hello Pablo,
same here, have you found a solution?
thanks
Jesús López
Jesús López 2023년 1월 14일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Chetan
Chetan 2024년 1월 5일
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

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by