Skip to main content

Graph API

Graph endpoints for visualization and time-travel inspection.

First-Party Only

The graph snapshot endpoint requires JWT authentication (first-party only). Third-party apps can build graph views by querying nodes and relationships via their respective APIs.

Endpoints

GET /graph/snapshot

GET Get complete graph state at a specific timestamp (time-travel).

curl -X GET "https://api.ofself.ai/api/v1/graph/snapshot?timestamp=2025-01-15T10:30:00Z" \
-H "Authorization: Bearer your-jwt-token"

Query Parameters:

ParameterTypeRequiredDescription
timestampdatetimeYesISO 8601 timestamp to snapshot

Response: 200 OK

{
"timestamp": "2025-01-15T10:30:00Z",
"nodes": [
{
"id": "node_abc",
"title": "First day teaching",
"node_type": "EXPERIENCE",
"meaning_level": "IDENTITY",
"importance_score": 0.98,
"created_at": "2024-01-15T10:30:00Z"
}
],
"relationships": [
{
"id": "rel_abc",
"from_node_id": "node_abc",
"to_node_id": "node_xyz",
"relationship_type": "shaped",
"strength": 0.9
}
],
"total_nodes": 42,
"total_relationships": 15
}

The snapshot reconstructs the graph state as it existed at the given timestamp by:

  • Including nodes that were created before the timestamp and not yet deleted
  • Using historical node state (from node history) at that point in time
  • Including relationships that existed at that time

Use cases:

  • Audit views: "What did the graph look like before this change?"
  • Time-travel visualization
  • Debugging data changes

Building Graph Views (Third-Party Apps)

Third-party apps can construct graph data by combining nodes and relationships:

# Get all identity nodes
nodes = requests.get(
"https://api.ofself.ai/api/v1/nodes",
headers={"X-API-Key": API_KEY, "X-User-ID": USER_ID},
params={"view": "identity", "include_tags": "true", "limit": 100}
).json()

# Get relationships
relationships = requests.get(
"https://api.ofself.ai/api/v1/relationships",
headers={"X-API-Key": API_KEY, "X-User-ID": USER_ID},
params={"view": "identity", "include_nodes": "true"}
).json()

# Use with D3.js, vis.js, react-force-graph, etc.
graph_data = {
"nodes": nodes["nodes"],
"edges": relationships["relationships"]
}