Skip to main content

Unofficial async Python client for the SAP Datasphere automation APIs.

Project description

Datasphere-API

CI PyPI Python

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() or remote_tables.create_statistics() return small, typed result structures (see datasphere_api.models). Their keys intentionally match the CSV/JSON exports of the CLI.
  • Raw payloads: low-level fetchers like views.get_all_views() or remote_tables.get_all_tables() return the parsed API payload, typed with broad TypedDicts. For anything not covered, client.session is the authenticated httpx.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

MIT

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

datasphere_api-0.1.1.tar.gz (58.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datasphere_api-0.1.1-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file datasphere_api-0.1.1.tar.gz.

File metadata

  • Download URL: datasphere_api-0.1.1.tar.gz
  • Upload date:
  • Size: 58.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for datasphere_api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3f5e1d7eabd8ba49ad5586e0ffb2858e557f0b4918f7e540448d96977f89f2e8
MD5 a2c1f20803e6f5d4c2df1fc801c40551
BLAKE2b-256 daf0f79bb4ba43d26e5fc34f7decdce43a133017f3c2debc12139c8caaefe29e

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasphere_api-0.1.1.tar.gz:

Publisher: release.yml on peterschwps/SAP-Datasphere-API

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file datasphere_api-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: datasphere_api-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for datasphere_api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 099d2d47b481c7376cd8dd80d39a19662a44e06dd89e200c7613f3c164ecd2f5
MD5 220b94081b94be0e7c83998e06910d9c
BLAKE2b-256 161ba65f6f21962fb1b9e5c84d6e1e251dc576c38730df6442f4ab74d22c6573

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasphere_api-0.1.1-py3-none-any.whl:

Publisher: release.yml on peterschwps/SAP-Datasphere-API

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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