Client SDKs and bindings
HelixDB client integrations give application developers one way to build graph queries, send them to a HelixDB server, or run them against an embedded database. Rust, Python, TypeScript, and Go expose language-shaped APIs over a shared query contract. UniFFI connects the embedded Rust runtime and native graph support to foreign-language clients.
Shared integration model
Each SDK turns application code into a query request. The request can cross the network or stay in the application process. This keeps the query model consistent while allowing each language to use its normal naming, type, and async style.
The main path through the integrations is:
flowchart LR
App[Application code] --> SDK[Language SDK]
SDK --> DSL[Query DSL]
DSL --> Request[Shared query request]
Request --> HTTP[Server query endpoint]
Request --> Embedded[Embedded Rust database]
Embedded --> FFI[UniFFI native boundary]
HTTP --> Result[Query result or typed error]
FFI --> Result
The supported integrations serve these roles:
| Integration | Main application use | Execution choices |
|---|---|---|
| Rust SDK | Build queries with the Rust DSL and use Rust graph access | HTTP client, plus optional embedded database and native graph access |
| Python SDK | Build queries with Python methods and use sync or async clients | HTTP or embedded database; native graph access uses the native package |
| TypeScript SDK | Build typed JavaScript or TypeScript queries and use the published npm package | HTTP or embedded database; native graph access uses the separate native package |
| Go SDK | Build requests with Go types and execute them with a context | HTTP client; embedded and native graph features depend on separately linked bindings |
| UniFFI bindings | Expose the Rust embedded database and native graph object to foreign runtimes | Native calls used by Python, Node, and other generated clients |
References: sdks/…/lib.rs• L3-16 sdks/…/README.md• L1-8 sdks/…/README.md• L1-5 sdks/…/package.json• L1-16 sdks/…/README.md• L1-4 bindings/…/lib.rs• L3-12
Published package boundary
The TypeScript integration is published as @helix-db/helix-db for Node applications. The package exposes the query DSL, client, graph helpers, and type declarations as one application-facing surface. Embedded storage remains an optional native package so server use does not require native bindings.
The release checks install the packed artifact in a clean consumer. They compile against the published declarations and run requests through the installed package. The consumer also checks remote error meaning and confirms that an uncertain write is not replayed. This separates the public package contract from checks that use repository source files or native development builds.
References: sdks/…/package.json• L1-16 sdks/…/package.json• L44-66 sdks/…/package-smoke.mjs• L1-53 sdks/…/consumer.mjs• L1-15 sdks/…/consumer.mjs• L53-89 sdks/…/types.mts• L1-13
Query DSL contract
The query DSL describes graph reads and writes as a structured request. An application starts a read or write batch, builds traversals over nodes or edges, applies filters and transformations, and names the values that the server must return.
The shared query model includes:
- node and edge selection
- graph navigation and filtering
- projections and aggregates
- conditional branches and repeated traversals
- runtime parameters with type information
- index, vector search, and text search operations
- row bindings for values that must stay linked across traversals
- index lifecycle receipts and status values for asynchronous index work
The SDKs use different surface names. Python uses snake_case, TypeScript uses camelCase, Rust uses Rust builder names, and Go uses exported Go names. They still target the same query JSON AST. Typed parameters carry their schema with their values, while each SDK keeps language limits at its own boundary. In Python, immutable builders preserve prior query states and parameter values are checked before serialization. The Python DSL also validates index lifecycle receipts and status values at the client boundary. Its response checks allow additive fields while rejecting unknown variants and invalid identifiers.
The Go surface also carries search visibility choices and index lifecycle states into the shared request model. It rejects invalid combinations before serialization, which keeps language-level convenience from changing the server contract.
Python's DSL covers graph traversal, reads, writes, projections, row bindings, search, and index lifecycle actions. Its tests compare serialized request shapes and verify that invalid types, unsafe values, incomplete binding projections, invalid dates, and unknown lifecycle variants fail before an application sends a request. These checks protect the shared contract without changing the language-level query experience.
Parity generators exercise the same read, write, traversal, parameter, search, index, and binding shapes in each language. They produce comparable request fixtures so a surface change can be checked for both local validity and cross-language agreement.
Read the Rust DSL integration for the model that defines the query-building concepts. Read the language client APIs for the Python, TypeScript, and Go client surfaces.
References: sdks/…/dsl.rs• L1-19 sdks/…/dsl.py• L1-6 sdks/…/dsl.py• L100-127 sdks/…/dsl.py• L130-170 sdks/…/dsl.py• L1090-1215 sdks/…/dsl.py• L1622-1741 sdks/…/dsl.ts• L69-95 sdks/…/dsl.ts• L925-967 sdks/…/dsl.ts• L1120-1325 sdks/…/dsl.go• L32-40 sdks/…/dsl.go• L974-1328 sdks/…/dsl.go• L1331-1400 sdks/…/dsl_test.go• L969-1012 sdks/…/dsl_test.go• L1139-1181 sdks/…/generate_parity_fixtures.rs• L279-327 sdks/…/main.go• L35-87 sdks/…/parity_runtime_fixtures.py• L73-1196 sdks/…/generate-fixtures.ts• L36-69 sdks/…/test_dsl.py• L63-237 sdks/…/test_dsl.py• L366-427 sdks/…/test_dsl.py• L545-729 sdks/…/test_dsl.py• L739-798 sdks/…/basic.test.ts• L42-100
Query execution modes
Every client separates query construction from query execution. In server mode, the SDK sends the serialized request to POST /v2/query and turns the response into the requested application type. In embedded mode, the same request is passed to an in-process HelixDB handle.
The Rust and TypeScript clients also expose Cypher as a second query surface. Applications can send a Cypher statement or request a plan through the server or an embedded handle. The SDK keeps result and error handling consistent with DSL requests.
The modes have different ownership and routing behavior:
| Mode | Data access | Request controls | Lifetime |
|---|---|---|---|
| Server | Remote HelixDB instance | API keys and server routing controls such as writer-only or warm-only requests | Reuse the client for many requests |
| Embedded writer | Local or object-backed database in the process | Query execution only; server routing controls do not apply | Open, use, then close the database handle |
| Embedded reader | Existing embedded database opened for reads | Query execution only; writes are rejected by the database mode | Open for read access, then close the handle |
Server and embedded paths share query results and error intent, but their transport errors differ. Server clients report network and remote response failures. Embedded clients report native database and binding failures. A successful warm request may have no result body, so callers must not assume that every successful response contains rows. TypeScript preserves large response integers as bigint, and the Rust, Python, and Go surfaces retain their own lossless value rules at the client boundary.
The Python sync and async clients follow the same mode and error contract. The async client also closes response streams on success, failure, timeout, and cancellation so the client can be reused safely.
References: sdks/…/lib.rs• L105-171 sdks/…/lib.rs• L243-343 sdks/…/lib.rs• L378-486 sdks/…/lib.rs• L655-825 sdks/…/lib.rs• L929-1029 sdks/…/client.py• L27-107 sdks/…/async_client.py• L1-180 sdks/…/dsl.py• L112-170 sdks/…/dsl.ts• L74-81 sdks/…/index.ts• L239-355 sdks/…/index.ts• L391-454 sdks/…/client.test.ts• L224-305 sdks/…/client.test.ts• L499-583 sdks/…/client.test.ts• L585-809 sdks/…/client.test.ts• L811-906 sdks/…/test_client.py• L197-329 sdks/…/test_client.py• L471-580 sdks/…/test_async_client.py• L255-475 sdks/…/client.go• L151-193 sdks/…/client.go• L243-326
Embedded graph access
Graph access has two stages. The client first runs one ordinary read that selects nodes and edges. It then creates an immutable native graph from that result. Graph lookups, traversals, algorithms, and graph changes operate on the loaded snapshot without more database reads.
The graph load path is:
sequenceDiagram
participant A as Application
participant C as SDK client
participant D as Server or embedded DB
participant G as Native graph
A->>C: Define node and edge selection
C->>D: Run one read query
D-->>C: Projected node and edge rows
C->>G: Validate and load snapshot
G-->>A: Local graph access and algorithms
A graph selection can control direction, node and edge properties, identity fields, weights, and result limits. Full graph scans require explicit acknowledgement so an application does not load a large graph by accident. The resulting graph supports common local graph work such as neighborhood access, degrees, paths, traversal, centrality, communities, cycles, layouts, and subgraphs.
Native graph access is a separate capability from ordinary query execution. Python and TypeScript load it through their native embedded package. Rust provides the native graph path directly. The standard Go SDK declares the graph API, but its published module does not include the native bindings required to use it.
References: sdks/…/graph.rs• L1-5 sdks/…/graph.rs• L70-112 sdks/…/graph.rs• L313-335 sdks/…/graph.py• L1-5 sdks/…/graph.py• L818-850 sdks/…/graph.ts• L32-105 sdks/…/graph.ts• L357-366 sdks/…/index.ts• L330-355 sdks/…/graph.go• L34-47 sdks/…/README.md• L258-265
UniFFI binding boundary
UniFFI is the native boundary for features that foreign-language code cannot run by itself. It exposes embedded database handles, storage sources, cache profiles, graph load descriptions, graph records, graph operations, and stable error categories as FFI-safe values.
The boundary keeps Rust-owned work inside native code. Foreign clients pass query bytes or typed binding values across the boundary and receive result bytes, records, or classified errors. A dedicated Tokio runtime owns database futures. This prevents foreign callback threads from having to run database work with their own runtime or stack limits.
The binding package is not the main application API. Applications use the Python or TypeScript SDK and install the matching native package when they need embedded storage or native graph access. Generated bindings and native libraries must match the SDK adapter that loads them.
Read the UniFFI bindings page for the native interface, packaging, runtime, and error contract.
References: bindings/…/helix_db.rs• L14-36 bindings/…/helix_db.rs• L106-120 bindings/…/helix_db.rs• L148-231 bindings/…/graph.rs• L100-181 bindings/…/error.rs• L1-40 bindings/…/runtime.rs• L1-24 sdks/…/test_client.py• L471-580 sdks/…/test_async_client.py• L436-532 sdks/…/client.test.ts• L100-189 sdks/…/client.test.ts• L499-583
Integration guides
The shared page gives the system view. Use the child pages for the language or boundary that you need to change:
- Rust SDK and DSL explains query construction, HTTP execution, embedded Rust access, and native graph loading.
- Language client SDKs compares the Python, TypeScript, and Go client APIs and their language-specific behavior.
- UniFFI bindings explains the native interface used by embedded clients and graph adapters.
These pages should describe language-specific behavior only after the shared request, execution, and native graph model is clear.
References: sdks/…/lib.rs• L3-16 sdks/…/test_client.py• L197-220 sdks/…/test_async_client.py• L102-127 sdks/…/consumer.mjs• L1-5 sdks/…/client.test.ts• L9 sdks/…/dsl.go• L57-60
Change checklist
When these files or sections are changed, remember to consider these:
- When the query AST or wire names change, update the Rust, Python, TypeScript, and Go builders together. A surface API can still compile while producing a request the other SDKs cannot match.
- When a DSL value, parameter, binding, search, or index lifecycle variant changes, regenerate parity fixtures in all four SDKs. Fixture coverage must remain complete before request comparison can show a real cross-language result.
- When response envelopes or error fields change, update each client’s success decoding and stable error classification. Remote status, error code, and readable message are separate contracts.
- When Python async transport or close behavior changes, keep response streams closed on success, failure, timeout, and cancellation. A leaked stream can make a reusable client fail later.
- When JavaScript number handling or datetime rules change, check both request serialization and response parsing. Large integers and out-of-range timestamps can pass type checks while changing wire values at runtime.
- When Cypher request or plan results change, update the Rust and TypeScript server and embedded paths together. Their option guards and empty warm responses must still agree.
- When UniFFI records, enums, or exported methods change, regenerate the foreign bindings and update the Python and Node adapters that load them.
- When graph selection fields or projected graph metadata change, update every graph loader. The server response and native graph load specification must describe the same identity and topology.
- When server request controls change, preserve the mode guard. Embedded requests must not silently accept controls that only a server can enforce.
- When the TypeScript package entry point or declaration shape changes, validate the packed npm artifact in an isolated consumer. Source imports can pass while the published
distfiles or exports are incomplete.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| One SDK emits a different AST shape or field name | Equivalent application queries behave differently across languages or fail at the server | Keep the shared query contract aligned and compare generated requests across SDKs |
| A new DSL or index lifecycle variant is added to one generator but not the others | One language cannot express or safely decode the same query or status | Regenerate and compare the Rust, Go, Python, and TypeScript fixture sets together |
| A JavaScript integer exceeds the safe number range | The request or result changes value | Use the SDK’s lossless integer form such as bigint where required |
| A client treats an uncertain write as retryable | The mutation can be applied more than once | Treat explicit unknown-outcome errors as terminal and send the mutation once |
| An async response stream stays open after timeout or cancellation | Later requests on the same Python client can fail or stall | Close the response stream in every exit path |
| An embedded client receives a server-only request control | The request is rejected instead of being routed as requested | Apply writer, warm, and durability controls only to server clients |
| A graph selection starts with an unfiltered full scan without opt-in | Graph loading fails before execution or loads more data than intended | Add a filter or explicitly allow the full scan, then use node and edge limits where needed |
| The native package is missing or does not match the adapter | Embedded queries, Cypher, or native graph loading are unavailable | Install the matching native package and keep generated bindings in sync |
| A warm success is treated as a normal result response | The caller tries to decode an empty body as rows | Treat the no-content warm response as success without a query payload |
| A package is tested from repository source but the packed artifact is stale or incomplete | Consumers cannot import the public API or its declarations after release | Run the isolated package consumer and declaration checks against the packed artifact |
Key files
| File | Why to read it |
|---|---|
| sdks/…/lib.rs | Defines the Rust client boundary, server and embedded modes, DSL and Cypher execution, and shared error intent. |
| sdks/…/dsl.rs | Shows how the Rust SDK presents the shared query-building contract. |
| sdks/…/graph.rs | Shows the one-read graph load model and the native graph entry point. |
| sdks/…/client.py | Shows synchronous Python server and embedded client behavior. |
| sdks/…/async_client.py | Shows asynchronous Python execution, cancellation, response cleanup, and native runtime use. |
| sdks/…/graph.py | Shows the Python graph selection and native graph façade. |
| sdks/…/dsl.py | Defines the Python AST, typed values, immutable traversal builders, bindings, search shapes, and index lifecycle values. |
| sdks/…/test_client.py | Checks Python server errors, embedded modes, native errors, and server-only option guards. |
| sdks/…/test_async_client.py | Checks async transport cleanup, cancellation, reuse, embedded concurrency, and mode parity. |
| sdks/…/index.ts | Defines the TypeScript client, execution modes, Cypher surface, and public package entry point. |
| sdks/…/dsl.ts | Defines the TypeScript representation of the shared query AST and parameter values. |
| sdks/…/graph.ts | Defines TypeScript graph selection, loading, and local graph access. |
| sdks/…/package.json | Defines the published package entry points, supported Node runtime, and cross-SDK parity commands. |
| sdks/…/client.test.ts | Checks TypeScript routing, Cypher, embedded access, lossless values, and error behavior. |
| sdks/…/lost-response-probe.ts | Checks that an uncertain write is terminal and is not replayed. |
| sdks/…/consumer.mjs | Exercises the public package contract, error decoding, and no-replay behavior after installation. |
| sdks/…/dsl.go | Defines Go request values, typed parameters, search controls, and index lifecycle decoding. |
| sdks/…/dsl_test.go | Checks Go request shapes, lifecycle variants, error classification, and server request behavior. |
| sdks/…/client.go | Defines Go server execution, embedded construction, request controls, and errors. |
| bindings/…/helix_db.rs | Exposes embedded storage sources, handles, query execution, and close behavior. |
| bindings/…/graph.rs | Exposes FFI-safe graph records, operations, and native graph loading. |
| bindings/…/error.rs | Defines the stable error categories returned across the native boundary. |
| bindings/…/runtime.rs | Defines the dedicated runtime that owns asynchronous native work. |