Go, Python, and TypeScript SDKs
The Go, Python, and TypeScript SDKs give applications one way to describe and run HelixDB reads, writes, searches, and graph work. They share the same query wire model while adapting execution, type use, error handling, and embedded database access to each language.
Shared client model
The SDKs turn language-level query builders into a typed HelixDB request. A request describes a read or write batch, its traversal steps, its returned variables, and any runtime parameters. Server clients send that request to POST /v2/query; embedded clients send the same query JSON to a local native database handle.
The common contract includes these concepts:
| Concept | Shared behavior |
|---|---|
| Query kind | Read and write requests remain distinct. A read batch cannot contain a write traversal. |
| Query values | Property values, expressions, predicates, projections, bindings, search steps, and index steps use the HelixDB AST shape. |
| Parameters | Typed parameters carry both a value and parameter type metadata. Parameter references can appear in filters, expressions, and stream bounds. |
| Results | A successful JSON body is decoded by the client. HTTP 204 No Content represents a successful empty result for warm requests. |
| Errors | Network, remote, serialization, invalid-request, embedded, and embedded-unavailable failures are exposed as structured SDK errors. |
The shared shape lets an application move a query between languages without changing its meaning. The language surface is not identical: Go favors exported functions and context.Context, Python favors immutable snake-case builders, and TypeScript favors typed classes with promises.
Request and response boundary
The request boundary is the main point of agreement between the SDKs and the HelixDB service. Each client validates or serializes a query before transport, adds server routing headers when requested, and maps an empty or failed response to the language-specific error contract.
Server execution supports writer routing, cache warming, and durability waiting. These options describe server behavior rather than query meaning, so all three SDKs reject them for embedded execution instead of silently ignoring them.
The clients also expose a separate Cypher boundary for one-statement requests. Cypher execution returns columns and rows, while Cypher explanation returns a plan without applying a modifying statement. The same server routing rules apply to these requests, but the native DSL and Cypher paths remain separate query contracts.
References: sdks/…/client.go• L229-326 sdks/…/_client_common.py• L123-263 sdks/…/index.ts• L342-437 sdks/…/README.md• L277-337 sdks/…/README.md• L316-357 sdks/…/README.md• L341-391
Query DSL
The DSL is a typed description of graph operations rather than a string query language. It lets callers compose node and edge sources, filters, traversals, expressions, projections, row bindings, repeated steps, vector and text searches, and index lifecycle actions.
The helpers also preserve important value distinctions. A literal value is different from a runtime parameter or an expression. Datetime values use the shared RFC3339 wire form. Python converts millisecond timestamps with exact arithmetic and maps values outside its supported datetime range to QueryError, so date values keep their millisecond precision and stable error contract. The SDKs protect values that could lose precision in the host language. Go, Python, and TypeScript validate index lifecycle receipts and status values while allowing unknown additive fields, so clients can accept compatible server extensions without accepting an unknown contract. The Go DSL keeps the current lifecycle stage and status set explicit, including build stages for vector and text indexes, and rejects stale or unknown stages. The DSLs also keep search consistency tied to request type: eventual search is a read-only choice and strong search remains the default. The refreshed parity corpus covers nested property values, row-binding projections, range-index direction, shortest paths, and the remaining read and write step shapes.
References: sdks/…/dsl.go• L32-41 sdks/…/dsl.go• L989-1343 sdks/…/dsl.go• L1331-1450 sdks/…/dsl_test.go• L80-303 sdks/…/dsl_test.go• L1460-1501 sdks/…/dsl_test.go• L969-997 sdks/…/main.go• L804-1092 sdks/…/dsl.py• L34-124 sdks/…/dsl.py• L196-244 sdks/…/dsl.py• L1087-1211 sdks/…/dsl.py• L1445-1738 sdks/…/test_dsl.py• L141-237 sdks/…/test_dsl.py• L240-312 sdks/…/test_dsl.py• L344-406 sdks/…/test_dsl.py• L429-450 sdks/…/dsl.ts• L69-158 sdks/…/dsl.ts• L878-973 sdks/…/dsl.ts• L1126-1331 sdks/…/generate-fixtures.ts• L774-1141 sdks/…/basic.test.ts• L42-100
Language interfaces
The three SDKs expose the same product capabilities through different language conventions. The table shows the normal entry points and the execution style an engineer should expect.
| SDK | Server client | Embedded client | Execution style | Result style |
|---|---|---|---|---|
| Go | NewClient and Client.Exec | NewEmbeddedClient or reader variants | Synchronous call with a context | Caller supplies an output value for JSON decoding |
| Python | Client or Client.server | Client.embedded or Client.embedded_reader | Synchronous call | Python value returned from query or execute |
| Python async | AsyncClient or AsyncClient.server | Awaitable embedded constructors | Awaitable calls with reusable async transport | Python value returned by await ...send() |
| TypeScript | Client | Client.embedded or Client.embeddedReader | Promise-based calls | Generic result type returned by send() |
The server paths are close in purpose. The main difference is ownership: Python async and TypeScript clients own an async transport or native handle and must be closed, while Go uses the caller's HTTP client and context model. Python synchronous embedded calls cannot run inside an active event loop because they bridge async native calls into a blocking API.
References: sdks/…/client.go• L56-67 sdks/…/client.go• L151-204 sdks/…/client.py• L27-133 sdks/…/async_client.py• L76-241 sdks/…/index.ts• L240-317
Go interface
The Go SDK is a synchronous client for code that already has a request context. A Go function can return helix.Request, then the caller passes it to Client.Exec with an output value and optional server execution options.
Go exposes the query model as exported constructors and methods. This makes the public contract explicit at compile time, while HelixError gives callers a stable way to inspect error kind, query code, status, and conflict state. The same client also executes or explains one Cypher statement at a time without replaying an uncertain modifying request.
References: sdks/…/client.go• L15-53 sdks/…/client.go• L243-326 sdks/…/README.md• L16-59 sdks/…/README.md• L277-337
The Go SDK also provides a native graph façade. Client.Graph performs one ordinary read to load a reusable immutable graph. Later graph access and algorithms use the retained graph, so they do not issue more HelixDB queries.
References: sdks/…/graph.go• L34-47 sdks/…/graph.go• L145-177 sdks/…/graph.go• L365-447
Python interfaces
The Python package offers both blocking and async clients over one shared query and error contract. The blocking Client is suited to scripts and synchronous services. AsyncClient keeps query execution and transport cleanup inside the event loop and supports concurrent requests.
The async client makes cancellation and connection ownership part of its contract. An async client can be used as an async context manager, and closing it prevents new work while allowing the transport to release its resources. Close is idempotent, and a failed or cancelled request does not make the client unusable. Embedded async calls can overlap; blocking embedded calls instead provide a simple synchronous boundary. Both client styles also expose matching Cypher execution and explanation operations.
References: sdks/…/client.py• L27-107 sdks/…/client.py• L334-343 sdks/…/async_client.py• L76-93 sdks/…/async_client.py• L226-275 sdks/…/test_client.py• L197-220 sdks/…/test_async_client.py• L75-127 sdks/…/test_async_client.py• L343-475 sdks/…/README.md• L33-66 sdks/…/README.md• L316-353
Python's public surface uses snake-case names and immutable DSL values. It returns native Python values for query results and uses typed graph records for graph work. The async and sync clients share the same server option names and error kinds, which keeps a query flow consistent when an application changes its execution model.
References: sdks/…/dsl.py• L1-6 sdks/…/_client_common.py• L16-120 sdks/…/__init__.py• L3-55
TypeScript interface
The TypeScript SDK is promise-based and uses the platform fetch API for server calls. Client.query creates a typed execution request, and send or sendBytes chooses decoded or raw results. TypeScript generics describe the expected decoded result without changing the query sent to HelixDB.
The SDK keeps its default server path dependency-free. It also preserves large integer results by parsing unsafe JSON integers as bigint, which avoids silent loss of identity or count values in JavaScript. Its published package is an ES module for Node 20 or newer, and the package contract checks the installed declarations as well as runtime imports. The client also exposes promise-based Cypher execution and explanation with the same embedded and server boundary rules.
References: sdks/…/index.ts• L226-239 sdks/…/index.ts• L299-329 sdks/…/index.ts• L375-437 sdks/…/dsl.ts• L69-158 sdks/…/dsl.ts• L229-291 sdks/…/package.json• L1-16 sdks/…/package.json• L38-66 sdks/…/types.mts• L1-17 sdks/…/basic.test.ts• L103-143 sdks/…/README.md• L341-391
TypeScript graph algorithms are promise-based even when graph accessors are direct. This reflects the native graph boundary: graph data is loaded once, then algorithm work is delegated to the native graph object.
References: sdks/…/graph.ts• L177-227 sdks/…/graph.ts• L270-353 sdks/…/graph.ts• L357-366
Embedded integration boundary
Embedded mode runs the HelixDB engine in the application process through generated native bindings. The SDKs keep this boundary separate from server transport while preserving the query JSON contract. A caller selects a storage source such as memory, disk, or object storage, then opens a writer or reader handle.
The boundary has four shared rules:
- Native bindings must be present and compatible with the SDK.
- Writer and reader handles are distinct choices.
- Cache settings are fixed when the embedded handle opens.
- Server-only routing options have no embedded meaning and are rejected.
The language bindings map these source and cache choices into each language's data model. Go uses source interfaces and build-tagged native code. Python imports the native module when an embedded constructor is called. TypeScript loads a configured native package dynamically; HELIXDB_EMBEDDED_NODE_PACKAGE is the current override and HELIXDB_UNIFFI_NODE_PACKAGE remains a deprecated alias. Embedded Cypher uses the same local handle, while Cypher explanation needs a native binding that supports that operation.
References: sdks/…/client.go• L64-135 sdks/…/client.go• L169-201 sdks/…/embedded_stub.go• L1-11 sdks/…/client.py• L36-82 sdks/…/client.py• L281-331 sdks/…/index.ts• L168-226 sdks/…/index.ts• L261-289 sdks/…/index.ts• L440-484 sdks/…/README.md• L66-102 sdks/…/README.md• L233-284 sdks/…/README.md• L258-265 sdks/…/README.md• L335-337
Embedded graph boundary
Graph loading adds a second native boundary after query execution. A graph selection tells the SDK which nodes and edges to read, which identity and weight fields to retain, and whether the graph is directed or supports parallel edges. The SDK performs one read and hands the result to the native graph layer.
The returned graph is immutable and reusable. It supports graph inspection, traversal, path and centrality work, community detection, layout, and graph transforms without querying HelixDB again. Native graph bindings are optional for the normal server query path, so missing bindings fail when graph loading is requested.
References: sdks/…/graph.go• L49-177 sdks/…/graph.py• L121-220 sdks/…/graph.py• L471-518 sdks/…/graph.py• L818-873 sdks/…/graph.ts• L18-105 sdks/…/graph.ts• L357-382
Contract tests and parity
Contract tests protect the agreements that must hold across language surfaces. They check query AST shape, parameter and result rules, transport headers, error mapping, embedded option limits, and the public methods that applications can call.
The tests use different forms of evidence for different boundaries:
| Boundary | What the tests establish |
|---|---|
| DSL contract | Equivalent operations produce the expected tagged query JSON. Invalid combinations fail before execution. Builders preserve traversal state and read/write mode. |
| HTTP contract | Clients use /v2/query, apply auth and routing headers, accept 200 and warm 204, and report remote failures with status and code data. |
| Embedded contract | Source and cache choices reach the native handle. Native errors retain their code and message. Missing bindings produce an explicit unavailable error. |
| Async contract | Cancellation closes response streams, embedded calls can overlap, clients can be reused after failed requests, and close is idempotent. |
| Graph contract | One read creates a native graph with stable identity, direction, limits, and algorithm behavior. |
| Package contract | The installed TypeScript artifact exposes its declarations and runtime behavior, preserves structured errors, and does not replay a mutation after a lost response. |
The language-local DSL suites also guard the shared value contract. They cover exact integer and datetime conversion, including boundary rendering and out-of-range errors, immutable builders, typed and untyped parameter rules, row-binding projections, search and index steps, and strict index lifecycle decoding that accepts additive response fields. The Go suite also checks that current vector and text lifecycle stages decode as valid while stale stage names and non-canonical operation IDs fail.
The runtime parity job goes beyond mocked calls. It builds native bindings, runs a common fixture corpus through Rust, TypeScript, Go, synchronous Python, and asynchronous Python, and compares normalized JSON results for memory and disk storage. It also checks disk reopen behavior, index-operation completion, post-DROP index_not_found errors, selected graph results, and transaction-conflict handling. The generators cover 234 runtime fixtures and 15 JSON-only fixtures, including edge removal, indexed-property removal, index drop, row bindings, shortest paths, and remaining read and write contracts.
References: sdks/…/main.go• L35-87 sdks/…/main.go• L93-246 sdks/…/parity_runtime_fixtures.py• L35-73 sdks/…/run_server_parity.py• L221-267 sdks/…/test_dsl.py• L53-237 sdks/…/test_dsl.py• L240-312 sdks/…/test_dsl.py• L344-406 sdks/…/test_dsl.py• L429-450 sdks/…/dsl_test.go• L1460-1501 sdks/…/generate-fixtures.ts• L36-71 sdks/…/generate-fixtures.ts• L774-1288 sdks/…/run-helix.ts• L23-87 sdks/…/basic.test.ts• L42-186 sdks/…/basic.test.ts• L488-494 sdks/…/package.json• L56-65
The TypeScript package checks run outside the source tree. They install the packed or registry artifact in an isolated consumer, compile against its public declarations, exercise successful, empty, legacy, future, and malformed response forms, verify confirmed conflicts and unknown write outcomes, and check that a dropped response does not replay a mutation. When a live test URL is configured, the consumer also checks real concurrent write conflicts and the final state after those conflicts. The edge-drop regression checks repeated edge replacement and final deletion against a disposable HTTP server. The lost-response probe applies the same no-replay rule to a live gateway.
References: sdks/…/package-smoke.mjs• L1-99 sdks/…/consumer.mjs• L1-152 sdks/…/client.test.ts• L261-386 sdks/…/lost-response-probe.ts• L1-26 sdks/…/edge-drop-regression.ts• L1-53
The CI contract treats the SDKs and their native binding generators as one compatibility surface. Changes to the AST, database, server, bindings, or SDK code can therefore affect the parity run even when a language package compiles on its own.
References: .github/…/sdk-query-parity.yml• L1-22 .github/…/sdk-query-parity.yml• L70-89 .github/…/sdk-query-parity.yml• L138-182
Change checklist
When these files or sections are changed, remember to consider these:
- A change to an AST tag, parameter type, datetime input conversion, RFC3339 form, integer form, row-binding shape, or index lifecycle field must stay aligned across Go JSON marshaling, Python encoding, and TypeScript encoding and parsing.
- A change to lifecycle stage names, status variants, operation ID rules, or additive response fields must update the Go decoder contract and the equivalent Python and TypeScript lifecycle checks.
- A change to parity fixture names, counts, ordering, normalization, index waits, or conflict handling must stay aligned across the Go, Python, and TypeScript generators.
- A change to
/v2/querystatus handling or error envelopes must preserve the sync and async Python paths plus the Go and TypeScript status, code, and unknown-outcome fields. - A change to
/v2/cypheror/v2/cypher/explainresponse shape, diagnostics, warm behavior, or write-outcome handling must stay aligned across the three language clients and their embedded paths. - A change to embedded source or cache variants must update the native conversion boundary and the generated-binding parity setup for all three languages.
- A change to graph identity, direction, limits, or native method names must preserve the one-read graph contract and the native graph acceptance checks.
- A change to a server-only option must keep its rejection behavior in embedded Go, Python sync, Python async, and TypeScript clients.
- A change to a public DSL method or result shape must be checked against the cross-language fixture corpus, not only the language-local unit tests.
- A change to search consistency defaults or read/write restrictions must preserve the strong default and reject eventual search on writes in every language surface.
- A change to index lifecycle status variants, stage names, decimal-string counters, or additive fields must preserve strict known-field validation and forward-compatible field handling in Python and TypeScript.
- A change to the TypeScript package export, declaration output, Node engine, or version must preserve isolated installed-package imports and type compilation.
- A change to edge drop or indexed-property removal must preserve the active, removed, dropped, and final index-search flows.
- A change to async response cleanup, cancellation, or embedded scheduling must preserve stream closure, client reuse, native-handle cleanup, and concurrent embedded calls.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Native embedded bindings are absent or do not expose the needed API | Embedded construction or graph loading fails instead of falling back to server mode | Use the explicit embedded-unavailable errors and run generated-binding parity checks. |
| A server routing option is used with an embedded client | The request is rejected because the option has no local meaning | Keep option validation at every client entry point. |
A 204 warm response is decoded as a normal JSON result | The caller sees a false serialization failure or expects a payload that does not exist | Treat 204 as successful empty output. |
An empty 200 response is treated like a warm 204 | A normal query succeeds without a result even though its response contract is broken | Keep empty 200 response decoding separate from the successful warm response path. |
| A query error envelope changes shape without preserving known forms | Callers lose stable error code or message data | Keep current, legacy, future-code, and message-only envelope parsing covered in each language. |
| A write response is lost after the server may have committed | An automatic retry can apply the mutation twice | Reconcile unknown write outcomes. The SDK must not replay uncertain mutations. |
| A graph selection starts with a full scan without opt-in | A potentially unbounded graph load is rejected | Set the explicit full-scan permission and use node or edge limits where needed. |
| One SDK emits a different AST or result shape | Cross-language applications return different data or parity fails | Compare structural JSON fixtures across all SDKs. |
| An indexed edge or node is removed without preserving index maintenance behavior | Search results can retain stale items or post-drop behavior can differ by SDK | Keep indexed-property removal, entity drop, index drop, and post-DROP checks in parity and edge regression flows. |
| The published TypeScript package differs from the source declarations or runtime | Consumers can compile against an API that does not work after install | Run the isolated package consumer and declaration checks. |
| An index lifecycle decoder treats an unknown status or malformed decimal counter as valid | A client can act on a bad operation receipt or lose the stable lifecycle contract | Validate known variants and required fields while ignoring only additive fields. |
| A Go lifecycle response uses a stale stage name or non-canonical operation ID | A valid operation receipt is rejected or an invalid receipt reaches application code | Keep the current stage and identifier rules covered by Go decoder tests and cross-language lifecycle checks. |
| Eventual search consistency is applied to a write request | The request is rejected instead of silently using a weaker visibility rule | Keep strong search as the default and reject eventual consistency for writes before transport. |
| An async cancellation or read failure leaves its response stream or native task open | The client cannot reuse its transport or the embedded handle leaks work | Close response streams on every path and propagate cancellation through embedded calls. |
| A Python millisecond timestamp falls outside the supported datetime range or loses precision during conversion | A query can carry the wrong instant or expose an unstable host exception instead of the SDK error | Use exact millisecond conversion, preserve RFC3339 boundary checks, and map range failures to InvalidDateTimeParameter. |
| Embedded Cypher explanation uses bindings that predate explain support | Explanation fails as unavailable even though ordinary embedded queries work | Treat explain support as a separate native capability and report EmbeddedUnavailable clearly. |
Key files
| File | Why to read it |
|---|---|
| sdks/…/client.go | Defines the Go server and embedded client boundary, execution options, and error model. |
| sdks/…/dsl.go | Shows the Go representation of shared query values, expressions, predicates, traversal steps, and index lifecycle contracts. |
| sdks/…/dsl_test.go | Checks Go AST shape, search consistency, parameter validation, lifecycle decoding, and transport error contracts. |
| sdks/…/graph.go | Shows the one-read immutable graph contract and Go graph interface. |
| sdks/…/main.go | Shows the shared fixture corpus, async index waits, disk reader reopen checks, and embedded conflict handling. |
| sdks/…/README.md | Summarizes the Go query, Cypher, server, and embedded client contract. |
| sdks/…/_client_common.py | Defines the shared Python request, response, URL, and error rules used by both clients. |
| sdks/…/client.py | Defines blocking server and embedded execution. |
| sdks/…/async_client.py | Defines async transport ownership, cancellation, embedded execution, and close behavior. |
| sdks/…/test_client.py | Checks the blocking client API, HTTP contract, embedded options, native errors, and no-replay behavior. |
| sdks/…/test_async_client.py | Checks async transport cleanup, cancellation, client reuse, embedded overlap, and native binding availability. |
| sdks/…/dsl.py | Defines the immutable Python DSL, shared AST encoding, exact datetime conversion, row bindings, search helpers, and index lifecycle values and decoders. |
| sdks/…/parity_runtime_fixtures.py | Shows the Python runtime fixtures that must match the other language generators. |
| sdks/…/run_server_parity.py | Runs the Python sync and async fixture corpus against a real server and compares it with Rust. |
| sdks/…/test_dsl.py | Shows Python contract checks for values, exact datetime boundaries, parameters, bindings, searches, index status, and traversal state. |
| sdks/…/graph.py | Defines Python graph selection, identity handling, and native graph operations. |
| sdks/…/README.md | Summarizes the Python sync, async, Cypher, and embedded client contract. |
| sdks/…/index.ts | Defines the TypeScript client, promise-based execution, error model, and native package boundary. |
| sdks/…/dsl.ts | Defines TypeScript AST values, safe integer parsing, query helpers, bindings, and index lifecycle parsing. |
| sdks/…/README.md | Describes the supported TypeScript client, Cypher, search, graph, package, and error contracts. |
| sdks/…/graph.ts | Defines graph loading and the promise-based native graph façade. |
| sdks/…/client.test.ts | Checks HTTP responses, error fields, embedded handles, cache options, and server-option rejection. |
| sdks/…/lost-response-probe.ts | Checks the live gateway contract for terminal unknown write outcomes. |
| sdks/…/basic.test.ts | Checks public DSL, value, parameter, binding, search, graph-selection, traversal state, and lifecycle contracts. |
| sdks/…/generate-fixtures.ts | Describes the TypeScript JSON and runtime parity fixture corpus. |
| sdks/…/run-helix.ts | Runs cross-language server and Cypher parity with disk restart coverage. |
| sdks/…/edge-drop-regression.ts | Checks repeated edge replacement and final edge deletion over HTTP. |
| sdks/…/package-smoke.mjs | Verifies the packed or registry package in an isolated consumer and optional database container. |
| sdks/…/consumer.mjs | Exercises installed-package runtime errors, conflict behavior, and no-replay guarantees. |
| .github/…/sdk-query-parity.yml | Shows which SDK, binding, and runtime checks CI treats as one contract. |
See Client SDKs and bindings for the wider SDK map. See Rust SDK and DSL for the reference language surface and UniFFI bindings for the native binding boundary.