Unofficial async Python client for the SAP Datasphere automation APIs.
Project description
Datasphere-API
Unofficial async Python client for the SAP Datasphere automation APIs. This library powers the SAP-Datasphere-CLI and can be used to build your own automations (e.g. MCP servers or scheduled jobs).
[!NOTE] This project is not affiliated with, endorsed by, or supported by SAP. It uses the same internal HTTP endpoints as the SAP Datasphere web UI, which may change without notice.
Features
- Views: export view analytics (persistence candidates), search views by attribute, persist/unpersist views, create/remove partitions, lock/unlock partitions.
- Remote Tables: list tables with statistics information, create/update statistics (Record Count / Simple / Histogram), refresh statistics.
- Task Chains: run task chains and wait for their completion.
- Analytical Models: export models with all their views (optionally per space), measure view persistence runtimes.
- OAuth login included: interactive authorization code flow via a real Chrome/Edge window (Playwright) with automatic token refresh and a shared token cache.
Installation
uv add datasphere-api
# or
pip install datasphere-api
The interactive login drives an installed Chrome or Edge browser via
Playwright channels — a regular Chrome/Edge installation is required,
no playwright install download is needed.
Quickstart
import asyncio
from datasphere_api import DatasphereClient, DatasphereConfig
async def main() -> None:
config = DatasphereConfig(
base_url="https://example.eu10.hcs.cloud.sap",
authorization_url=(
"https://example.authentication.eu10.hana.ondemand.com"
"/oauth/authorize"
),
token_url=(
"https://example.authentication.eu10.hana.ondemand.com"
"/oauth/token"
),
client_id="...",
client_secret="...",
)
client = DatasphereClient(config)
try:
await client.login()
results = await client.task_chains.run(
chains=[{"entity": "MY_CHAIN", "space": "MY_SPACE"}],
)
print(results)
finally:
await client.aclose()
asyncio.run(main())
The URLs and credentials can be found in your tenant under
System > Administration (Tenant Links and App Integration). The OAuth
client has to be of type "Interactive Usage" with the redirect URI
http://localhost:8080.
Authentication
client.login() first tries to refresh cached tokens from the token
store (session.json in the user data directory of Datasphere). If no
tokens are cached or the refresh fails, a browser window opens for the
interactive login. All consumers of this library share the same token
cache, so a login in one tool also benefits the others.
Layered results
The library returns data on two levels:
- Curated results (recommended): high-level operations like
views.persist_views()orremote_tables.create_statistics()return small, typed result structures (seedatasphere_api.models). Their keys intentionally match the CSV/JSON exports of the CLI. - Raw payloads: low-level fetchers like
views.get_all_views()orremote_tables.get_all_tables()return the parsed API payload, typed with broad TypedDicts. For anything not covered,client.sessionis the authenticatedhttpx.AsyncClient— you can call any endpoint directly.
Long-running batch operations accept an on_result/on_update
callback that is invoked after every finished item, so consumers can
save intermediate results during runs that take hours.
Development
uv sync
uv run pytest
uv run ruff check .
uv run pyright
License
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 datasphere_api-0.1.0.tar.gz.
File metadata
- Download URL: datasphere_api-0.1.0.tar.gz
- Upload date:
- Size: 50.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39402735a51ee5e8c83b9c5a467b6f28b029f93d1a4b7d3b90961ba81bda5d00
|
|
| MD5 |
b2102d3823aa60b32ec6f7c216345eab
|
|
| BLAKE2b-256 |
0769209eec5ba23854507884e94bf23d355907dc195088d403d69242256f9b1d
|
Provenance
The following attestation bundles were made for datasphere_api-0.1.0.tar.gz:
Publisher:
release.yml on peterschwps/SAP-Datasphere-API
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasphere_api-0.1.0.tar.gz -
Subject digest:
39402735a51ee5e8c83b9c5a467b6f28b029f93d1a4b7d3b90961ba81bda5d00 - Sigstore transparency entry: 2104509867
- Sigstore integration time:
-
Permalink:
peterschwps/SAP-Datasphere-API@b9d5e81c020612ecb922387a96d08fb370d17ae8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/peterschwps
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b9d5e81c020612ecb922387a96d08fb370d17ae8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file datasphere_api-0.1.0-py3-none-any.whl.
File metadata
- Download URL: datasphere_api-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.6 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 |
f20ad71f166cf540016f33f6493d408edd78d96e3ef94d977d0f0c0687adc8cb
|
|
| MD5 |
7656fa1c5aa12a5be2d63851ddaeb4ff
|
|
| BLAKE2b-256 |
95186863ccd73b0bd1dda1084666a88045dfa54887c781c701d8232c897be0b8
|
Provenance
The following attestation bundles were made for datasphere_api-0.1.0-py3-none-any.whl:
Publisher:
release.yml on peterschwps/SAP-Datasphere-API
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasphere_api-0.1.0-py3-none-any.whl -
Subject digest:
f20ad71f166cf540016f33f6493d408edd78d96e3ef94d977d0f0c0687adc8cb - Sigstore transparency entry: 2104510064
- Sigstore integration time:
-
Permalink:
peterschwps/SAP-Datasphere-API@b9d5e81c020612ecb922387a96d08fb370d17ae8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/peterschwps
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b9d5e81c020612ecb922387a96d08fb370d17ae8 -
Trigger Event:
push
-
Statement type: