Sage Data Client
This is the official Sage Python data API client. Its main goal is to make writing queries and working with the results easy. It does this by:
- Providing a simple query function which talks to the data API.
- Providing the results in an easy to use Pandas data frame.
Installation
Sage Data Client can be installed with pip using:
pip3 install sage-data-client
If you prefer to install this package into a Python virtual environment or are unable to install it system wide, you can use the venv module as follows:
# 1. Create a new virtual environment called my-venv.
python3 -m venv my-venv
# 2. Activate the virtual environment
source my-venv/bin/activate
# 3. Install sage data client in the virtual environment
pip3 install sage-data-client
Note: If you are using Linux, you may need to install the python3-venv package which is outside of the scope of this document.
Note: You will need to activate this virtual environment when opening a new terminal before running any Python scripts using Sage Data Client.
Usage Examples
Query API
import sage_data_client
# query and load data into pandas data frame
df = sage_data_client.query(
start="-1h",
filter={
"name": "env.temperature",
}
)
# print results in data frame
print(df)
# meta columns are expanded into meta.fieldname. for example, here we print the unique nodes
print(df["meta.vsn"].unique())
# print stats of the temperature data grouped by node + sensor.
print(df.groupby(["meta.vsn", "meta.sensor"]).value.agg(["size", "min", "max", "mean"]))
import sage_data_client
# query and load data into pandas data frame
df = sage_data_client.query(
start="-1h",
filter={
"name": "env.raingauge.*",
}
)
# print number of results of each name
print(df.groupby(["meta.vsn", "name"]).size())
Load results from file
If we have saved the results of a query to a file data.json, we can also load using the load function as follows:
import sage_data_client
# load results from local file
df = sage_data_client.load("data.json")
# print number of results of each name
print(df.groupby(["meta.vsn", "name"]).size())
Integration with Notebooks
Since we leverage the fantastic work provided by the Pandas library, performing things like looking at dataframes or creating plots is easy.
A basic example of querying and plotting data can be found here.
Additional Examples
Additional code examples can be found in the examples directory.
If you're interested in contributing your own examples, feel free to add them to examples/contrib and open a PR!
Reference
The query function accepts the following arguments:
start. Absolute or relative start timestamp. (required)end. Absolute or relative end timestamp.head. Limit results toheadearliest values per series. (Only one ofheadortailcan be provided.)tail. Limit results totaillatest values per series. (Only one ofheadortailcan be provided.)filter. Key-value patterns to filter data on.
Metadata
Release files for sage-data-client 0.9.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 |
|---|---|---|---|---|
| sage_data_client-0.9.1.tar.gz | 7.5 kB | Without provenance | Details for sage_data_client-0.9.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sage_data_client-0.9.1-py3-none-any.whl | Python 3 | none | any | Details for sage_data_client-0.9.1-py3-none-any.whl |
Total release size: 14.1 kB
Release files / sage_data_client-0.9.1.tar.gz
| Download URL | sage_data_client-0.9.1.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d1b0e02afc085441542c567aa47a6c866859a7c86ca908e57b96f35affbb9f4
|
|
BLAKE2b-256 checksum How to use checksums |
4d7e36868a4b5dee741bd60738da0a56d5719510a6103afec6222de8d11516a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sage_data_client-0.9.1-py3-none-any.whl
| Download URL | sage_data_client-0.9.1-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a08efebe898010bc58418ec14c1374ff2337efc19dd6e379e4904b82264edaad
|
|
BLAKE2b-256 checksum How to use checksums |
bb8fa8b7f2baa3a04059f88afbf56f5ff668a6b9fa70e58c9668b681d27c2ea4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for sage-data-client 0.9.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.