Facilitate access to Demeter REST interface endpoints, provided by Hidroconta S.A.U.
Project description
Integrations-PythonAPI
Python API to facilitate access to Demeter REST interface endpoints. https://pypi.org/project/hidroconta/
The API allows the management of large amounts of data using the Pandas library, provided that the following directive is used in method calls:
# Pandas = True returns a pandas dataframe instead a json
The way to use the API is the following:
- Import the desired modules:
import hidroconta.api as demeter
import hidroconta.types as hidrotypes
import pandas as pd
import datetime
import hidroconta.endpoints as hidroendpoints
- Select the server with which you want to communicate (you can modify it at any time):
# Set server
demeter.set_server(hydroendpoints.Server.MAIN)
- Login to this server
# Login
demeter.login('USERNAME', 'PASSWORD')
Once the previous steps have been followed, you can make any query about the system. Some of them are:
- Search
# Search
df = demeter.search(text='SAT', element_types=[hidrotypes.Element.COUNTER, hidrotypes.Element.ANALOG_INPUT, hidrotypes.Element.RTU], status=hidrotypes.Status.ENABLED, pandas=True)
print(df)
- Getting history
# Get historics
df = demeter.get_historics(start_date=datetime.datetime.now(), end_date=datetime.datetime.now(), element_ids=[1000], subtype=hidrotypes.AnalogInputHist.subtype, subcode=[hidrotypes.AnalogInputHist.subcode], pandas=True)
print(df)
- Getting elements
# Get
df = demeter.get_rtus(element_id=17512, pandas=True)
print(df)
The API also defines a special exception when the call to the Demeter endpoint does not return the expected result. The exception is called 'DemeterStatusCodeException' and contains the HTTP error code.
# Exception treatment
try:
df = demeter.get_rtus(element_id=17512, pandas=True).
except demeter.DemeterStatusCodeException as status_code:
print('Error {}'.format(status_code))
- Finally, a logout should be made on the server
demeter.logout()
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 hidroconta-1.4.1.tar.gz.
File metadata
- Download URL: hidroconta-1.4.1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
566bee4f6ed085a78076cfc1be70d4a973644793c8011f20aeafa22ea1cd4d68
|
|
| MD5 |
8ac34dea68d648a3057cbf58a8a411f2
|
|
| BLAKE2b-256 |
eb02438cb61d1cefd02e31ff80b5e51458bf9cc2ac5120afeaffaa2526a8f600
|
File details
Details for the file hidroconta-1.4.1-py3-none-any.whl.
File metadata
- Download URL: hidroconta-1.4.1-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2592330abc521441a7142a693e422b3428f1077e202b2defa5df2a23b5443ed
|
|
| MD5 |
6aea9509a66867c56b95f0e358cee174
|
|
| BLAKE2b-256 |
7af1c4e03b1dfae41fbe82e705935622485dac3728ef63ed80ec6996d39da372
|