Skip to main content

Python API client for Enhydris

Project description


Pypi Build Coverage Updates

Python API client for Enhydris

  • Free software: GNU General Public License v3

This package has some functionality to make it easier to use the Enhydris API.


pip install enhydris-api-client


from enhydris_api_client import EnhydrisApiClient

with EnhydrisApiClient("", "my_auth_token") as api_client:
    # Get a dict with attrs of station with id=42
    station = api_client.get_model(Station, 42)

    # Create a new station
    api_client.post_model(Station, data={"name": "my station"})


EnhydrisApiClient(base_url, token=None)

Creates and returns an api client. It can also be used as a context manager, though this is not necessary. If not used as a context manager, you might get warnings about unclosed sockets.

Not specifying token is deprecated. token will become mandatory in future versions.

EnhydrisApiClient objects have the following methods:

.get_token(username, password)

(Deprecated.) Gets an API token from Enhydris and thereafter uses it in subsequent requests. The method will be removed in future versions.


Returns a dict with the data for the station with the given id.


Creates a new station, with its data given by dictionary data, and returns its id.

.put_station(station_id, data)

Replaces the station’s attributes with data (a dictionary). Any unspecified attributes are set to null.

.patch_station(station_id, data)

Same as put_station() except that any attribute not specified in data is untouched.


Deletes the specified station.

.list_timeseries(station_id, timeseries_group_id)

Returns a list of time series in the specified group. Each item in the list is a dict with the data for the time series.

.get_timeseries(station_id, timeseries_group_id, timeseries_id)

Returns a dict with the data for the given time series.

.post_timeseries(station_id, timeseries_group_id, data)

Creates a new time series, with its data given by dictionary data, and returns its id.

.delete_timeseries(station_id, timeseries_group_id, timeseries_id)

Deletes the specified time series.

.read_tsdata(station_id, timeseries_group_id, timeseries_id, start_date=None, end_date=None)

Retrieves the time series data into a htimeseries object that it returns. If start_date and/or end_date are specified, only the part of the time series between these dates is retrieved.

.post_tsdata(station_id, timeseries_group_id, timeseries_id, ts)

Posts a time series to Enhydris, appending the records to any already existing. ts is a htimeseries object.

.get_ts_end_date(station_id, timeseries_group_id, timeseries_id)

Returns a datetime object which is the last timestamp of the time series. If the time series is empty it returns None.


2.0.1 (2021-08-31)

  • Updated dependences (the version of htimeseries required was too old).

2.0.0 (2020-10-06)

  • We now support the time series groups of Enhydris 3. Earlier Enhydris versions are unsupported. Use enhydris-api-client v1 for Enhydris v2.
  • We now use token authentication. Using a username and password have been deprecated and will be removed in a future version. Accordingly, the .login() method has been removed; it has been replaced with the deprecated .get_token() method.

1.0.0 (2020-02-28)

  • We now support only Python 3.7 or greater.
  • If there is an http error, the error message now includes the response body.

0.5.1 (2020-01-05)

  • Minor fix for compatibility with htimeseries 2

0.5.0 (2019-06-13)

  • Can now be used as a context manager
  • Added post/put/patch/delete station

0.4.1 (2019-06-12)

  • Fixed bug where .read_tsdata() was failing to set the metadata attributes of the time series.

0.4.0 (2019-06-12)

  • .read_tsdata() now accepts optional arguments start_date and end_date.

0.3.0 (2019-06-06)

  • Upgrade dependecy htimeseries to 1.0

0.2.0 (2019-04-17)

  • Support new API of Enhydris 3

0.1.0 (2019-03-06)

  • Initial release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Built Distribution

enhydris_api_client-2.0.1-py2.py3-none-any.whl (5.5 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page