Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mharrisb1/cube-http-client
Pythonic HTTP client for Cube.js REST API (sync + async)
https://github.com/mharrisb1/cube-http-client
cube cubejs python
Last synced: 20 days ago
JSON representation
Pythonic HTTP client for Cube.js REST API (sync + async)
- Host: GitHub
- URL: https://github.com/mharrisb1/cube-http-client
- Owner: mharrisb1
- License: mit
- Created: 2024-07-30T20:38:40.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-10-09T18:47:57.000Z (4 months ago)
- Last Synced: 2025-01-16T01:37:24.757Z (28 days ago)
- Topics: cube, cubejs, python
- Language: Python
- Homepage:
- Size: 66.4 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cube-http-client
Pythonic HTTP client for [Cube.dev](https://cube.dev) REST API (sync + async support)
## Installation
[![PyPI version](https://badge.fury.io/py/cube-http-client.svg)](https://badge.fury.io/py/cube-http-client)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cube-http-client.svg)](https://pypi.org/project/cube-http-client)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/cube-http-client)](https://pypi.org/project/cube-http-client/)Available on [PyPI](https://pypi.org/project/cube-http-client)
```bash
pip install cube-http-client
```## Quickstart
```python
import cube_httpcube = 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
```python
import cube_httpcube = cube_http.Client(...)
```### Asynchronous
```python
import cube_httpcube = cube_http.AsyncClient(...)
```### Error handling
Error classes are available for each endpoint. For example, handling an API error when calling `/v1/meta` endpoint:
```python
import cube_http
from cube_http.exc.v1 import V1MetaErrorcube = cube_http.Client(...)
try:
meta = cube.v1.meta()
except V1MetaError as e:
print(e)
```