Skip to main content
For the complete documentation index optimized for AI agents, see llms.txt.
Queries for HelixDB can be authored directly in Python with the helix-db package, imported as helixdb. The Python SDK pairs a query-builder DSL with a small sync HTTP client. The API is Pythonic (read_batch, write_batch, var_as, value_map) and emits the same dynamic-query JSON AST as the Rust, TypeScript, and Go SDKs. For the traversal model and query patterns themselves, see Querying and the Querying Guide.

Prerequisites

  • Python 3.10 or later.
  • Optional: uv for fast environment and dependency management.
  • Optional: the Helix CLI for local development and ad-hoc query testing.

Create a project

Add the dependency

Install the helix-db package from PyPI.
Import the SDK from helixdb:
A compatibility import path, helix_db, is also available for codebases that prefer underscore package names. With uv, run your script through the managed environment:

Write query functions

Python query builders are normal functions returning ReadBatch or WriteBatch. Use define_params for runtime values and pass the returned refs into predicates, limits, property inputs, search inputs, and mutations.
Direct values are serialized as literals in the query AST. That is useful for true constants, but values that change per request should be declared as params so the query shape stays stable and the server can reuse cached work across requests.

Build dynamic requests

A batch becomes a dynamic request with to_dynamic_request(...) or to_dynamic_json(...):
The request includes request_type, query_name, query, parameters, and parameter_types, ready to POST to /v1/query.

Execute queries

Create the client once and reuse it:
For Helix Cloud, pass the cluster URL and API key:
Use request-builder options when a write must hit the writer node or wait for durability:
Warm read-query caches with warm_only():
Stored routes post to /v1/query/{name}:

Write queries

read_batch().var_as(...) rejects write traversals. Use write_batch() for any node/edge creation, property update/removal, drop, or index mutation.

Bundles

Python can also generate query bundles:
Route names must be unique across read and write routes. Bundles serialize with version 4, matching the other SDKs.

Handle conflicts in application code

The Python client does not retry HTTP 409 Conflict responses automatically. Retry only when the operation is safe to replay. Remote errors are raised as HelixError with kind == "Remote", details, and status_code populated.

Next Steps

Querying

Dynamic query envelopes, client execution, and transactions.

Parameters & bundles

Parameter serialization across TypeScript, Rust, Go, and Python.

Local Development

Run HelixDB locally while developing queries.

Python SDK source

Python package source and README.