Pythonic HTTP client for Cube.js REST API (sync + async)
Project description
cube-http-client
Pythonic HTTP client for Cube.dev REST API (sync + async support)
Installation
pip install cube-http-client
Quickstart
import cube_http
cube = cube_http.Client({"url": "...", "token": "..."})
# get metadata
meta = cube.v1.meta()
# load query results
results = cube.v1.load({
"measures": ["..."],
"dimensions": ["..."],
})
# compile to SQL
compiled_sql = cube.v1.sql({
"measures": ["..."],
"dimensions": ["..."],
})
Support Coverage
Endpoint | Description | Supported? |
---|---|---|
/v1/load |
Get the data for a query. | ✅ |
/v1/sql |
Get the SQL Code generated by Cube to be executed in the database. | ✅ |
/v1/meta |
Get meta-information for cubes and views defined in the data model. Information about cubes and views with public: false will not be returned. |
✅ |
/v1/run-scheduled-refresh |
Trigger a scheduled refresh run to refresh pre-aggregations. | ❌ |
/v1/pre-aggregations/jobs |
Trigger pre-aggregation build jobs or retrieve statuses of such jobs. | ❌ |
/readyz |
Returns the ready state of the deployment. | ❌ |
/livez |
Returns the liveness state of the deployment. This is confirmed by testing any existing connections to dataSource. If no connections exist, it will report as successful. | ❌ |
Usage
Synchronous
import cube_http
cube = cube_http.Client(...)
Asynchronous
import cube_http
cube = cube_http.AsyncClient(...)
Error handling
Error classes are available for each endpoint. For example, handling an API error when calling /v1/meta
endpoint:
import cube_http
from cube_http.exc.v1 import V1MetaError
cube = cube_http.Client(...)
try:
meta = cube.v1.meta()
except V1MetaError as e:
print(e)
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
cube_http_client-0.3.5.tar.gz
(12.4 kB
view details)
Built Distribution
File details
Details for the file cube_http_client-0.3.5.tar.gz
.
File metadata
- Download URL: cube_http_client-0.3.5.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50025960cba7c0d9ca7e6197055aaf0eb68485c6ed38f0010cb12a377f5ef0f8 |
|
MD5 | 9fe07a57c9535102c6123d7c0def0a6b |
|
BLAKE2b-256 | ba666a8bf07f959a76f8de66127c7edf1191dab4b1b3f1969fdddefa1709ea0e |
File details
Details for the file cube_http_client-0.3.5-py3-none-any.whl
.
File metadata
- Download URL: cube_http_client-0.3.5-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d48dfed4204d53d3a8987c71af5ef30eb24708c5f336a952693b1fafc399338 |
|
MD5 | a610ff93e0bf71ffac00d68bcf3b5044 |
|
BLAKE2b-256 | a45a6da270e49030e98d7209b13e790eb25ad9997db0d0f97ffd0c6595215dee |