Skip to main content

samyama — Python SDK for the Samyama Graph Database

Python bindings for Samyama, a property-graph database with a Cypher query engine. The extension module is built from Rust with PyO3 on top of crates/samyama-sdk, so the embedded mode runs the engine in-process — no server, no network.

Install

pip install samyama

Wheels are abi3 and work on CPython 3.8+.

The package also installs samyama_aio (asyncio wrapper), samyama_nb (notebook helpers) and samyama_mcp (an MCP server, entry point samyama-mcp-serve).

Connect

Two modes. Embedded runs the engine inside your process:

from samyama import SamyamaClient

client = SamyamaClient.embedded()

Remote talks to a running Samyama server over HTTP:

from samyama import SamyamaClient

client = SamyamaClient.connect(
    "http://localhost:8080",
    timeout_seconds=30.0,          # whole-request deadline
    connect_timeout_seconds=5.0,   # TCP connect only
    max_retries=2,
    retry_base_delay_ms=100,
)

Both return the same SamyamaClient, with the same query methods. Graph algorithms (page_rank, wcc, scc, bfs, dijkstra, pca, triangle_count) and the vector methods (create_vector_index, add_vector, vector_search) are embedded-only and raise RuntimeError on a remote client.

First query

from samyama import SamyamaClient

client = SamyamaClient.embedded()

client.query('CREATE (:Person {name: "Alice"})-[:KNOWS]->(:Person {name: "Bob"})')

result = client.query_readonly(
    "MATCH (a:Person)-[:KNOWS]->(b:Person) RETURN a.name, b.name"
)

print(result.columns)   # ['a.name', 'b.name']
for row in result.records:
    print(row)          # ['Alice', 'Bob']
print(len(result))      # 1

query is read-write, query_readonly is read-only. Both take an optional graph argument, which defaults to "default"; this build serves a single graph and rejects any other name.

A QueryResult exposes columns, records, nodes, edges, and len().

Other methods on the client: status() (returns a ServerStatus with status, version, nodes, edges), ping(), list_graphs(), delete_graph(graph="default").

Snapshots

A .sgsnap file is a whole graph in one file. In embedded mode the client loads and saves one itself, so a notebook, an evaluation harness or an agent needs no server and no network:

from samyama import SamyamaClient

client = SamyamaClient.open_snapshot("pubmed.sgsnap")   # embedded, ready to query
client.query_readonly("MATCH (a:Article) RETURN count(a) AS n")

client.query('CREATE (:Note {text: "checked"})')
report = client.export_snapshot("pubmed-annotated.sgsnap")
print(report["nodes_exported"], report["bytes_written"], report["dropped"])

import_snapshot(path) adds a snapshot to a client's graph and returns a report with the keys of the server's import response (nodes_imported, edges_imported, nodes_merged, merges_by_key, dedup_keys_unused, ...) plus duration_ms. Pass dedup_keys=["drugbank_id"] to merge incoming nodes into existing ones that share a key value; open_snapshot takes the same argument. export_snapshot replaces any file at path, and its dropped list says what the format does not carry.

Vectors added with add_vector are not carried. add_vector puts a vector in the vector index only, not on the node as a property, and a snapshot holds node properties and index declarations. After open_snapshot the index exists but is empty, and vector_search returns nothing; the export's dropped list does not report it yet. Re-add the vectors after opening.

All three are embedded-only: a remote client raises RuntimeError, because a server imports and exports its own snapshots (POST /api/snapshot/import and POST /api/snapshot/export). A file that is missing or is not a snapshot raises RuntimeError and leaves the graph unchanged.

asyncio

samyama_aio wraps the same client, running each call on a worker thread so the event loop is not blocked:

import asyncio
from samyama_aio import AsyncSamyamaClient

async def main():
    client = await AsyncSamyamaClient.embedded()
    await client.query('CREATE (:Person {name: "Alice"})')
    result = await client.query_readonly("MATCH (n:Person) RETURN n.name")
    print(result.records)   # [['Alice']]

asyncio.run(main())

AsyncSamyamaClient.connect(url, **kwargs) takes the same keyword arguments as SamyamaClient.connect.

Natural-language queries

nlq turns a question into Cypher. It returns the query and does not run it; a generated query that writes is refused.

client = SamyamaClient.embedded()
# ... load a graph ...
cypher = client.nlq("Who does Alice know?", provider="openai")  # key from OPENAI_API_KEY
result = client.query_readonly(cypher)

In embedded mode the translation happens in this process: the model is shown this graph's schema, as the server would show it. The provider is read from the same environment variables the server reads, and the keyword arguments take their place for one call:

argument environment variable it replaces
provider NLQ_PROVIDER — openai, gemini, ollama, claudecode or mock; no default
model NLQ_MODEL (default gpt-4o)
api_key the provider's own: OPENAI_API_KEY, GEMINI_API_KEY
api_base_url NLQ_API_BASE_URL

No server is involved, but the provider still is: openai and gemini send the question and the schema summary to that service. mock answers a fixed query without leaving the process, for tests.

A remote client asks the server (POST /api/nlq), which chooses its own provider, so passing any of these arguments to it raises ValueError.

More

Apache-2.0.

Metadata

Release files for samyama 1.15.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for samyama 1.15.0
File Size Uploaded Provenance Actions
samyama-1.15.0.tar.gz 7.1 MB With provenance Details for samyama-1.15.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for samyama 1.15.0
File Actions
samyama-1.15.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for samyama-1.15.0-cp38-abi3-win_amd64.whl
samyama-1.15.0-cp38-abi3-manylinux_2_28_x86_64.whl CPython 3.8 abi3 Linux glibc 2.28+ x86-64 Details for samyama-1.15.0-cp38-abi3-manylinux_2_28_x86_64.whl
samyama-1.15.0-cp38-abi3-manylinux_2_28_aarch64.whl CPython 3.8 abi3 Linux glibc 2.28+ ARM64 Details for samyama-1.15.0-cp38-abi3-manylinux_2_28_aarch64.whl
samyama-1.15.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for samyama-1.15.0-cp38-abi3-macosx_11_0_arm64.whl
samyama-1.15.0-cp38-abi3-macosx_10_15_x86_64.whl CPython 3.8 abi3 macOS 10.15+ x86-64 Details for samyama-1.15.0-cp38-abi3-macosx_10_15_x86_64.whl

Total release size: 64.2 MB

Release files / samyama-1.15.0.tar.gz

Download URL samyama-1.15.0.tar.gz
Size 7.1 MB
Tags Source
SHA-256 checksum
How to use checksums
33f7bee11a11ffb9915ce5f396acca57ce3acf44d4197640e0162a81155f0353
BLAKE2b-256 checksum
How to use checksums
fb641272fd7027b5e254ed33004acd4965266e0535c4537cfb47412afc283842
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / samyama-1.15.0-cp38-abi3-win_amd64.whl

Download URL samyama-1.15.0-cp38-abi3-win_amd64.whl
Size 10.4 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3570cd1c00104d6c3e8aae45b5e1c6918197e866f9fc129c5b69719f86614e24
BLAKE2b-256 checksum
How to use checksums
7713aa37d2bbd8a50a907fc3d6b026811a716df274755ade3b78c17c7c2aa566
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / samyama-1.15.0-cp38-abi3-manylinux_2_28_x86_64.whl

Download URL samyama-1.15.0-cp38-abi3-manylinux_2_28_x86_64.whl
Size 12.6 MB
Tags CPython 3.8 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
1fa12d6ec629b73eaff9e8dbe7d7be573a1d1932b0550972448bc765db5c19d1
BLAKE2b-256 checksum
How to use checksums
88763eeadae3386b85845e34b98a832361c5ec52d8c268534172f54e31eb1afc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / samyama-1.15.0-cp38-abi3-manylinux_2_28_aarch64.whl

Download URL samyama-1.15.0-cp38-abi3-manylinux_2_28_aarch64.whl
Size 12.3 MB
Tags CPython 3.8 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
42cb80a659a483334286d80a5629d86315eebcb4f7b5fcad2c147ab968d1ec74
BLAKE2b-256 checksum
How to use checksums
dd93db0807a7948b0f59dd616be30f31c58b34e24f129058c4e3abfad311c228
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / samyama-1.15.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL samyama-1.15.0-cp38-abi3-macosx_11_0_arm64.whl
Size 10.6 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6068a6f840d8d61b89e8981db3370a905ee0d2ac12ebc7f02075c9f6f2b45aeb
BLAKE2b-256 checksum
How to use checksums
0543ebd67e50059e299cc0f852f11943e37f8f5bc39aa8912273f9115e76382e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / samyama-1.15.0-cp38-abi3-macosx_10_15_x86_64.whl

Download URL samyama-1.15.0-cp38-abi3-macosx_10_15_x86_64.whl
Size 11.2 MB
Tags CPython 3.8 abi3 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
b0fe2e52fdf44874fd989cee3044abb1153fd75a58556dd0d1c6fa268825f117
BLAKE2b-256 checksum
How to use checksums
ef9e8f9a14a021e24102c938e434e1e48d43a5d93ab9b21526e08190b0f1187a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Security for samyama 1.15.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for samyama-1.15.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page