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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-esios
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: A Python wrapper for the ESIOS API
5
5
  Home-page: https://github.com/datons/python-esios
6
6
  Author: Jesús López
@@ -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
@@ -3,7 +3,7 @@ from esios.api_client import APIClient
3
3
  import html
4
4
 
5
5
  class Indicators(APIClient):
6
- def __init__(self, api_key):
6
+ def __init__(self, api_key=None):
7
7
  super().__init__(api_key)
8
8
 
9
9
  def list(self, df=False):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-esios
3
- Version: 0.1.2
3
+ Version: 0.1.3
4
4
  Summary: A Python wrapper for the ESIOS API
5
5
  Home-page: https://github.com/datons/python-esios
6
6
  Author: Jesús López
@@ -7,7 +7,7 @@ long_description = (this_directory / "README.md").read_text(encoding='utf-8')
7
7
 
8
8
  setup(
9
9
  name='python-esios',
10
- version='0.1.2',
10
+ version='0.1.3',
11
11
  packages=find_packages(),
12
12
  install_requires=[
13
13
  'requests',
@@ -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