> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kiwifs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Velocity, graph, and similarity

> Measure change velocity, analyze the wiki link graph, find related pages, and evaluate search quality.

These endpoints help you understand the shape of a knowledge base: which pages churn, which are central, how pages connect, which pages are related but not linked, and how well search finds the right page.

| Endpoint | Needs |
| - | - |
| Velocity | Git versioning |
| Graph endpoints | The link index (on by default). `503` when unavailable. |
| Suggestions, embeddings | Vector search. `503` when it is off. |
| Similar | A `[[similarity.profiles]]` block in config. `503` without one. |

## Change velocity

Analyze git history for a period: which pages change most, which don't change at all, which are suddenly busy, and which have a single author.

```http theme={null}
GET /api/kiwi/velocity
```

**period** `string` (default: 30d)

Window as a number followed by `d` (days), `w` (weeks), or `m` (months, counted as 30 days).

**limit** `integer` (default: 20)

Maximum entries in `hot_spots`.

**path\_prefix** `string`

Only analyze pages under this prefix.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/velocity?period=2w&limit=5'
```

Only markdown files are counted. Returns `500` if `git log` fails, for example when versioning is off.

**period** `string`

Period used.

**total\_changes** `integer`

File changes (one per commit per file) in the period.

**hot\_spots** `object[]`

Most changed pages, descending.

**properties**

**path** `string`

Page path.

**changes** `integer`

Commits touching the page.

**authors** `integer`

Distinct commit authors.

**lines\_changed** `integer`

Lines added plus lines deleted.

**cold\_spots** `object[]`

Every page with no changes in the period, each with `path` and `days_since_change`.

**bursts** `object[]`

Pages whose change rate over the last 7 days is more than three times their average for the period.

**properties**

**path** `string`

Page path.

**recent\_rate** `number`

Changes per day over the last 7 days.

**avg\_rate** `number`

Changes per day over the whole period.

**single\_author\_pages** `string[]`

Pages changed in the period by only one author.

```json theme={null}
{
  "period": "2w",
  "total_changes": 87,
  "hot_spots": [
    { "path": "concepts/auth.md", "changes": 12, "authors": 3, "lines_changed": 240 }
  ],
  "cold_spots": [
    { "path": "concepts/legacy.md", "days_since_change": 120 }
  ],
  "bursts": [
    { "path": "runbooks/deploy.md", "recent_rate": 1.29, "avg_rate": 0.36 }
  ],
  "single_author_pages": ["runbooks/deploy.md"]
}
```

## Graph analytics

Summarize the wiki link graph: size, connected components, orphans, and the highest PageRank pages.

```http theme={null}
GET /api/kiwi/graph/analytics
```

**limit** `integer` (default: 20)

Number of pages in `top_pages`.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/graph/analytics?limit=10'
```

**total\_nodes** `integer`

Pages in the link graph.

**total\_edges** `integer`

Wiki links.

**components** `integer`

Disconnected subgraphs.

**largest\_component\_size** `integer`

Pages in the largest component.

**orphans** `string[]`

Pages with no incoming links.

**top\_pages** `object[]`

Highest PageRank pages, each with `path`, `pagerank`, `in_degree`, and `out_degree`.

```json theme={null}
{
  "total_nodes": 142,
  "total_edges": 387,
  "components": 3,
  "largest_component_size": 138,
  "orphans": ["concepts/legacy.md"],
  "top_pages": [
    { "path": "concepts/auth.md", "pagerank": 0.042, "in_degree": 18, "out_degree": 5 }
  ]
}
```

## Centrality

Return PageRank, betweenness, and degree for every page, highest PageRank first.

```http theme={null}
GET /api/kiwi/graph/centrality
```

**limit** `integer`

Maximum pages. Omit to return all.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/graph/centrality?limit=20'
```

**pages** `object[]`

**properties**

**path** `string`

Page path.

**pagerank** `number`

PageRank score.

**betweenness** `number`

How often the page sits on shortest paths between other pages.

**in\_degree** `integer`

Incoming links.

**out\_degree** `integer`

Outgoing links.

```json theme={null}
{
  "pages": [
    { "path": "concepts/auth.md", "pagerank": 0.042, "betweenness": 0.18, "in_degree": 18, "out_degree": 5 }
  ]
}
```

## Communities

Group pages into topic clusters with Louvain community detection. Links are treated as undirected.

```http theme={null}
GET /api/kiwi/graph/communities
```

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/graph/communities'
```

**communities** `object[]`

Clusters, each with a numeric `id` and its `pages`.

```json theme={null}
{
  "communities": [
    { "id": 0, "pages": ["concepts/auth.md", "concepts/sessions.md", "runbooks/login-flow.md"] },
    { "id": 1, "pages": ["concepts/billing.md", "concepts/invoices.md"] }
  ]
}
```

## Shortest path

Return the shortest chain of wiki links from one page to another, following link direction.

```http theme={null}
GET /api/kiwi/graph/path
```

**from** `string` *required*

Start page.

**to** `string` *required*

End page.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/graph/path?from=concepts/auth.md&to=concepts/billing.md'
```

Returns `400` if either parameter is missing, and `404` if a page isn't in the graph or no path exists.

**path** `string[]`

Pages from `from` to `to`, inclusive.

```json theme={null}
{ "path": ["concepts/auth.md", "concepts/users.md", "concepts/billing.md"] }
```

## Graph walk

Return one page's immediate neighborhood: outgoing links, backlinks, and pages in the same folder or with a shared tag.

```http theme={null}
GET /api/kiwi/graph/walk
```

**path** `string` *required*

Page path.

**include\_siblings** `boolean` (default: true)

Set to `false` to skip folder and tag siblings, which requires scanning every page.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/graph/walk?path=concepts/auth.md'
```

Returns `404` if the page does not exist.

**path** `string`

Page path.

**links\_out** `string[]`

Wiki link targets in the page, as written.

**links\_in** `string[]`

Pages that link here.

**siblings** `object[]`

Each with `path`, `relation` (`sibling_dir` or `sibling_tag`), and `shared_tag` for tag siblings.

**hub\_score** `number`

Incoming links divided by pages in the graph.

**in\_degree** `integer`

Length of `links_in`.

**out\_degree** `integer`

Length of `links_out`.

```json theme={null}
{
  "path": "concepts/auth.md",
  "links_out": ["sessions", "api-keys"],
  "links_in": ["index.md", "runbooks/login-flow.md"],
  "siblings": [
    { "path": "concepts/sessions.md", "relation": "sibling_dir" },
    { "path": "runbooks/login-flow.md", "relation": "sibling_tag", "shared_tag": "security" }
  ],
  "hub_score": 0.014,
  "in_degree": 2,
  "out_degree": 2
}
```

## Link suggestions

Find pages that are semantically close to a page but not yet linked to or from it. Use this to discover missing wiki links.

```http theme={null}
GET /api/kiwi/suggestions
```

**path** `string` *required*

Page path.

**limit** `integer` (default: 10)

Maximum suggestions.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/suggestions?path=concepts/auth.md&limit=3'
```

Returns `400` if `path` is missing, `404` if the page does not exist, and `503` if vector search is off. `suggestions` is `null` when nothing qualifies.

**suggestions** `object[]`

**properties**

**target** `string`

Suggested page.

**similarity** `number`

Vector similarity score.

**snippet** `string`

Matching text from the suggested page.

```json theme={null}
{
  "suggestions": [
    { "target": "concepts/api-keys.md", "similarity": 0.89, "snippet": "API key authentication..." }
  ]
}
```

## Similar pages

Rank pages by how similar their frontmatter is, using Gower distance over the fields in a similarity profile. Query by a page, or by an inline set of field values for a case that isn't in the knowledge base yet.

```toml .kiwi/config.toml theme={null}
[[similarity.profiles]]
name = "dataset"
match = { kind = "dataset" }
numeric = ["stats.rows", "stats.columns"]
categorical = ["format", "license"]
weights = { "license" = 3.0 }
```

```http theme={null}
GET /api/kiwi/similar
```

**path** `string`

Page to find neighbors of. Required unless `vector` is set.

**vector** `string`

JSON object of field values. Combined with `path`, it overrides that page's values.

**profile** `string`

Profile name. Optional when only one profile is configured.

**k** `integer` (default: 5)

Number of neighbors.

```bash theme={null}
curl -G 'http://localhost:3333/api/kiwi/similar' \
  --data-urlencode 'vector={"format":"parquet","stats.rows":120000}' \
  --data-urlencode 'profile=dataset'
```

Returns `400` when neither `path` nor `vector` is given, the profile is unknown, `k` isn't a positive integer, or `vector` isn't a JSON object.

**profile** `string`

Profile used.

**query\_path** `string`

Page queried, if any.

**query\_vector** `object`

Field values compared against.

**fields** `string[]`

Profile fields.

**candidate\_count** `integer`

Pages considered.

**truncated** `boolean`

`true` if the candidate set hit its cap.

**neighbors** `object[]`

Most similar first.

**properties**

**path** `string`

Page path.

**score** `number`

Similarity from 0 to 1. Results are ordered by this.

**distance** `number`

Gower distance over the fields both sides have.

**rank\_distance** `number`

Distance that counts missing fields as maximally different.

**coverage** `number`

Weighted share of fields that could be compared.

**comparable\_fields** `integer`

Fields both sides had.

**total\_fields** `integer`

Fields in the profile.

**contributions** `object[]`

Per-field `field`, `kind`, `distance`, `weight`, `skipped`, and the two values `a` and `b`.

```json theme={null}
{
  "profile": "dataset",
  "query_vector": { "format": "parquet", "stats.rows": 120000 },
  "fields": ["stats.rows", "stats.columns", "format", "license"],
  "candidate_count": 38,
  "neighbors": [
    {
      "path": "datasets/orders.md",
      "score": 0.81,
      "distance": 0.06,
      "rank_distance": 0.19,
      "coverage": 0.5,
      "comparable_fields": 2,
      "total_fields": 4,
      "contributions": [
        { "field": "format", "kind": "categorical", "distance": 0, "weight": 1, "skipped": false, "a": "parquet", "b": "parquet" }
      ]
    }
  ]
}
```

## Embeddings

Return the stored text chunks and embedding vectors for a page.

```http theme={null}
GET /api/kiwi/embeddings
```

**path** `string` *required*

Page path.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/embeddings?path=concepts/auth.md'
```

Returns `400` if `path` is missing, `404` if the page has no embeddings, and `503` if vector search is off.

**path** `string`

Page path.

**dimensions** `integer`

Vector length.

**chunks** `object[]`

Each with `chunk_idx`, `text`, and `vector`.

```json theme={null}
{
  "path": "concepts/auth.md",
  "dimensions": 768,
  "chunks": [
    { "chunk_idx": 0, "text": "# Authentication\n\nOAuth2...", "vector": [0.012, -0.034, 0.051] }
  ]
}
```

## Search evaluation

Score full-text, semantic, and hybrid search against questions with known answers. Reports hit rate, MRR, precision, and nDCG at `top_k`. Same as `kiwifs eval`.

```http theme={null}
POST /api/kiwi/eval
```

**set** `string`

Golden set name. Loads `<set>.topics` and `<set>.qrels` from `.kiwi/eval/`. Use either `set` or `queries`.

**queries** `object[]`

Inline questions.

**properties**

**question** `string` *required*

Search text.

**expected\_paths** `string[]`

Relevant pages, each graded 1.

**grades** `object`

Map from path to graded relevance (higher is more relevant). Only nDCG uses grades.

**exclude\_prefix** `string | string[]`

Path prefixes hidden from retrieval before ranking. Use this for leave-one-out evaluation.

**top\_k** `integer` (default: 5)

Cutoff for every metric.

```bash Golden set theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/eval' \
  -H "Content-Type: application/json" \
  -d '{"set": "leave-one-out", "exclude_prefix": "drafts/", "top_k": 10}'
```

```bash Inline queries theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/eval' \
  -H "Content-Type: application/json" \
  -d '{
    "queries": [
      {"question": "how does authentication work", "expected_paths": ["concepts/auth.md"]},
      {"question": "deploy checklist", "expected_paths": ["runbooks/deploy.md"]}
    ]
  }'
```

Returns `400` when both or neither of `set` and `queries` are given or the set can't be loaded, and `500` if every search failed.

**top\_k** `integer`

Cutoff used.

**exclude\_prefix** `string[]`

Prefixes excluded, if any.

**fts** `object`

Full-text search metrics. `semantic` and `hybrid` have the same shape; `hybrid` only has data when vector search is on.

**properties**

**hit\_rate** `number`

Share of questions with a relevant page in the top `top_k`.

**mrr** `number`

Mean reciprocal rank of the first relevant page.

**precision\_at\_k** `number`

Mean precision in the top `top_k`.

**precision\_at\_5** `number` *deprecated*

Same value as `precision_at_k`.

**ndcg** `number`

Mean nDCG at `top_k`.

**queries** `integer`

Questions scored.

**semantic** `object`

Semantic search metrics.

**hybrid** `object`

Hybrid (reciprocal rank fusion) metrics.

**per\_query** `object[]`

Per question: `question`, `relevant`, and for each engine its rank (`fts_rank`, `semantic_rank`, `hybrid_rank`; `0` means not found), hits, and nDCG.

**skipped** `object[]`

Questions that couldn't be scored, each with `question` and `reason`.

**errors** `integer`

Failed searches.

```json theme={null}
{
  "top_k": 5,
  "fts": { "hit_rate": 1.0, "mrr": 0.75, "precision_at_k": 0.3, "precision_at_5": 0.3, "ndcg": 0.81, "queries": 2 },
  "semantic": { "hit_rate": 1.0, "mrr": 0.9, "precision_at_k": 0.4, "precision_at_5": 0.4, "ndcg": 0.88, "queries": 2 },
  "hybrid": { "hit_rate": 1.0, "mrr": 0.92, "precision_at_k": 0.4, "precision_at_5": 0.4, "ndcg": 0.9, "queries": 2 },
  "per_query": [
    {
      "question": "how does authentication work",
      "relevant": ["concepts/auth.md"],
      "fts_rank": 2, "semantic_rank": 1, "hybrid_rank": 1,
      "fts_hits": ["concepts/sessions.md", "concepts/auth.md"],
      "semantic_hits": ["concepts/auth.md"],
      "hybrid_hits": ["concepts/auth.md"],
      "fts_ndcg": 0.63, "semantic_ndcg": 1, "hybrid_ndcg": 1
    }
  ],
  "errors": 0
}
```

## MCP equivalents

`kiwi_velocity`, `kiwi_graph_analytics`, `kiwi_graph_centrality`, `kiwi_graph_communities`, `kiwi_graph_path`, `kiwi_graph_walk`, `kiwi_suggestions`, `kiwi_similar`, `kiwi_embeddings`, and `kiwi_eval`. The `kiwi_eligible` task-ranking tool is MCP-only; there is no REST endpoint for it.

## Related

> [card] [Analytics and health](https://docs.kiwifs.com/api/analytics.md)
>
> Page views, failed searches, and health checks.

> [card] [Search](https://docs.kiwifs.com/api/search.md)
>
> Full-text, semantic, and hybrid search.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.