EHESO API
Project description
EHESO API Client for Python
This Python package is automatically generated by the OpenAPI Generator project:
- API version: v1
- Generator version: 7.7.0
- Build package: org.openapitools.codegen.languages.PythonPydanticV1ClientCodegen
Requirements.
Python 3.7+
Installation & Usage
pip install
pip install eheso-api-client
Post-Installation Setup
After installing the package, you need to create a .env file in the source folder containing the API key for server access.
Steps to Create the .env File:
- Navigate to the folder where the package is installed or the source folder of your project.
- Create a file named
.env. - Add the following line to the
.envfile:
API_KEY="your_api_key_here"
Replace your_api_key_here with the actual API key provided to you.
For example:
API_KEY="abcd1234efgh5678ijkl"
Save the .env file.
Note
- The package uses the
.envfile to securely load the API key into the application. - Please make sure the .env file is not included in version control systems like Git (add .env to your .gitignore).
Getting Started
The following section provides examples for the most important endpoints:
Get All Layer Data
Retrieve all the data from a specified layer in the requested format.
For details regarding the parameters and response samples please refer to the documentation: Get All Layer Data.
import json
import time
import os
import eheso_api_client
from eheso_api_client.models.format import Format
from eheso_api_client.rest import ApiException
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = eheso_api_client.Configuration(
host = 'https://dev.observatory.eter-project.com/api/v1'
)
# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ['API_KEY']
# Enter a context with an instance of the API client
with eheso_api_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = eheso_api_client.LayerDataApi(api_client)
layer_id = 'COUNTRY' # str | The ID of the layer
format = 'flat' # Format |
try:
# Get All Layer Data
api_response = api_instance.layer_query_get(layer_id, format)
print('The response of LayerDataApi->layer_query_get:\n')
pprint(api_response)
# save as json file
with open('data.json', 'w', encoding='utf-8') as f:
json.dump(api_response, f, ensure_ascii=False, indent=4)
except Exception as e:
print('Exception when calling LayerDataApi->layer_query_get: %s\n' % e)
Query Layer Data
Retrieve data from a specified layer based on the provided parameters. This endpoint allows querying the layer for specific data, applying filters, and returning the results in the requested format.
For details regarding the parameters and response samples please refer to the documentation: Query Layer Data.
import time
import os
import eheso_api_client
from eheso_api_client.models.query_post_schema import QueryPostSchema
from eheso_api_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://dev.observatory.eter-project.com/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = eheso_api_client.Configuration(
host = "https://dev.observatory.eter-project.com/api/v1"
)
# Configure API key authorization: ApiKeyAuth
configuration.api_key["ApiKeyAuth"] = os.environ["API_KEY"]
# Enter a context with an instance of the API client
with eheso_api_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = eheso_api_client.LayerDataApi(api_client)
layer_id = "COUNTRY" # str | The ID of the layer
query_post_schema = {
"format":"flat",
"find": {
"CY.COUNTRY.v": "AD",
"CY.YEAR.v": 2015
},
"limit":1,
"select": [ ],
"sort": { }
} # QueryPostSchema |
try:
# Query Layer Data
api_response = api_instance.layer_query_post(layer_id, query_post_schema)
print("The response of LayerDataApi->layer_query_post:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling LayerDataApi->layer_query_post: %s\n" % e)
Get Minimal Field Information
Retreive metadata for each field such as field type, name, category, and definition.
For details regarding the parameters and response samples please refer to the documentation: Query Layer Data.
import time
import os
import eheso_api_client
from eheso_api_client.models.field_info_response_inner import FieldInfoResponseInner
from eheso_api_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://dev.observatory.eter-project.com/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = eheso_api_client.Configuration(
host = "https://dev.observatory.eter-project.com/api/v1"
)
# Configure API key authorization: ApiKeyAuth
configuration.api_key["ApiKeyAuth"] = os.environ["API_KEY"]
# Enter a context with an instance of the API client
with eheso_api_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = eheso_api_client.LayerInfoApi(api_client)
layer_id = "COUNTRY" # str | The ID of the layer
try:
# Get field information
api_response = api_instance.field_get(layer_id)
print("The response of LayerInfoApi->field_get:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling LayerInfoApi->field_get: %s\n" % e)
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eheso_api_client-0.1.18.tar.gz.
File metadata
- Download URL: eheso_api_client-0.1.18.tar.gz
- Upload date:
- Size: 38.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0160f44072782dbdb900f5fbb56dd7c929fad126d2df45a91107c8f2c123dff9
|
|
| MD5 |
a47492f870ca37681f927dae094a2ea6
|
|
| BLAKE2b-256 |
5de04abe7149c58fddaf81a614f12ad8a313529b1261bc2f279773823ea86a00
|
File details
Details for the file eheso_api_client-0.1.18-py3-none-any.whl.
File metadata
- Download URL: eheso_api_client-0.1.18-py3-none-any.whl
- Upload date:
- Size: 65.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55573fbecb72ee5b5a6f161ba89a906c62f660031ae275eb6ae6d1d9be03b8d1
|
|
| MD5 |
aa4bf98e84871bfe3a52bdcc7a9111f2
|
|
| BLAKE2b-256 |
aac1cb394c70d2ff9386aed0d48d79d8c8f23c8106bc11b1502169d1d0949c2b
|