---
title: "Get Graph Stats"
method: GET
path: "/api/v1/graph/stats"
tags: ["graph"]
---

# Get Graph Stats

`GET /api/v1/graph/stats`

## Request

- Base URL: `https://memory.kagura-ai.com` (the document declares no server; this is the origin it was published from)
- URL: `https://memory.kagura-ai.com/api/v1/graph/stats`
- Auth: none declared

Get Neural Memory graph statistics for specified context.

Issue #82: Context-scoped stats.
Issue #383: Authorization is delegated to ``PermissionService``. Previously
this endpoint hard-filtered by ``user_id == caller``, hiding shared-context
memories authored by other workspace members. Now:

    - Shared context (``is_private = false``): any workspace member sees
      the full graph for the context.
    - Private context (``is_private = true``): only the private-context
      creator can access the graph for that context. The creator-only
      rule matches ``can_access_memory`` (returns ``False`` for
      non-creators) and ``check_context_access`` (raises 403 for
      non-creators). This endpoint deliberately **remaps that denial
      to 404**, unifying with the cross-workspace-probe shape so
      neither path leaks existence — an intentional divergence from
      ``check_context_access``'s 403 status code, not from its
      authorization semantics.
    - Cross-workspace probes and private-context access by non-creators
      both surface as 404 (CWE-639 / OWASP A01 uniform disclosure)
      to avoid existence leakage.

Args:
    context_id: Optional context ID. When absent, returns an empty graph
        (no scope = no visible edges).

Returns:
    Graph statistics including node/edge counts, top connections, etc.

## Query parameters

- `context_id` string, uuid, nullable: Optional context ID. When absent, returns an empty graph (no scope = no visible edges) per Issue #383.

## Headers

- `authorization` string, nullable

## Response `200`

Successful Response

- GraphStatsResponse: Graph stats API response.
  - `user_id` string, required
  - `stats` GraphStats, required: Graph statistics response.
    - `total_nodes` integer, required
    - `total_edges` integer, required
    - `avg_edge_weight` number, required
    - `max_edge_weight` number, required
    - `min_edge_weight` number, required
    - `density` number, required
    - `top_connections` object[], required
    - `recent_edges` object[], required
  - `last_updated` string, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud.md) · [All operations](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/llms.txt) · [OpenAPI document](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/revisions/aa9df1a21db9?raw)
