python-esios 0.1.2__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_esios-0.1.2 → python_esios-0.1.3}/PKG-INFO +1 -1
- python_esios-0.1.3/esios/api_client.py +22 -0
- {python_esios-0.1.2 → python_esios-0.1.3}/esios/endpoints/indicators/__init__.py +1 -1
- {python_esios-0.1.2 → python_esios-0.1.3}/python_esios.egg-info/PKG-INFO +1 -1
- {python_esios-0.1.2 → python_esios-0.1.3}/setup.py +1 -1
- python_esios-0.1.2/esios/api_client.py +0 -24
- {python_esios-0.1.2 → python_esios-0.1.3}/LICENSE +0 -0
- {python_esios-0.1.2 → python_esios-0.1.3}/README.md +0 -0
- {python_esios-0.1.2 → python_esios-0.1.3}/esios/__init__.py +0 -0
- {python_esios-0.1.2 → python_esios-0.1.3}/esios/endpoints/__init__.py +0 -0
- {python_esios-0.1.2 → python_esios-0.1.3}/python_esios.egg-info/SOURCES.txt +0 -0
- {python_esios-0.1.2 → python_esios-0.1.3}/python_esios.egg-info/dependency_links.txt +0 -0
- {python_esios-0.1.2 → python_esios-0.1.3}/python_esios.egg-info/requires.txt +0 -0
- {python_esios-0.1.2 → python_esios-0.1.3}/python_esios.egg-info/top_level.txt +0 -0
- {python_esios-0.1.2 → python_esios-0.1.3}/setup.cfg +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
class APIClient:
|
|
5
|
+
base_url = 'https://api.esios.ree.es'
|
|
6
|
+
|
|
7
|
+
def __init__(self, api_key=None):
|
|
8
|
+
self.api_key = api_key if api_key else os.getenv('ESIOS_API_KEY')
|
|
9
|
+
if not self.api_key:
|
|
10
|
+
raise ValueError("API key must be provided directly or set in the 'ESIOS_API_KEY' environment variable")
|
|
11
|
+
self.headers = {
|
|
12
|
+
'Accept': "application/json; application/vnd.esios-api-v1+json",
|
|
13
|
+
'Content-Type': "application/json",
|
|
14
|
+
'Host': 'api.esios.ree.es',
|
|
15
|
+
'x-api-key': self.api_key
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
def _api_call(self, method, endpoint, params=None, data=None):
|
|
19
|
+
url = self.base_url + endpoint
|
|
20
|
+
response = requests.request(method, url, headers=self.headers, params=params, json=data)
|
|
21
|
+
response.raise_for_status()
|
|
22
|
+
return response
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
class APIClient:
|
|
5
|
-
base_url = 'https://api.esios.ree.es'
|
|
6
|
-
headers = {
|
|
7
|
-
'Accept': "application/json; application/vnd.esios-api-v1+json",
|
|
8
|
-
'Content-Type': "application/json",
|
|
9
|
-
'Host': 'api.esios.ree.es',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
def __init__(self, api_key=None):
|
|
13
|
-
if api_key is None:
|
|
14
|
-
api_key = os.getenv('ESIOS_API_KEY') # Try to get the API key from environment variable
|
|
15
|
-
if api_key is None:
|
|
16
|
-
raise ValueError("API key must be provided either through constructor or as an environment variable 'ESIOS_API_KEY'")
|
|
17
|
-
self.api_key = api_key
|
|
18
|
-
self.headers['x-api-key'] = self.api_key
|
|
19
|
-
|
|
20
|
-
def _api_call(self, method, endpoint, params=None, data=None):
|
|
21
|
-
url = self.base_url + endpoint
|
|
22
|
-
response = requests.request(method, url, headers=self.headers, params=params, json=data)
|
|
23
|
-
response.raise_for_status()
|
|
24
|
-
return response
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|