C bindings for Minigraf — zero-config, single-file, embedded bi-temporal graph database.
Download the pre-built library for your platform from the latest release:
| Platform | Archive |
|---|---|
| Linux x86_64 | minigraf-c-<version>-linux-x86_64.tar.gz |
| Linux aarch64 | minigraf-c-<version>-linux-aarch64.tar.gz |
| macOS universal | minigraf-c-<version>-macos-universal2.tar.gz |
| Windows x86_64 | minigraf-c-<version>-windows-x86_64.zip |
Each archive contains libminigraf.{so|dylib|dll} and minigraf.h.
#include "minigraf.h"
#include <stdio.h>
int main(void) {
MiniGrafDb *db = minigraf_open_in_memory();
char *result = minigraf_execute(db, "(transact [[:alice :name \"Alice\"]])");
printf("%s\n", result);
minigraf_string_free(result);
minigraf_close(db);
return 0;
}Compile: cc -o example example.c -Iinclude -L. -lminigraf -Wl,-rpath,.
- Strings returned by
minigraf_executemust be freed withminigraf_string_free. - Databases must be closed with
minigraf_close. - Passing
NULLto any function is safe (no-op or returns NULL/error).
| Function | Description |
|---|---|
minigraf_open(path) |
Open a file-backed database |
minigraf_open_in_memory() |
Open an in-memory database |
minigraf_execute(db, datalog) |
Execute Datalog, returns JSON string |
minigraf_string_free(s) |
Free a string returned by execute |
minigraf_checkpoint(db) |
Flush WAL to disk; returns 0 on success |
minigraf_last_error(db) |
Return last error message (valid until next call) |
minigraf_close(db) |
Close the database and free all memory |
cargo build --release
# produces target/release/libminigraf.{so|dylib|dll}Regenerate the header after changing the public API:
cbindgen --config cbindgen.toml --crate minigraf-c-shim --output include/minigraf.hMIT OR Apache-2.0