Official Python SDK for the Omnia Timeseries API
Project description
Omnia Timeseries Python API
Python package for interacting with the Omnia Industrial IoT Timeseries API.
Installation
Install from PyPI:
pip install omnia-timeseries
Install from GitHub (latest unreleased changes):
pip install git+https://github.com/equinor/omnia-timeseries-python.git@main
Install from a specific Git tag (for example, if you need an earlier SDK version):
pip install git+https://github.com/equinor/omnia-timeseries-python.git@vX.Y.Z
Supported Python versions: 3.10+
For support, create an issue on GitHub.
Example usage
For fundamental questions please refer to the MSAL documentation which has code examples for multiple programming languages and scenarios.
You should also familiarize yourself with the azure.identity package, which we will use below.
Follow usage examples to learn how to retrieve data in Json format.
Follow get data as protobuf example to learn how to retrieve data in Protobuf format.
Preparing Azure authentication
Read https://github.com/equinor/OmniaPlant/wiki/Authentication-&-Authorization to familiarize yourself with how Timeseries API handles authentication and authorization.
The TimeseriesAPI client accepts any azure.identity credential that inherits from MsalCredential, so you can pick the flow that suits your environment. The options we currently cover are:
- Service principal with client secret (
ClientSecretCredential) for headless service-to-service scenarios. - Service principal with certificate (
ClientCertificateCredential) when you prefer cert-based authentication instead of a secret. - Managed identities / default credential chain (
ManagedIdentityCredentialorDefaultAzureCredential) when running inside Azure. - Interactive browser login (
InteractiveBrowserCredential) for local development where you can complete the sign-in with a browser. - User impersonation (
DeviceCodeCredentialor other interactive flows that acquire a user token) when you need to act on behalf of a signed-in user; this requires the Timeseries API app to consent to theuser_impersonationscope. - On-behalf-of flow (
OnBehalfOfCredential) when a middle-tier service needs to exchange a signed-in user's token for a Timeseries API token and act with delegated permissions.
The supported credential setups are shown below.
With service principal credentials (client secret)
Read Service-to-service using a shared secret and ensure prerequisite steps have been done.
from azure.identity import ClientSecretCredential
import os
credentials = ClientSecretCredential(
tenant_id=os.environ['AZURE_TENANT_ID'],
client_id=os.environ['AZURE_CLIENT_ID'],
client_secret=os.environ['AZURE_CLIENT_SECRET']
)
With service principal credentials (client certificate)
Use a certificate instead of a shared secret when you want a stronger identity proof and avoid storing plain secrets.
from azure.identity import ClientCertificateCredential
import os
credentials = ClientCertificateCredential(
tenant_id=os.environ['AZURE_TENANT_ID'],
client_id=os.environ['AZURE_CLIENT_ID'],
certificate_path=os.environ['AZURE_CLIENT_CERT_PATH']
)
With interactive browser login
When developing locally, you can open a browser window and sign in manually.
from azure.identity import InteractiveBrowserCredential
import os
credentials = InteractiveBrowserCredential(
tenant_id=os.environ['AZURE_TENANT_ID'],
client_id=os.environ['AZURE_CLIENT_ID']
)
With user impersonation (device code)
Use a device code or other interactive credential that requests the user_impersonation scope so the signed-in user is impersonated by the Timeseries API.
from azure.identity import DeviceCodeCredential
import os
credentials = DeviceCodeCredential(
tenant_id=os.environ['AZURE_TENANT_ID'],
client_id=os.environ['AZURE_CLIENT_ID']
)
With managed / default credentials
Read Managed Service Identity (For Equinor applications in Azure) and ensure prerequisite steps have been done.
from azure.identity import DefaultAzureCredential
credentials = DefaultAzureCredential()
With on-behalf-of flow
Use OnBehalfOfCredential when a backend service receives a user token (the user assertion) and needs to call the Timeseries API on that user's behalf.
from azure.identity import OnBehalfOfCredential
import os
credentials = OnBehalfOfCredential(
tenant_id=os.environ['AZURE_TENANT_ID'],
client_id=os.environ['AZURE_CLIENT_ID'],
client_secret=os.environ['AZURE_CLIENT_SECRET'],
user_assertion=os.environ['USER_ASSERTION']
)
Output
The Json response from Timeseries API looks like this:
>> {'items': [{'id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'datapoints': [{'time': '2021-02-01T09:54:05.4200000Z', 'value': -0.000286102294921875, 'status': 192}]}]}
The Protobuf response from Timeseries API looks like this:
{ "data": [ { "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "totalCount": "1", "fields": [ "time", "value", "status" ], "values": [ { "int64": "1727263834898000000" }, { "double": 246.56092834472656 }, { "uint32": 192 } ] } ] }
Other use cases
Please consult the API Reference for a full overview of the API endpoints.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file omnia_timeseries-2.0.0.tar.gz.
File metadata
- Download URL: omnia_timeseries-2.0.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25c13160d4264e0fa5c1156ddabbcdaf796f15d4d9190a15362ae63d6112dfbf
|
|
| MD5 |
eb3eebd8c0eaf4c0d22f73de7468665c
|
|
| BLAKE2b-256 |
1abcc21202cfd29ece70e04f5d3eec1d8b0c9cb270c0556e861eeef9542e13c6
|
Provenance
The following attestation bundles were made for omnia_timeseries-2.0.0.tar.gz:
Publisher:
publish-pypi.yml on equinor/omnia-timeseries-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
omnia_timeseries-2.0.0.tar.gz -
Subject digest:
25c13160d4264e0fa5c1156ddabbcdaf796f15d4d9190a15362ae63d6112dfbf - Sigstore transparency entry: 2084794973
- Sigstore integration time:
-
Permalink:
equinor/omnia-timeseries-python@0eee92f1ce953280e82f4ab0b198971acdeb97b0 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/equinor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@0eee92f1ce953280e82f4ab0b198971acdeb97b0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file omnia_timeseries-2.0.0-py3-none-any.whl.
File metadata
- Download URL: omnia_timeseries-2.0.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ce5d2507e5084f6586c8b250d5bd16a3149bf7bcb1b10d56a0331dee7500aad
|
|
| MD5 |
5a7fb4a3c4c1517675ea8f550f935851
|
|
| BLAKE2b-256 |
b1a36b7ba4b3c4d0db9d879db28d49f75df37bc466063fa5a4f66d935c33d3c0
|
Provenance
The following attestation bundles were made for omnia_timeseries-2.0.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on equinor/omnia-timeseries-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
omnia_timeseries-2.0.0-py3-none-any.whl -
Subject digest:
4ce5d2507e5084f6586c8b250d5bd16a3149bf7bcb1b10d56a0331dee7500aad - Sigstore transparency entry: 2084794983
- Sigstore integration time:
-
Permalink:
equinor/omnia-timeseries-python@0eee92f1ce953280e82f4ab0b198971acdeb97b0 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/equinor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@0eee92f1ce953280e82f4ab0b198971acdeb97b0 -
Trigger Event:
push
-
Statement type: