Skip to main content

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

PyPI version PyPI - Python Version PyPI - Downloads

Available on PyPI

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.7.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

cube_http_client-0.3.7-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file cube_http_client-0.3.7.tar.gz.

File metadata

  • Download URL: cube_http_client-0.3.7.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Darwin/23.5.0

File hashes

Hashes for cube_http_client-0.3.7.tar.gz
Algorithm Hash digest
SHA256 b11c5e301d8c8284417d99086eaf5b22c1e82c57a39111665e25216b2ab7c5eb
MD5 925a1e7afe1ec3678db0bbcfce833739
BLAKE2b-256 b1c718195b65b9e63e84c6163f1c261c16f4b28f438b4a873d4ccc6e17492d88

See more details on using hashes here.

File details

Details for the file cube_http_client-0.3.7-py3-none-any.whl.

File metadata

File hashes

Hashes for cube_http_client-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 1bcc28c7d064eb39965906c994be20a90ba7b8464f5356552951f6695b60e4c6
MD5 41b3ba2b5793fd554d40044a37a7c964
BLAKE2b-256 e92850d6cdff5e370e972809650c98fcb02c5fbba41972e23c7a834e882206c4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page