A connector to connect to the Lizard-API with Python.
Project description
lizard-connector
- warning:
Lizard API version 2 will deprecate on January 31th 2021, please switch to the default API version 3
This can be done by either omitting the version parameter when creating a Client instance, or creating a Client instance with version 3 specified:
Introduction
Connector to Lizard api (e.g. https://demo.lizard.net/api/v3) for python.
Includes: - Client (experimental / alpha) - Endpoint (Easy access to Lizard api endpoints) - Connector (http handling) - parsers to parse the json obtained from Endpoint queries - queryfunctions for special cases such as geographical queries and time related queries other queries can be input as a dictionary - callbacks for async data handling.
When pandas, numpy are installed the Client returns pandas.DataFrame`s and/or `numpy.array`s in a `ScientifResult object.
Example usage
An example jupyter notebook can be found Example_EN.ipynb or in Dutch: Voorbeeld_NL.ipynb.
Use one endpoints https://demo.lizard.net/api/v3 in Python with the Endpoint class:
from lizard_connector import Client import lizard_connector.queries import datetime # Fill in your username and password (your password will be prompted) client = lizard_connector.Client( username = "example.username" ) endpoint = 'timeseries' south_west = [48.0, -6.8] north_east = [56.2, 18.9] organisation_id = 'example_organisation_uuid' start = datetime.datetime(1970, 1, 1) end = datetime.datetime.now() relevant_queries = [ lizard_connector.queries.in_bbox(south_west, north_east, endpoint), lizard_connector.queries.organisation(organisation_id, endpoint), lizard_connector.queries.datetime_limits(start, end) ] results = client.timeseries.get(*relevant_queries)
Usage with PyQT (for Qgis plugins)
You can create a QThread worker like so:
from PyQt4.QtCore import QThread from PyQt4.QtCore import pyqtSignal class Worker(QThread): """This class creates a worker thread for getting the data.""" output = pyqtSignal(object) def __init__(self, parent=None, endpoint=None, *querydicts, **queries): """Initiate the Worker.""" super(Worker, self).__init__(parent) self._endpoint = endpoint self._querydicts = querydicts self._queries = queries def run(self): """Called indirectly by PyQt if you call start(). This method retrieves the data from Lizard and emits it via the output signal as dictionary. """ data = self._endpoint._synchronous_get_async( *self._querydicts, **self._queries) self.output.emit(data)
Credits
roel.vandenberg@nelen-schuurmans.nl started this library
Changelog of lizard-connector
0.7.3 (2020-12-17)
Removed mentions of v2 API from docs.
0.7.2 (2020-12-17)
Added FutureWarnings when using the v2 API (default is V3)
Renamed REAMDE.md to README.rst
0.7.1 (2018-04-17)
Nothing changed yet.
0.7 (2018-04-17)
Added Client.
Added parsers (scientific, json).
Added callbacks.
Renamed Endpoint download… methods to get….
0.6 (2018-02-07)
Add explicit py2/3 imports to mitigate problems with the future library.
0.5 (2017-10-16)
Compatible with python 2.7.
Refactored pagination.
Added Async downloads with callback.
Removes max_result on Endpoint initialisation.
0.4 (2016-06-05)
Fixed bug in iteration over paginated results.
When all_pages is set to False all methods involving get return the object as an iterator.
0.3 (2016-05-06)
Http base urls are not allowed, throws exception when baseurl is not secure (i.e. does not start with https).
Fixed a bug that caused a get to run two times.
0.2 (2016-05-04)
Added Datatype classes.
Renamed Endpoint get and post to download and upload.
0.1 (2016-03-29)
Basic setup
Added tests
Initial project structure created with nensskel 1.37.dev0.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file lizard-connector-0.7.3.tar.gz
.
File metadata
- Download URL: lizard-connector-0.7.3.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5238adb67da394c593e5d7ea7e45762d19d83e97c98e5c5d4a5c4c9230f15111 |
|
MD5 | 521a1c0e6e0d2eff1d5634acc00dcf8d |
|
BLAKE2b-256 | d8ae745fba3f0073621c5d6ca7f2f388a154cef0366e177ebf7f3d0e603ff8f1 |