Skip to main content

RevTurbine SDK — Python

Headless, in-memory entitlement and placement decisioning for Python services. RevTurbineCustomerSdk (plan 33 TASK-7) decides in-process from a caller-supplied user context + ExportedConfig snapshot — no network, no persistence beyond memory. Its decision output is byte-identical to the canonical TypeScript LocalRuntime (cross-language parity is gate-enforced via revturbine-sdk-internal/tests/parity/).

Full docs: the published Astro docs site — Getting Started → Python SDK (source: pages-build/src/content/docs/getting-started/python.mdx).

Install

Published on PyPI as revturbine. Requires Python ≥ 3.10.

pip install revturbine

Releases are tag-driven and version-locked with @revturbine/sdk — the same version number always ships for both. (Contributors developing in this repo use the editable install under Local development instead. The old GitHub-Release distribution on the now-archived revt-eng/revturbine-external is retired.)

Quick start

import json
from revturbine import RevTurbineCustomerSdk

with open("playbook.json") as f:
    exported_config = json.load(f)

sdk = RevTurbineCustomerSdk(
    user_context={"tenant_id": "tenant_abc", "user_id": "user_123", "plan_handle": "pro"},
    exported_config=exported_config,
)

if not sdk.check_entitlement("advanced_analytics")["allowed"]:
    raise PermissionError("not entitled")

decision = sdk.get_placement_decision(
    {"placement_id": "pl_dashboard_upsell", "user_id": "user_123"}
)

Public API

  • RevTurbineCustomerSdk(*, user_context, exported_config) — keyword-only; user_context requires tenant_id + user_id (optional plan_handle, plan_name, usage). Stateless / in-memory — no storage parameter.
  • check_entitlement(handle, context=None) -> EntitlementCheckResult
  • can(handle, context=None) — the advertised alias of check_entitlement (same canonical/alias pair as the scaffold SDK function surface and the server-node port)
  • get_placement_decision(input) -> PlacementDecision
  • get_placement_decisions(inputs) -> list[PlacementDecision]

That is the entire public surface. Browser/full-SDK concerns (React, hooks, HTTP/dual-mode, decision cache, segment/targeting derivation, identify/dismiss/snooze/convert/get_trial_status/capture/…) are intentionally not ported — plan 33 REQ-14 non-goals.

Project layout

server-python/
├── pyproject.toml          ← package metadata + tool config (ruff, mypy, pytest)
├── tox.ini                 ← test/lint/type matrix
├── .pre-commit-config.yaml ← ruff + mypy hooks (scoped to this dir)
├── src/revturbine/         ← the headless SDK (sdk.py + core/ port)
├── revturbine_server/      ← legacy thin-RPC client (see below)
└── tests/                  ← pytest suite (incl. tests/test_public_api.py)

Legacy revturbine_server

A historical thin-RPC HTTP client (from revturbine_server import RevTurbineServer) also ships in this package. It is independent of and unrelated to RevTurbineCustomerSdk — not folded in, not a dual-mode of it. It currently depends on an unmaintained generated revturbine.types module (plan REQ-4 / TASK-2) and is not standalone-importable until that generator lands. Prefer RevTurbineCustomerSdk for all new server integrations.

Local development

pip install -e ".[dev]"
pytest                  # unit + smoke + parity-contract tests
mypy                    # strict type-check of src/ and tests/
ruff check src tests    # lint (CI scope)
ruff format --check src tests
tox                     # full matrix (py310–py313 + lint + type)

Cross-language parity (run from the SDK repo root):

node scripts/run-parity.mjs   # TS + Python runners, byte-diff (the gate)

Dependencies

  • Runtime: pydantic>=2.0.
  • Stdlib only otherwise. The legacy revturbine_server client uses only urllib / json / uuid (plus the unmaintained generated-types import noted above).

Download files

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

Source Distribution

revturbine-0.2.67.tar.gz (217.8 kB view details)

Uploaded Source

Built Distribution

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

revturbine-0.2.67-py3-none-any.whl (242.2 kB view details)

Uploaded Python 3

File details

Details for the file revturbine-0.2.67.tar.gz.

File metadata

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

File hashes

Hashes for revturbine-0.2.67.tar.gz
Algorithm Hash digest
SHA256 0b0e7d3532faf2803eed0a7299d260447345e53a89a379130259b2ba41dadeb0
MD5 0af604cb0dc434a63415eede08b06377
BLAKE2b-256 c9fa1369ce769dfbd24d8974270ca28c64d5a5e0636565a53ef52a670512751b

See more details on using hashes here.

Provenance

The following attestation bundles were made for revturbine-0.2.67.tar.gz:

Publisher: release-pypi.yml on revt-eng/revturbine-sdk

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

File details

Details for the file revturbine-0.2.67-py3-none-any.whl.

File metadata

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

File hashes

Hashes for revturbine-0.2.67-py3-none-any.whl
Algorithm Hash digest
SHA256 12054f396168b9a368a2fc3306d667f774f40cde7d4adfb4bd8c99cf40e5f00a
MD5 4702d2305db4497f3ec5c0b5c2c8cff1
BLAKE2b-256 c164b10087fca71ab1c9ff3aad1fd6a1f70520e3f824d1b84b529dadd7560aba

See more details on using hashes here.

Provenance

The following attestation bundles were made for revturbine-0.2.67-py3-none-any.whl:

Publisher: release-pypi.yml on revt-eng/revturbine-sdk

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

Release history Release notifications | RSS feed

Supported by

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