enhydris-api-client


Nameenhydris-api-client JSON
Version 4.0.0 PyPI version JSON
download
home_pagehttps://github.com/openmeteo/enhydris-api-client
SummaryPython API client for Enhydris
upload_time2024-04-16 19:19:39
maintainerNone
docs_urlNone
authorAntonis Christofides
requires_pythonNone
licenseGNU General Public License v3
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            ===================
enhydris-api-client
===================


.. image:: https://img.shields.io/pypi/v/enhydris_api_client.svg
        :target: https://pypi.python.org/pypi/enhydris-api-client
        :alt: Pypi

.. image:: https://img.shields.io/travis/openmeteo/enhydris-api-client.svg
        :target: https://travis-ci.org/openmeteo/enhydris-api-client
        :alt: Build

.. image:: https://codecov.io/github/openmeteo/enhydris-api-client/coverage.svg
        :target: https://codecov.io/gh/openmeteo/enhydris-api-client
        :alt: Coverage

.. image:: https://pyup.io/repos/github/openmeteo/enhydris-api-client/shield.svg
         :target: https://pyup.io/repos/github/openmeteo/enhydris-api-client/
         :alt: 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.

Installation
============

``pip install enhydris-api-client``

Example
=======

::

    from enhydris_api_client import EnhydrisApiClient

    with EnhydrisApiClient("https://openmeteo.org", "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"})


Reference
=========

**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.

| **.get_station(id)**
| **.post_station(data)**
| **.put_station(station_id, data)**
| **.patch_station(station_id, data)**
| **.delete_station(station_id)**

Methods that create, retrieve, update or delete stations. The ``data``
argument (for those methods that receive one) is a dictionary.
``get_station()`` returns a dictionary with the data for the station.
``post_station()`` returns the created station's id.

| **.get_timeseries_group(station_id, timeseries_group_id)**
| **.post_timeseries_group(station_id, timeseries_group_id, data)**
| **.put_timeseries_group(station_id, timeseries_group_id, data)**
| **.patch_timeseries_group(station_id, timeseries_group_id, data)**
| **.delete_timeseries_group(station_id, timeseries_group_id)**

Methods that create, retrieve, update or delete time series groups.
Similar to the ones for station.

| **.list_timeseries(station_id, timeseries_group_id)**
| **.get_timeseries(station_id, timeseries_group_id, timeseries_id)**
| **.post_timeseries(station_id, timeseries_group_id, data)**
| **.delete_timeseries(station_id, timeseries_group_id, timeseries_id)**

Methods that create, retrieve or delete time series. Similar to the ones
for station. ``list_timeseries()`` returns a list of dictionaries.

| **.read_tsdata(station_id, timeseries_group_id, timeseries_id, start_date=None, end_date=None, timezone=None)**
| **.post_tsdata(station_id, timeseries_group_id, timeseries_id, ts)**
| **.get_ts_end_date(station_id, timeseries_group_id, timeseries_id, timezone=None)**

Methods that retrieve or update time series data.

``read_ts_data()`` retrieves the time series data into a htimeseries
object that it returns. If ``start_date`` and/or ``end_date`` (aware
datetime objects) are specified, only the part of the time series
between these dates is retrieved. The timestamps are returned in the
specified time zone. If unspecified, then they are returned in the time
zone specified by the station's display_timezone_.

``post_tsdata() `` posts a time series to Enhydris, appending the
records to any already existing.  ``ts`` is a htimeseries object.

``get_ts_end_date()`` returns a ``datetime`` object which is the last
timestamp of the time series. If the time series is empty it returns
``None``. The returned timestamp is always naive, but it is in the specified
``timezone`` (or the station's display_timezone_ if unspecified).

.. _display_timezone: https://enhydris.readthedocs.io/en/latest/dev/database.html#enhydris.models.Gentity.display_timezone


=======
History
=======

4.0.0 (2024-04-16)
==================

- Requires htimeseries 7.
- When downloading time series data without specifying the time zone, it
  uses the ``display_timezone`` of that Enhydris station, whereas in
  3.x.x it used UTC. The behaviour is now similar to that of 2.x.x.

3.0.1 (2024-04-14)
==================

- Compatible with htimeseries 4 to 7.

3.0.0 (2022-12-04)
==================

- Requires Enhydris 4 and htimeseries 4, and therefore requires aware
  HTimeseries objects.
- Supports specifying time zone when downloading time series data.
- Support for creating, retrieving, updating, and deleting time series
  groups.

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/openmeteo/enhydris-api-client",
    "name": "enhydris-api-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Antonis Christofides",
    "author_email": "antonis@antonischristofides.com",
    "download_url": "https://files.pythonhosted.org/packages/d9/bf/16f28ac6221fe0d708edd032817a3d32ac23287296d5645b1e3f6143f2cb/enhydris-api-client-4.0.0.tar.gz",
    "platform": null,
    "description": "===================\nenhydris-api-client\n===================\n\n\n.. image:: https://img.shields.io/pypi/v/enhydris_api_client.svg\n        :target: https://pypi.python.org/pypi/enhydris-api-client\n        :alt: Pypi\n\n.. image:: https://img.shields.io/travis/openmeteo/enhydris-api-client.svg\n        :target: https://travis-ci.org/openmeteo/enhydris-api-client\n        :alt: Build\n\n.. image:: https://codecov.io/github/openmeteo/enhydris-api-client/coverage.svg\n        :target: https://codecov.io/gh/openmeteo/enhydris-api-client\n        :alt: Coverage\n\n.. image:: https://pyup.io/repos/github/openmeteo/enhydris-api-client/shield.svg\n         :target: https://pyup.io/repos/github/openmeteo/enhydris-api-client/\n         :alt: Updates\n\nPython API client for Enhydris\n\n* Free software: GNU General Public License v3\n\nThis package has some functionality to make it easier to use the\nEnhydris API.\n\nInstallation\n============\n\n``pip install enhydris-api-client``\n\nExample\n=======\n\n::\n\n    from enhydris_api_client import EnhydrisApiClient\n\n    with EnhydrisApiClient(\"https://openmeteo.org\", \"my_auth_token\") as api_client:\n        # Get a dict with attrs of station with id=42\n        station = api_client.get_model(Station, 42)\n\n        # Create a new station\n        api_client.post_model(Station, data={\"name\": \"my station\"})\n\n\nReference\n=========\n\n**EnhydrisApiClient(base_url, token=None)**\n\nCreates and returns an api client. It can also be used as a context\nmanager, though this is not necessary. If not used as a context manager,\nyou might get warnings about unclosed sockets.\n\nNot specifying ``token`` is deprecated. ``token`` will become mandatory\nin future versions.\n\n``EnhydrisApiClient`` objects have the following methods:\n\n**.get_token(username, password)**\n\n(Deprecated.) Gets an API token from Enhydris and thereafter uses it in\nsubsequent requests. The method will be removed in future versions.\n\n| **.get_station(id)**\n| **.post_station(data)**\n| **.put_station(station_id, data)**\n| **.patch_station(station_id, data)**\n| **.delete_station(station_id)**\n\nMethods that create, retrieve, update or delete stations. The ``data``\nargument (for those methods that receive one) is a dictionary.\n``get_station()`` returns a dictionary with the data for the station.\n``post_station()`` returns the created station's id.\n\n| **.get_timeseries_group(station_id, timeseries_group_id)**\n| **.post_timeseries_group(station_id, timeseries_group_id, data)**\n| **.put_timeseries_group(station_id, timeseries_group_id, data)**\n| **.patch_timeseries_group(station_id, timeseries_group_id, data)**\n| **.delete_timeseries_group(station_id, timeseries_group_id)**\n\nMethods that create, retrieve, update or delete time series groups.\nSimilar to the ones for station.\n\n| **.list_timeseries(station_id, timeseries_group_id)**\n| **.get_timeseries(station_id, timeseries_group_id, timeseries_id)**\n| **.post_timeseries(station_id, timeseries_group_id, data)**\n| **.delete_timeseries(station_id, timeseries_group_id, timeseries_id)**\n\nMethods that create, retrieve or delete time series. Similar to the ones\nfor station. ``list_timeseries()`` returns a list of dictionaries.\n\n| **.read_tsdata(station_id, timeseries_group_id, timeseries_id, start_date=None, end_date=None, timezone=None)**\n| **.post_tsdata(station_id, timeseries_group_id, timeseries_id, ts)**\n| **.get_ts_end_date(station_id, timeseries_group_id, timeseries_id, timezone=None)**\n\nMethods that retrieve or update time series data.\n\n``read_ts_data()`` retrieves the time series data into a htimeseries\nobject that it returns. If ``start_date`` and/or ``end_date`` (aware\ndatetime objects) are specified, only the part of the time series\nbetween these dates is retrieved. The timestamps are returned in the\nspecified time zone. If unspecified, then they are returned in the time\nzone specified by the station's display_timezone_.\n\n``post_tsdata() `` posts a time series to Enhydris, appending the\nrecords to any already existing.  ``ts`` is a htimeseries object.\n\n``get_ts_end_date()`` returns a ``datetime`` object which is the last\ntimestamp of the time series. If the time series is empty it returns\n``None``. The returned timestamp is always naive, but it is in the specified\n``timezone`` (or the station's display_timezone_ if unspecified).\n\n.. _display_timezone: https://enhydris.readthedocs.io/en/latest/dev/database.html#enhydris.models.Gentity.display_timezone\n\n\n=======\nHistory\n=======\n\n4.0.0 (2024-04-16)\n==================\n\n- Requires htimeseries 7.\n- When downloading time series data without specifying the time zone, it\n  uses the ``display_timezone`` of that Enhydris station, whereas in\n  3.x.x it used UTC. The behaviour is now similar to that of 2.x.x.\n\n3.0.1 (2024-04-14)\n==================\n\n- Compatible with htimeseries 4 to 7.\n\n3.0.0 (2022-12-04)\n==================\n\n- Requires Enhydris 4 and htimeseries 4, and therefore requires aware\n  HTimeseries objects.\n- Supports specifying time zone when downloading time series data.\n- Support for creating, retrieving, updating, and deleting time series\n  groups.\n\n2.0.1 (2021-08-31)\n==================\n\n- Updated dependences (the version of htimeseries required was too old).\n\n2.0.0 (2020-10-06)\n==================\n\n- We now support the time series groups of Enhydris 3. Earlier Enhydris\n  versions are unsupported. Use enhydris-api-client v1 for Enhydris v2.\n- We now use token authentication. Using a username and password have\n  been deprecated and will be removed in a future version. Accordingly,\n  the ``.login()`` method has been removed; it has been replaced with\n  the deprecated ``.get_token()`` method.\n\n1.0.0 (2020-02-28)\n==================\n\n- We now support only Python 3.7 or greater.\n- If there is an http error, the error message now includes the response body.\n\n0.5.1 (2020-01-05)\n==================\n\n- Minor fix for compatibility with htimeseries 2\n\n0.5.0 (2019-06-13)\n==================\n\n- Can now be used as a context manager\n- Added post/put/patch/delete station\n\n0.4.1 (2019-06-12)\n==================\n\n- Fixed bug where .read_tsdata() was failing to set the metadata\n  attributes of the time series.\n\n0.4.0 (2019-06-12)\n==================\n\n- .read_tsdata() now accepts optional arguments start_date and end_date.\n\n0.3.0 (2019-06-06)\n==================\n\n- Upgrade dependecy htimeseries to 1.0\n\n0.2.0 (2019-04-17)\n==================\n\n- Support new API of Enhydris 3\n\n0.1.0 (2019-03-06)\n==================\n\n- Initial release\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3",
    "summary": "Python API client for Enhydris",
    "version": "4.0.0",
    "project_urls": {
        "Homepage": "https://github.com/openmeteo/enhydris-api-client"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d9ce4a3430f2ec2bd9ee24d2bea22c6bf12f2ce497f415db0ae4249225464377",
                "md5": "bb15a4a067c3360560545b5f98b48f05",
                "sha256": "aff43d56bcbc5c6ea0a0b2e6d5b552957807b099056367c83ff5a071561454cd"
            },
            "downloads": -1,
            "filename": "enhydris_api_client-4.0.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bb15a4a067c3360560545b5f98b48f05",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 6137,
            "upload_time": "2024-04-16T19:19:38",
            "upload_time_iso_8601": "2024-04-16T19:19:38.445794Z",
            "url": "https://files.pythonhosted.org/packages/d9/ce/4a3430f2ec2bd9ee24d2bea22c6bf12f2ce497f415db0ae4249225464377/enhydris_api_client-4.0.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d9bf16f28ac6221fe0d708edd032817a3d32ac23287296d5645b1e3f6143f2cb",
                "md5": "84ec03f97c0449570c0d3fa34eaa395e",
                "sha256": "11d0d266227064dede6335d363b1f917cc049bedef18827e3681fc888876cc1c"
            },
            "downloads": -1,
            "filename": "enhydris-api-client-4.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "84ec03f97c0449570c0d3fa34eaa395e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11667,
            "upload_time": "2024-04-16T19:19:39",
            "upload_time_iso_8601": "2024-04-16T19:19:39.879299Z",
            "url": "https://files.pythonhosted.org/packages/d9/bf/16f28ac6221fe0d708edd032817a3d32ac23287296d5645b1e3f6143f2cb/enhydris-api-client-4.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-16 19:19:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "openmeteo",
    "github_project": "enhydris-api-client",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "enhydris-api-client"
}
        
Elapsed time: 0.42854s