stapy
This is an easy to use SensorThings API Client written in Python
The SensorThings API (STA) is an OGC standard for IoT device sensing data.
A server implementation of the STA can be found here FROST.
For more (advanced) information about the SensorThings API see the official OGC documentation.
Installation
stapy is compatible with Python 3.7+ and the recommended way to install is via pip
pip install stapy
Usage
stapy can be used both form the command line (in two different ways) and as a Python library.
STA_URL
At first it is necessary to set the URL of the STA. Optionally it is also possible to set credentials for a basic authentication. Within the CLI this can be achieved as follows:
stapy -u {URL}
stapy -c {USR} {PWD}
stapy can of course be also run as a Python module(python -m stapy)
The URL and credentials can also be set from within a Python script:
>>> import stapy
>>> stapy.set_sta_url({URL})
>>> stapy.set_credentials({USR}, {PWD})
CLI - Interactive
The interactive mode is the easiest one to use but can not be used programmatically. Therefore it is probably a good starting point to get familiar with the STA. The interactive mode can be invoked in the following way.
stapy -i
Currently it does support POST, PATCH and DELETE requests.
CLI - Normal
The normal command line mode is a bit more difficult to use but can be automated.
stapy --help
Should give sufficient information on how two use it properly.
As the interactive mode it does support POST, PATCH and DELETE requests.
Library
This is the Python interface to the SensorThings API (stapy is meant to be used as Python library).
Therefore it supports all requests (POST, PATCH, DELETE and GET).
The relevant classes can be found within the files entity.py, delete.py, post.py, patch.py and query.py in the sta sub-module.
The following syntax can be used to create new entities:
>>> from stapy import Post
>>> Post.observed_property("TestProp", "TestProp-Desc", "TestProp-Def")
To understand which arguments are available and mandatory it is advisable to have a look at the STA-Docs and/or use the interactive mode of stapy.
Following is one example of a GET request:
>>> from stapy import Query, Entity
>>> results, times = Query(Entity.Observation).select("result", "phenomenonTime").order("result").get_data_sets()
results afterwards contains all results of the present Observations in ascending order.
times contains the respective times for the results.
stapy does support all GET query options that are available for the STA.
Some examples are select, filter, orderby and skip. These can be chained together as seen in the example above.
Further use-cases and applications can be found in the examples.
Development
To build this project, run python setup.py build. To execute the unit tests, run python setup.py test.
Metadata
Release files for stapy 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stapy-0.3.1.tar.gz | 22.7 kB | Without provenance | Details for stapy-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stapy-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for stapy-0.3.1-py3-none-any.whl |
Total release size: 53.8 kB
Release files / stapy-0.3.1.tar.gz
| Download URL | stapy-0.3.1.tar.gz |
|---|---|
| Size | 22.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33e720be785314e7b8652afab50da5c826aace57748808656b18b57e8d44718a
|
|
BLAKE2b-256 checksum How to use checksums |
3d6fa99f736b954587f67536b38e2536aa48cd1b91c5b5e0a0aababc91885f65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Release files / stapy-0.3.1-py3-none-any.whl
| Download URL | stapy-0.3.1-py3-none-any.whl |
|---|---|
| Size | 31.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3173b41753b5bc9d6f394cc1078292f8ea519b103f08eaee30374a9a91191df1
|
|
BLAKE2b-256 checksum How to use checksums |
14de6f558809e9d7b701cfc786a44d821eeb910bfed20941bc29250a9babd741
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Security for stapy 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.