SDK reference
Official Python, Node.js, and Go clients for AnythingGraph.
Methods mirror the REST API — inject playbook data, sync data capsules,
and traverse relationships from your backend or CI.
Python
Node.js (ESM)
Go
Start the stack first (
anythinggraph start or
./start-all.sh). SDKs default to
127.0.0.1 service ports. Source:
github.com/AnythingGraph/sdk
| Client property | Python | Node.js | Go |
| Top-level | AnythingGraphClient | AnythingGraphClient | Client |
| Data Injection | .connector | .connector | .Connector |
| Data Cache | .rdf_cache | .rdfCache | .RdfCache |
| Data layer | .data_layer | .dataLayer | .DataLayer |
| Playbooks | .dashboard | .dashboard | .Dashboard |
Installation
Clone the SDK submodule with the platform repo, or install from the SDK repository.
Install Python
git clone --recurse-submodules https://github.com/AnythingGraph/AnythingGraph.git
cd AnythingGraph/sdk/python
pip install -e .
python examples/supply_chain.py
from anythinggraph import AnythingGraphClient
client = AnythingGraphClient()
print(client.connector.health())
Install Node.js
cd AnythingGraph/sdk/nodejs
npm install
node examples/example.js
import { AnythingGraphClient } from 'anythinggraph-sdk';
const client = new AnythingGraphClient();
const health = await client.connector.health();
Install Go
cd AnythingGraph/sdk/golang
go build ./...
go run ./examples/supply-chain/
import (
"context"
"github.com/anythinggraph/anythinggraph-sdk/anythinggraph"
)
client := anythinggraph.NewClient(nil)
health, err := client.Connector.Health(context.Background())
ReBAC options
Pass RebacOptions on data-layer row and relationship reads when a playbook enforces access.
| Field | Maps to |
subject_id / subjectId | X-Ontox-Subject-Id header or subject_id query |
playbook_id / playbookId | X-Ontox-Playbook-Id header or playbook_id query |
# Python
from anythinggraph import RebacOptions
links = client.data_layer.list_relationships(
rebac=RebacOptions(playbook_id="organizational-graph")
)
// Node.js
const links = await client.dataLayer.listRelationships({
playbookId: 'organizational-graph',
});
Data Injection client
client.connector — wraps the Data Injection API at http://127.0.0.1:8183.
Health
client.connector.health() # Python
await client.connector.health() # Node.js
client.Connector.Health(ctx) # Go
Ingest
Inject records into an installed playbook. context.playbook_id scopes field mappings and
relationship routing. Returns rows created, relationships created, and landing-zone count.
# Python
result = client.connector.ingest(
{
"playbook_id": "organizational-graph",
"source_label": "hr-export",
"entity_name": "employee",
"field_mappings": [],
},
{
"records": [{
"full_name": "Sam Lee",
"email": "sam@acme.example",
"corporation_name": "Acme Corp",
}]
},
)
print(result["relationships_created"])
// Node.js
const result = await client.connector.ingest({
playbook_id: 'organizational-graph',
source_label: 'hr-export',
entity_name: 'employee',
field_mappings: [],
}, {
records: [{
full_name: 'Sam Lee',
email: 'sam@acme.example',
corporation_name: 'Acme Corp',
}],
});
console.log(result.relationships_created);
List landing zone
Failed or ambiguous ingest records awaiting human review.
client.connector.list_landing_zone() # Python
await client.connector.listLandingZone() # Node.js
client.Connector.ListLandingZone(ctx) # Go
Approve landing zone record
Apply corrections and train field mappings. Python / Node only.
await client.connector.approveLandingZone(12, {
entity_name: 'employee',
corrected_values: { full_name: 'Sam Lee' },
field_mappings: [
{ from_field: 'name', to_field: 'full_name', entity_name: 'employee' },
],
});
Delete landing zone record
client.connector.delete_landing_zone(12) # Python
await client.connector.deleteLandingZone(12) # Node.js
client.Connector.DeleteLandingZone(ctx, 12) # Go
Data Cache client
client.rdf_cache / client.rdfCache — wraps the Data Cache API at http://127.0.0.1:8181.
Health
client.rdf_cache.health()
Load cache
Load Turtle into the active cache capsule. For playbook-scoped capsules, use the REST API with playbook_id.
client.rdf_cache.load_cache(turtle_text, replace=True) # Python
await client.rdfCache.loadCache(turtleText, true) # Node.js
Get cached Turtle
client.rdf_cache.get_cache()
await client.rdfCache.getCache()
Cache metadata
Returns version, turtle_bytes, updated_at_ms.
client.rdf_cache.cache_meta()
await client.rdfCache.cacheMeta()
Clear cache
client.rdf_cache.clear_cache()
await client.rdfCache.clearCache()
SPARQL query
SELECT on the active cache. For governed agents with per-playbook capsules, use the REST API with playbook_id and subject_id.
query = "SELECT ?row ?name WHERE { ?row a <...#Employee> ; <...#fullName> ?name }"
client.rdf_cache.sparql_query(query)
await client.rdfCache.sparqlQuery(query)
Sync from data layer
Export Turtle from the data layer and load into the cache in one call.
For governed MCP agents, sync per-playbook capsules from the dashboard
(Settings → Data Capsules) — not __global__.
client.rdf_cache.sync_from_data_layer(entity_ids="*") # Python
await client.rdfCache.syncFromDataLayer({ entityIds: '*' }) # Node.js
Data layer client
client.data_layer / client.dataLayer — wraps the Data layer API at http://127.0.0.1:8182.
Health
client.data_layer.health()
Entity CRUD
Manage record types (schemas) and fields.
entities = client.data_layer.list_entities()
entity = client.data_layer.get_entity(1)
client.data_layer.create_entity({
"name": "employee",
"display_name": "Employee",
"fields": [
{ "field_name": "email", "field_type": "TEXT", "is_required": True }
],
})
Entity rows
Optional RebacOptions on listEntityRows.
rows = client.data_layer.list_entity_rows(
entity_id,
rebac=RebacOptions(playbook_id="organizational-graph"),
)
client.data_layer.create_entity_row(entity_id, {"email": "sam@acme.example"})
Row relationships
Traverse graph links between rows. Pass playbook_id to scope reads.
# Python — list employed_by links for a playbook
links = client.data_layer.list_relationships(
rebac=RebacOptions(playbook_id="organizational-graph")
)
# Node.js
const links = await client.dataLayer.listRelationships({
playbookId: 'organizational-graph',
});
client.data_layer.create_relationship({
"relationship_name": "employed_by",
"subject_entity_id": 1,
"object_entity_id": 2,
"subject_row_id": 10,
"object_row_id": 20,
})
Export Turtle
Returns text/turtle for loading into the Data Cache client.
turtle = client.data_layer.export_turtle(entity_ids="*")
turtle = client.data_layer.export_turtle(entity_names=["employee", "corporation"])
Playbooks client
client.dashboard — install packs, webhook ingest, and landing-zone review via the dashboard API.
List playbooks
playbooks = client.dashboard.list_playbooks() # Python
await client.dashboard.listPlaybooks() # Node.js
Install playbook
Creates entities, schema relationships, and optional example data in the data layer.
await client.dashboard.installPlaybook('organizational-graph')
Playbook webhook ingest
Simplest ingest path — dashboard resolves mappings and forwards to the connector.
await client.dashboard.playbookWebhook('organizational-graph', {
records: [{
full_name: 'Sam Lee',
email: 'sam@acme.example',
corporation_name: 'Acme Corp',
}],
}, 'hr-export');