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.16.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.16.0
File Size Uploaded Provenance Actions
samyama-1.16.0.tar.gz 7.2 MB With provenance Details for samyama-1.16.0.tar.gz

Built distributions (wheels)

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

Total release size: 65.1 MB

Release files / samyama-1.16.0.tar.gz

Download URL samyama-1.16.0.tar.gz
Size 7.2 MB
Tags Source
SHA-256 checksum
How to use checksums
44b2d073593e94795f38f8dfd543d518f7e40f3b21ee6a19c14ee39473a809e9
BLAKE2b-256 checksum
How to use checksums
d91ab2427761d0b4fd7135f144346ceee1723e4debe0d795594baffc4528eaea
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 16, 2026.

Transparency log

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

Download URL samyama-1.16.0-cp38-abi3-win_amd64.whl
Size 10.5 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
42376cee2fd551778ff158b4886502552d1f993043c990db8ca47edc12226e0c
BLAKE2b-256 checksum
How to use checksums
b1b1baf8104e5083b3530fe6bddc8151813e06d0e8dd957101e24f4ba6ce6245
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 16, 2026.

Transparency log

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

Download URL samyama-1.16.0-cp38-abi3-manylinux_2_28_x86_64.whl
Size 12.7 MB
Tags CPython 3.8 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
473442de882fb792ed7cea79252fc8af6e7fc982cdc95ae8e78703f8f6b13443
BLAKE2b-256 checksum
How to use checksums
b0dc53403aba265305f1e983b3e1ef174f12f21267c616e0f10fbdeeb5b77ec5
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 16, 2026.

Transparency log

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

Download URL samyama-1.16.0-cp38-abi3-manylinux_2_28_aarch64.whl
Size 12.5 MB
Tags CPython 3.8 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
5878370f7aee3ee0e06e7b56e9ea1b1f19b407c07c6200416f798afacaec9e25
BLAKE2b-256 checksum
How to use checksums
d676316e25e92e4686909e43a273b6859d1ae57643797798bb08d595f250e304
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 16, 2026.

Transparency log

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

Download URL samyama-1.16.0-cp38-abi3-macosx_11_0_arm64.whl
Size 10.8 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2bc96cf0a5cbaee57f21cea37262a6edb0800370324155c8ed5666222cd65b1b
BLAKE2b-256 checksum
How to use checksums
2d7e6b05ad065e567d8ddf49698741b3c2df47375c4969236008be9cfe5bfb1c
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 16, 2026.

Transparency log

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

Download URL samyama-1.16.0-cp38-abi3-macosx_10_15_x86_64.whl
Size 11.4 MB
Tags CPython 3.8 abi3 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
d77d6d6ed2ce93e9ea7b8b32ab5926777a9ae036bf1dcc58df7eeb55c1cff32e
BLAKE2b-256 checksum
How to use checksums
0471ff0c9607cc6d1bf0e42fd27f33fdc2731f66a49b1db9529d80bfb03a7eb1
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 16, 2026.

Transparency log

Security for samyama 1.16.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.16.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 16, 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