Skip to main content

sanka-sdk

Python SDK for Sanka's hosted API and local migration lifecycle.

This package is generated from Sanka's OpenAPI spec using Fern, then packaged locally for uv and PyPI.

Install

Python 3.9 or newer is required. CI tests every minor from Python 3.9 through Python 3.14.

uv add sanka-sdk

Hosted API

from sanka_sdk import SankaClient

client = SankaClient(token="YOUR_TOKEN")
response = client.public_auth.whoami()
print(response)

SankaClient calls Sanka's hosted HTTP API and requires a token. Extension management is part of the local migration runtime described below; it is not a hosted API resource.

Local migration runtime

The hosted API client and local migration adapter are separate surfaces:

Import What runs Authentication
from sanka_sdk import SankaClient Sanka's hosted HTTP API API token
SankaMigrate or AsyncSankaMigrate from sanka_sdk.migrate A local sanka subprocess None

Install the runtime separately. Installing sanka-sdk does not install or authenticate sanka.

uv tool install sanka-cli

Use a runtime release that includes the extension marketplace commands and the published default DRF extension dependency.

Configure an extension, scan, and plan

Add the official marketplace and lock the extension before the first scan. Marketplace snapshots are user-scoped; the extension lock belongs to the project in cwd.

from sanka_sdk.migrate import SankaMigrate

migrate = SankaMigrate(cwd="./django-app")

migrate.extensions.marketplaces.add(
    "git@github.com:sankaHQ/extensions.git",
    name="sanka",
)
migrate.extensions.add("sanka/drf-to-fastapi", marketplace="sanka")

scan = migrate.scan()
plan = migrate.plan(
    to="fastapi",
    extension_config={
        "generation": "minimal",
        "output": "./fastapi-app",
        "package_manager": "uv",
        "strategy": "native",
    },
    extension_environment=("DJANGO_SECRET_KEY",),
)
applied = migrate.apply(plan_hash=plan.data["plan_hash"])
tested = migrate.test()
verified = migrate.verify()

scan.data["recommendations"] contains the selected extension, its target, matching evidence, and install status. When the exact default package is already installed and has not been disabled, sanka can lock it on the first scan. Otherwise, if no matching extension is enabled, the command stops with SANKA_EXTENSION_REQUIRED. The error details contain the recommendations and exact add_command; the SDK does not bypass the runtime's selection and trust checks.

extension_config accepts JSON-compatible values and is serialized as stable, sorted JSON. extension_environment accepts environment variable names, not secret values. sanka forwards only those named values to the selected extension. Both options are available on scan(), plan(), apply(), test(), and verify().

Manage extensions and marketplaces

extensions = migrate.extensions

installed = extensions.list()
extensions.add("example/demo", marketplace="partner")
extensions.remove("example/demo")

marketplaces = extensions.marketplaces
marketplaces.add(
    "https://github.com/example/sanka-extensions.git",
    name="partner",
    trust=True,
)
marketplaces.list()
marketplaces.upgrade("partner")  # Omit the name to upgrade all marketplaces.
marketplaces.remove("partner")

The Python methods map directly to these local commands:

Python method sanka command
extensions.list() extension list --json
extensions.add(id, marketplace=...) extension add ID --marketplace NAME --json
extensions.remove(id) extension remove ID --json
extensions.marketplaces.list() extension marketplace list --json
extensions.marketplaces.add(source, name=..., trust=True) extension marketplace add SOURCE --name NAME --trust --json
extensions.marketplaces.upgrade(name) extension marketplace upgrade NAME --json
extensions.marketplaces.remove(name) extension marketplace remove NAME --json

trust=True is an explicit operator decision. The SDK only passes --trust. sanka owns source identity checks, immutable marketplace snapshots, artifact verification, project locks, extension installation, upgrades, and removal safety. An untrusted source fails with SANKA_MARKETPLACE_TRUST_REQUIRED; the SDK does not bypass that check.

Async adapter

Use AsyncSankaMigrate to run the same commands without blocking the event loop. Its lifecycle, extension, and marketplace methods have the same arguments and results as the synchronous adapter. Cancelling an awaited command kills and reaps its local CLI process.

import asyncio

from sanka_sdk.migrate import AsyncSankaMigrate


async def main() -> None:
    migrate = AsyncSankaMigrate(cwd="./django-app")

    scan = await migrate.scan()
    await migrate.extensions.list()
    plan = await migrate.plan(to="fastapi")
    await migrate.apply(plan_hash=plan.data["plan_hash"])
    await migrate.test()
    await migrate.verify()


asyncio.run(main())

Each method maps directly to the local runtime:

Python method Runtime command Purpose
scan() sanka scan ... --json Inspect the source and write the scan artifact
plan() sanka plan ... --json Create a reviewable plan and plan hash
apply() sanka apply ... --json Generate only from the supplied reviewed plan hash
test() sanka test ... --json Prepare the generated target environment and run its tests
verify() sanka verify ... --json Verify integrity and configured behavior

Results, failures, and subprocess safety

Both adapters execute an argv list without a shell and never call Sanka's hosted API. Arguments such as marketplace URLs, paths, and configuration values are not interpreted as shell commands.

Every successful call returns a typed SankaMigrateResult. The validated sanka-cli/v1 fields are schema_version, command, outcome, migration_state, data, artifacts, limitations, and next_actions. ScanData, ExtensionRecommendation, ExtensionEvidence, and ExtensionFailure describe the extension-specific data available to type checkers and IDEs.

from sanka_sdk.migrate import SankaMigrateError

try:
    migrate.extensions.marketplaces.add("./third-party", name="third-party")
except SankaMigrateError as error:
    print(error.command, error.exit_code)
    print(error.parsed_error)  # code, message, and optional details
    print(error.result)  # Complete validated failure envelope, when available.

Failures are fail-closed. The SDK rejects missing executables, malformed or non-object JSON, a schema other than sanka-cli/v1, the wrong command, invalid outcome/exit-code pairs, malformed data.error, and non-string artifact or action lists. A valid CLI failure raises SankaMigrateError with its typed result preserved. Exit 1 is a runtime failure, exit 2 is invalid usage, and any other exit code is a protocol error.

Defaults, framework detection, marketplace trust, immutable snapshots, extension subprocess execution, generated-target environments, and plan-hash safety remain in sanka. The SDK is a typed local adapter, not a second migration runtime.

See the CLI execution model and Sanka developer documentation.

Regenerate

./scripts/generate_sdk.sh

Publish

This repo includes a GitHub Actions workflow for PyPI Trusted Publishing at .github/workflows/publish.yml.

Configure a Trusted Publisher on PyPI for:

  • owner: sankaHQ
  • repository: sanka-python
  • workflow: .github/workflows/publish.yml
  • environment: pypi

Then publish by pushing a tag like vX.Y.Z or running the workflow manually.

Developer Cloud release candidate: bounded execution, Repair, certificates and Fleet.

For a worktree or pinned SDK contract, regenerate with SANKA_API_SPEC_SOURCE=/path/to/openapi.json ./scripts/generate_sdk.sh. The committed V2 input is openapi/openapi.json; no legacy runtime export runs.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sanka_sdk-0.2.7.tar.gz (252.5 kB view details)

Uploaded Source

Built Distribution

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

sanka_sdk-0.2.7-py3-none-any.whl (681.3 kB view details)

Uploaded Python 3

File details

Details for the file sanka_sdk-0.2.7.tar.gz.

File metadata

  • Download URL: sanka_sdk-0.2.7.tar.gz
  • Upload date:
  • Size: 252.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sanka_sdk-0.2.7.tar.gz
Algorithm Hash digest
SHA256 41cf2307cdc273018750067479652e1eebfef403bbe08ef4da7d9a08d95d4a8f
MD5 4f8dbebfc4bfbf51abac14a586ed2257
BLAKE2b-256 9dc7b8267b8bac79e6c74bbdfd10d1291c980a1a895a4b2759658d620143379f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sanka_sdk-0.2.7.tar.gz:

Publisher: publish.yml on sankaHQ/sanka-python

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

File details

Details for the file sanka_sdk-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: sanka_sdk-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 681.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sanka_sdk-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 405be29d3abb90760b39cd647c597cd05b07f94ec292020fd5a788cd1d58605d
MD5 de6f9597da27c848e7b6a02c12ca0341
BLAKE2b-256 92c46c3996045b0e392fbc66ece12ad34f117303f91ea036b3c2eb09c65c7f55

See more details on using hashes here.

Provenance

The following attestation bundles were made for sanka_sdk-0.2.7-py3-none-any.whl:

Publisher: publish.yml on sankaHQ/sanka-python

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

Release history Release notifications | RSS feed

This release

0.2.7 This release

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page