Skip to main content

Python bindings for Redis Enterprise REST API client

Project description

redis-enterprise Python bindings

Python bindings for the Redis Enterprise REST API, built with PyO3 on top of the redis-enterprise Rust crate.

Scope and philosophy

Goals

  • Convenience, not parity. The Python layer exposes the most common read and inspection operations — cluster info, database listing, node status, user listing — plus raw HTTP access for anything else.
  • Sync and async. Every named method ships as both a blocking _sync variant and an async/await coroutine so it fits naturally in scripts, notebooks, or async applications.
  • Plain Python dicts. All responses are deserialized to Python dict/list (via serde_json). No custom model classes to learn; use SimpleNamespace, pydantic, or dataclasses as you prefer.
  • Zero required event loop. The _sync variants drive a dedicated Tokio runtime internally, so they work from plain Python scripts or Jupyter notebooks without any asyncio setup.

Non-goals

  • Full API parity with the Rust crate. Write operations (database create/update/ delete), CRDB management, module uploads, and so on are outside the initial scope.
  • Typed response models. Raw dicts keep the binding thin and avoid a maintenance burden on the Python side.
  • Re-exporting every Rust builder knob. For advanced configuration use the Rust crate directly.

Installation

pip install redis-enterprise

Requires Python ≥ 3.9. Wheels are published for Linux (x86_64, aarch64), macOS (x86_64, arm64), and Windows (x86_64) via the publish-python CI workflow.


Quick start

from redis_enterprise import EnterpriseClient

# Explicit configuration
client = EnterpriseClient(
    base_url="https://cluster.example.com:9443",
    username="admin@redis.local",
    password="secret",
    insecure=True,       # skip TLS verification — dev/lab only
    timeout_secs=30,     # optional; omit to use the default
)

# Or let the client read credentials from environment variables
client = EnterpriseClient.from_env()

# ── Synchronous ──────────────────────────────────────────────
cluster = client.cluster_info_sync()
print(cluster["name"])

dbs = client.databases_sync()
for db in dbs:
    print(db["name"], db["uid"])

# ── Async ────────────────────────────────────────────────────
import asyncio

async def main():
    cluster = await client.cluster_info()
    print(cluster["name"])

asyncio.run(main())

API reference

All methods return plain Python dict or list[dict].

Constructor

Signature Description
EnterpriseClient(base_url, username, password, insecure=False, timeout_secs=None) Build a client explicitly
EnterpriseClient.from_env() Read credentials from environment variables (see Environment variables)

Cluster

Async Sync Returns Description
cluster_info() cluster_info_sync() dict Cluster name, version, and topology summary
cluster_stats() cluster_stats_sync() dict Cluster-level performance counters
license() license_sync() dict License details (expiry, limits, active features)

Databases

Async Sync Returns Description
databases() databases_sync() list[dict] All databases (BDBs) on the cluster
database(uid) database_sync(uid) dict Single database by numeric UID

Nodes

Async Sync Returns Description
nodes() nodes_sync() list[dict] All nodes in the cluster
node(uid) node_sync(uid) dict Single node by numeric UID

Users

Async Sync Returns Description
users() users_sync() list[dict] All users configured on the cluster

Raw HTTP access

Use the raw pass-through methods for any endpoint not yet covered by a named method. Paths are relative to the cluster base URL (e.g. "/v1/bdbs").

# GET
roles = client.get_sync("/v1/roles")

# POST — body is a plain Python dict
new_role = client.post_sync(
    "/v1/roles",
    {"name": "ops-reader", "management": "db_viewer"},
)

# DELETE
client.delete_sync(f"/v1/roles/{role_id}")

# Async equivalents
roles = await client.get("/v1/roles")
new_role = await client.post(
    "/v1/roles",
    {"name": "ops-reader", "management": "db_viewer"},
)
await client.delete(f"/v1/roles/{role_id}")
Async Sync Signature Description
get(path) get_sync(path) path: str Raw GET — returns parsed JSON as dict or list
post(path, body) post_sync(path, body) path: str, body: dict Raw POST — body is serialized to JSON
delete(path) delete_sync(path) path: str Raw DELETE — returns parsed JSON response

Error handling

from redis_enterprise import EnterpriseClient, RedisEnterpriseError

try:
    db = client.database_sync(9999)
except ValueError:
    print("Database not found")
except RedisEnterpriseError as e:
    print(f"API error: {e}")
except ConnectionError as e:
    print(f"Could not reach cluster: {e}")
Rust error variant Python exception Typical cause
ConnectionError ConnectionError Network unreachable, DNS failure, TLS handshake error
AuthenticationFailed RedisEnterpriseError Wrong credentials
Unauthorized RedisEnterpriseError Valid credentials but insufficient privilege
NotFound ValueError UID or path does not exist on the cluster
ValidationError ValueError Malformed request body or invalid parameter
Other RuntimeError Unexpected server-side or deserialization error

RedisEnterpriseError is a custom exception class exported by the module and is a subclass of Exception.


Planned expansion — first tranche

The following operations are targeted for the next minor release:

Method Description
node_stats(uid) / node_stats_sync(uid) Per-node performance counters
database_stats(uid) / database_stats_sync(uid) Per-database performance counters
roles() / roles_sync() RBAC role listing
put(path, body) / put_sync(path, body) Raw PUT for the HTTP pass-through layer

Mutation operations (database create/update/delete, user management) are under consideration for a subsequent tranche but are not committed.


Testing strategy

Unit tests live in python/tests/ and use pytest + pytest-asyncio. Integration tests require a live Redis Enterprise cluster; see the live-validation runbook for standing one up with Docker Compose.

# Install dev extras
pip install -e "python/[dev]"

# Unit tests (no cluster required)
pytest python/tests/unit/

# Integration tests (cluster required — see docs/live-validation.md)
pytest python/tests/integration/

Release and packaging

The publish-python GitHub Actions workflow fires on version tags (v*). It uses maturin to compile the PyO3 extension module for each supported platform and architecture, then publishes the wheels and an sdist to PyPI.

The Python package version is derived from python/Cargo.toml, which is kept in sync with the root crate version.


Environment variables

These variables are read by EnterpriseClient.from_env():

Variable Default Description
REDIS_ENTERPRISE_URL https://localhost:9443 Cluster base URL
REDIS_ENTERPRISE_USER (required) Username
REDIS_ENTERPRISE_PASSWORD (required) Password
REDIS_ENTERPRISE_INSECURE false Set true to skip TLS certificate verification (dev/lab only)
REDIS_ENTERPRISE_CA_CERT (optional) Path to a custom CA certificate PEM file

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

redis_enterprise-0.9.1.tar.gz (232.2 kB view details)

Uploaded Source

Built Distributions

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

redis_enterprise-0.9.1-cp39-abi3-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.9+Windows x86-64

redis_enterprise-0.9.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

redis_enterprise-0.9.1-cp39-abi3-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file redis_enterprise-0.9.1.tar.gz.

File metadata

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

File hashes

Hashes for redis_enterprise-0.9.1.tar.gz
Algorithm Hash digest
SHA256 89206186acf03c8dce7e729de733c993bea8aaa4e626f2fc60f259f79cf93cbf
MD5 1eba02d71253259c6490e7dbb15d5df1
BLAKE2b-256 3f7b1b3f3e2e11c57cdde90cb08e5e74757202bcad800c0c0c32555df5a93479

See more details on using hashes here.

Provenance

The following attestation bundles were made for redis_enterprise-0.9.1.tar.gz:

Publisher: python.yml on redis-developer/redis-enterprise-rs

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

File details

Details for the file redis_enterprise-0.9.1-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for redis_enterprise-0.9.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 38dfa0068cfba4df7e5478befbca2b753f0fdff9da7eaf8279fbcd57897dd30b
MD5 26f5aaab09f432e6443854bf45e6ec35
BLAKE2b-256 26aa139f53bc5a6a725c1ac54a732abfa051f924171aa084f059719c7867b069

See more details on using hashes here.

Provenance

The following attestation bundles were made for redis_enterprise-0.9.1-cp39-abi3-win_amd64.whl:

Publisher: python.yml on redis-developer/redis-enterprise-rs

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

File details

Details for the file redis_enterprise-0.9.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for redis_enterprise-0.9.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d8587ca351da55f21f8ac87a16c518064b5471bbe0eee36277673a81d0c4563a
MD5 7649a7cafba76240cc326a179427f82f
BLAKE2b-256 7953ca27e936a6415baede0045b4b2cc3aadafe765865c4a527150857c925fdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for redis_enterprise-0.9.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python.yml on redis-developer/redis-enterprise-rs

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

File details

Details for the file redis_enterprise-0.9.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for redis_enterprise-0.9.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80103560fcf01045175c0c875e106d314b2e309e9b62806959772d429eeeaf43
MD5 1e34db190cc4ad2d95719608a118b3e8
BLAKE2b-256 d8066b86bf99c5bbaeff850e548c8066f17c995d6152dc6f023c156bc275e5cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for redis_enterprise-0.9.1-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: python.yml on redis-developer/redis-enterprise-rs

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