A Python SDK for Omni API
Project description
omni-python-sdk
Python SDK for interacting with the Omni API
Installation
pip install -r requirements.txt
Usage
from omni_python_sdk import OmniAPI
# Set your API key and base URL
api_key = "your_api_key"
base_url = "https://your_domain.omniapp.co"
#these can optionally be set in an .env file with the following keys:
# OMNI_API_KEY=<<your api key>>
# OMNI_BASE_URL=<<your base url>>
# Define your query
query = {
"query": {
"sorts": [
{
"column_name": "order_items.created_at[date]",
"sort_descending": False
}
],
"table": "order_items",
"fields": [
"order_items.created_at[date]",
"order_items.sale_price_sum"
],
"modelId": "your_model_id",
"join_paths_from_topic_name": "order_items"
}
}
# Initialize the API with your credentials
api = OmniAPI(api_key, base_url)
# if you've optionally set your keys in a .env file no arguments are required:
# api = OmniAPI()
# if your environment variables are stored in an alternative location
# api = OmniAPI(env_file='<<path_to_custom_env>>')
# Run the query and get a table
table = api.run_query_blocking(query)
# Convert the table to a Pandas DataFrame
df = table.to_pandas()
# Display the first few rows of the DataFrame
print(df.head())
To run the example, you need to replace your_api_key, your_domain, and your_model_id with your own values.
To get a query object, you can use the Inspector on a Omni Workbook. The query object is a JSON object that represents the query you want to run. You can find the Inspector in the View menu on a Workbook. Look for the "Query Structure" section.
For a simple command line interface, you can run the following command:
python3 examples/query.py OMNI_API_KEY https://OMNI_URL '{"query": {"sorts": [{"column_name": "omni_dbt__order_items.created_at[date]", "sort_descending": false}], "table": "omni_dbt__order_items", "fields": ["omni_dbt__order_items.created_at[date]", "omni_dbt__order_items.total_sale_price"], "modelId": "OMNI_MODEL_ID", "join_paths_from_topic_name": "order_items"}}
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 omni_python_sdk-0.1.11.tar.gz.
File metadata
- Download URL: omni_python_sdk-0.1.11.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64a16fdcfc6aa7da4574b2e0b9a287bb81e79a1dfc6212dbba854da694887a22
|
|
| MD5 |
104f1273aa738a58dd9f6ef6091bf577
|
|
| BLAKE2b-256 |
b6832067a9ee66c7190ab80da1431d05ee96eb38611d4a4b952ac4c3b0fb85cd
|
Provenance
The following attestation bundles were made for omni_python_sdk-0.1.11.tar.gz:
Publisher:
python-publish.yml on exploreomni/omni-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
omni_python_sdk-0.1.11.tar.gz -
Subject digest:
64a16fdcfc6aa7da4574b2e0b9a287bb81e79a1dfc6212dbba854da694887a22 - Sigstore transparency entry: 240879956
- Sigstore integration time:
-
Permalink:
exploreomni/omni-python-sdk@64d7f642103c0102155ff0958bbfadda6ede2da9 -
Branch / Tag:
refs/tags/0.1.11 - Owner: https://github.com/exploreomni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@64d7f642103c0102155ff0958bbfadda6ede2da9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file omni_python_sdk-0.1.11-py3-none-any.whl.
File metadata
- Download URL: omni_python_sdk-0.1.11-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9514cc1a872181f0f5ce87a562238e103b8c92ee5fd12357a3cafb76cff7723c
|
|
| MD5 |
45c6a682581315490da797dbfc24735d
|
|
| BLAKE2b-256 |
8de347557fe1dcfa6961dc12b2ce763383627f3ac77ac3952fb676bc63ece9b8
|
Provenance
The following attestation bundles were made for omni_python_sdk-0.1.11-py3-none-any.whl:
Publisher:
python-publish.yml on exploreomni/omni-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
omni_python_sdk-0.1.11-py3-none-any.whl -
Subject digest:
9514cc1a872181f0f5ce87a562238e103b8c92ee5fd12357a3cafb76cff7723c - Sigstore transparency entry: 240879964
- Sigstore integration time:
-
Permalink:
exploreomni/omni-python-sdk@64d7f642103c0102155ff0958bbfadda6ede2da9 -
Branch / Tag:
refs/tags/0.1.11 - Owner: https://github.com/exploreomni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@64d7f642103c0102155ff0958bbfadda6ede2da9 -
Trigger Event:
release
-
Statement type: