API Reference
CypherLite provides APIs across multiple languages. Each binding exposes the same core functionality: opening a database, executing Cypher queries, and iterating over results.
Rust API (Primary)
The Rust API is the primary interface and provides the most complete feature set.
Full Rust API documentation with all type signatures and examples is available on docs.rs/cypherlite-query.
Core Types
| Type | Description |
|---|---|
CypherLite | Main database handle. Open, execute queries, and manage the database lifecycle. |
QueryResult | Iterator over result rows returned by execute(). |
Row | A single result row with column access via get(name). |
Value | Typed property value: Null, Bool, Int64, Float64, String, Bytes, Array. |
CypherLiteError | Error type for all database operations. |
Core Methods
// Open or create a database
let db = CypherLite::open("path/to/db.cyl")?;
// Execute a Cypher query
let result = db.execute("MATCH (n) RETURN n")?;
// Iterate over results
for row in result {
let row = row?;
let value = row.get("column_name");
}Crate Hierarchy
| Crate | Purpose |
|---|---|
cypherlite-query | High-level query interface (recommended entry point) |
cypherlite-core | Core data structures, traits, and plugin system |
cypherlite-storage | Storage engine, B+Tree, WAL, buffer pool |
cypherlite-ffi | C ABI foreign function interface |
FFI Binding APIs
All FFI bindings follow a consistent pattern:
- Open a database from a file path
- Execute Cypher queries as strings
- Iterate over result rows
- Close the database handle
Python API
import cypherlite
db = cypherlite.open("db.cyl") # Open database
result = db.execute("MATCH (n) ...") # Execute query
for row in result: # Iterate rows
print(row["column"]) # Access columns
db.close() # Close databaseSee the Python Getting Started guide for full details.
Go API
db, err := cypherlite.Open("db.cyl") // Open database
result, err := db.Execute("MATCH ...") // Execute query
for result.Next() { // Iterate rows
row := result.Row()
val, _ := row.GetString("column") // Access columns
}
db.Close() // Close databaseSee the Go Getting Started guide for full details.
Node.js API
const { open } = require("cypherlite");
const db = open("db.cyl"); // Open database
const result = db.execute("MATCH ..."); // Execute query
for (const row of result) { // Iterate rows
console.log(row["column"]); // Access columns
}
db.close(); // Close databaseSee the Node.js Getting Started guide for full details.
C API
#include "cypherlite.h"
CylDb *db = cyl_open("db.cyl"); // Open database
CylResult *res = cyl_execute(db, "MATCH ..."); // Execute query
while (cyl_result_next(res)) { // Iterate rows
const char *val = cyl_row_get_string(res, "column");
}
cyl_result_free(res); // Free result
cyl_close(db); // Close databaseThe C header (cypherlite.h) and static library (libcypherlite_ffi.a) are generated by building the cypherlite-ffi crate.
Property Types
All bindings support the same set of property value types:
| Type | Rust | Python | Go | Node.js | C |
|---|---|---|---|---|---|
| Null | Value::Null | None | nil | null | CYL_NULL |
| Boolean | Value::Bool | bool | bool | boolean | cyl_bool |
| Integer | Value::Int64 | int | int64 | number | int64_t |
| Float | Value::Float64 | float | float64 | number | double |
| String | Value::String | str | string | string | const char* |
| Bytes | Value::Bytes | bytes | []byte | Buffer | uint8_t* |
| Array | Value::Array | list | []any | Array | CylArray* |