The LAST free Semurg nodes EVER: the first 1,000 are free, for a limited time. After that, every node is US$139, paid once.

Blog / How-to guides

Semurg as a graph database: load edges, walk them to any depth

23 October 2026 · Semurg · 3 min read · Markdown

Last checked on r11.168.20261114.da3a8f8 (14 Nov 2026): every command below ran on a fresh node of that release. The current release is r11.173.20261116.3006727 (16 Nov 2026), and the commands have not been re-checked on it yet (how)

graphdatabasehow-topython

A graph in Semurg is a set of edges. An edge's id is computed from its two ends and its relation, so writing the same edge twice still leaves one edge. A walk starts from the nodes you name and follows outgoing edges level by level, as deep as you ask, and answers with how many nodes it reached, how many edges it followed, and how many nodes it first reached at each level.

Your edges, one record each; a walk starts from the seeds you name and follows outgoing edges level by level, answering with the nodes reached, the edges followed and how many nodes were first reached at each level.Your edges, one recordeachThe nodes you startfromA walk: outgoingedges, level by levelNodes reached, edgesfollowed, nodes firstreached per level

Load edges and walk them, from Python

pip install semurg, then build each edge with semurg.container.edge(source, target) (or edge(source, target, relation)) and send them with ingest. The program below writes a small graph, a short chain with one branch, and walks it out from the first node of the chain. It reads your node's API token from SEMURG_API_TOKEN: the installer prints it, and semurg.open() reads it for you.

python
import os
from semurg import Client, container

c = Client("http://localhost:4000", token=os.environ["SEMURG_API_TOKEN"])

# 1 -> 2 -> 3 -> 4, and a branch 2 -> 5
edges = [container.edge(1, 2), container.edge(2, 3), container.edge(3, 4), container.edge(2, 5)]
print("written", c.ingest(edges)["containers"])

walk = c.query("traverse", {"seeds": [1], "hops": 3})["result"]
print("levels", walk["witness"]["levels"])
print("nodes", walk["nodes_visited"], "edges", walk["edge_hops"])

Expected: four edges written; levels 1, 1, 2, 1 (node 1, then 2, then 3 and 5, then 4); five nodes reached (node 1 included) over four edges

semurg.open() starts a local node with Docker and returns the same client, so on an x86_64 Linux machine with Docker the first line can be c = semurg.open(). A large graph goes in batches: each ingest call takes a list of edges, and the edges are checked before anything is sent (an edge built wrong is refused by its position in the list, never stored wrong).

What a walk answers

  • nodes_visited: the distinct nodes reached, the starting nodes included.
  • edge_hops: the edges followed.
  • witness.levels: how many nodes were first reached at each level, starting with the seeds, so you can see where the walk grew and where it stopped. levels_complete is true when every node of the cluster reported its counts; false means the per-level counts are partial, and "elided" means the walk went too deep to list every level.

A walk takes up to 100000 starting nodes in one call ("seeds": [...]) and any depth ("hops"). Over HTTP it is one call:

bash
curl -sS http://localhost:4000/v1/query \
  -H "Authorization: Bearer $SEMURG_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"op":"traverse","seeds":[1],"hops":3}'

Read a node's neighbours

neighbour_ids answers each node's outgoing neighbours, or only how many there are with "count_only": true:

bash
curl -sS http://localhost:4000/v1/query \
  -H "Authorization: Bearer $SEMURG_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"op":"neighbour_ids","ids":[2],"direction":"out"}'

Each id in the answer says its state: its edges (an empty list for a node with none), a page of them when there are more than you asked for, a count with count_only, or absent when nothing was ever written under that id.

When something is refused

  • 422: a malformed request, with the field named.
  • 413: more than 100000 starting nodes in one call.
  • 501: starting nodes that exist but cannot be walked on this release.
  • 503: the node is under its memory floor, or busy with other walks; retry.

How it behaves

  • A walk answers counts and a witness per level, not the list of nodes it reached.
  • Walks follow outgoing edges.
  • Edges load as records built by the clients (semurg.container in Python), not as JSON.

Next

What Semurg is: Give Claude Code, Cursor and your other AI agents a memory that lasts: install Semurg on your own machine in one line.

Why use it: your agent recalls the facts it needs, each with its source, instead of re-reading the project.

What it solves today: agents that forget between sessions, and data that must stay on your own machines.

This post was written with AI assistance. Every result in it is checked against a published release or record before the post goes out.

How these commands were checked

Our test farm ran each of the 1 command block marked runnable, exactly as written, with the answer checked against the expectation printed under it, against a fresh node of the published release r11.168.20261114.da3a8f8. A post is published only when every one of them passed there.

Related