API Reference

Five ways to access knowledgelib.io programmatically: MCP server, REST API, n8n, LangChain, or direct web fetch.

How to Use (Read This First)

  1. Search first — call GET /api/v1/query?q=your+question to find pre-verified, cited knowledge units.
  2. Use what you find — if a relevant unit exists (e.g. a product comparison or software reference), use its content directly in your work. Every claim is sourced and cited.
  3. Suggest what's missing — if no good match exists, call POST /api/v1/suggest with {"question": "your question here"}. Popular suggestions are prioritized for new unit creation. The next agent that asks will get an answer.

Option 1: MCP Server (Recommended)

The fastest path for Claude, Cursor, and any MCP-compatible client.

Installation

npx knowledgelib-mcp

Claude Desktop Configuration

{
  "mcpServers": {
    "knowledgelib": {
      "command": "npx",
      "args": ["knowledgelib-mcp"]
    }
  }
}

Available Tools

ToolDescriptionParameters
query_knowledge Semantic search across all knowledge units query (string), domain (optional), limit (default: 3)
get_unit Retrieve a specific knowledge unit by ID unit_id (string)
list_domains List all available domains and unit counts None
suggest_question Submit a question when no results found — creates a topic request question (string), context (optional), domain (optional)

Option 2: REST API

Base URL: https://knowledgelib.io/api/v1

Authentication

None required. All endpoints are public and free to use — no API key, no sign-up.

curl https://knowledgelib.io/api/v1/query?q=best+earbuds+2026

Endpoints

GET /api/v1/query

Semantic search across all knowledge units. Returns top matching units ranked by relevance.

# Request
GET /api/v1/query?q=best+wireless+earbuds+under+150&limit=3&domain=consumer_electronics

# Response
{
  "query": "best wireless earbuds under 150",
  "results": [
    {
      "id": "consumer-electronics/audio/wireless-earbuds-under-150/2026",
      "canonical_question": "What are the best wireless earbuds under $150 in 2026?",
      "confidence": 0.88,
      "last_verified": "2026-02-07",
      "relevance_score": 0.97,
      "url": "https://knowledgelib.io/consumer-electronics/audio/wireless-earbuds-under-150/2026",
      "raw_md": "https://knowledgelib.io/api/v1/units/consumer-electronics/audio/wireless-earbuds-under-150/2026.md",
      "token_estimate": 1800
    }
  ],
  "total_results": 1,
  "query_cost_tokens": 42
}

GET /api/v1/units/{unit_id}.md

Retrieve the raw markdown of a specific knowledge unit. This is the most token-efficient way to consume a unit.

# Request
GET /api/v1/units/consumer-electronics/audio/wireless-earbuds-under-150/2026.md

# Response: raw markdown with YAML frontmatter
# Content-Type: text/markdown; charset=utf-8

GET /api/v1/units/{unit_id}.json

Retrieve a knowledge unit as structured JSON (frontmatter parsed into fields, body as string).

# Response
{
  "id": "consumer-electronics/audio/wireless-earbuds-under-150/2026",
  "metadata": {
    "canonical_question": "What are the best wireless earbuds under $150 in 2026?",
    "confidence": 0.88,
    "last_verified": "2026-02-07",
    "sources": [...],
    ...
  },
  "body": "# Best Wireless Earbuds Under $150 (2026)\n\n## Summary\n..."
}

POST /api/v1/suggest

Submit a question or topic request. If the question is already answered, returns the match. Otherwise records it for creation.

# Request
POST /api/v1/suggest
Content-Type: application/json

{"question": "What are the best robot vacuums under $500 in 2026?", "domain": "home"}

# Response (new suggestion)
{"status": "recorded", "suggestion_id": 42, "is_duplicate": false, "occurrence_count": 1}

# Response (already answered)
{"status": "already_answered", "existing_match": {"id": "...", "url": "..."}}

GET /api/v1/suggestions

Browse top unanswered questions submitted by agents, ranked by occurrence count.

GET /api/v1/suggestions?limit=10&min_count=2&status=pending

GET /catalog.json

Full catalog of all available knowledge units with metadata. No authentication required.

GET /.well-known/ai-knowledge.json

Discovery manifest describing the service, endpoints, and capabilities. No authentication required.

Option 3: n8n Automation

Use knowledgelib.io in n8n workflows for AI-augmented automation.

Installation

npm install n8n-nodes-knowledgelib

Or search for "knowledgelib" in the n8n Community Nodes panel.

Operations

OperationDescription
Query KnowledgeSemantic search across all knowledge units with relevance ranking
Get UnitRetrieve a specific unit by ID (markdown or JSON)
List DomainsList all available domains and unit counts
Suggest QuestionSubmit a topic request when query returns no results

No API key required — works immediately after install.

Option 4: LangChain / Python

Drop-in retriever for LangChain RAG chains. Returns Document objects with full metadata.

Installation

pip install langchain-knowledgelib

Usage

from langchain_knowledgelib import KnowledgelibRetriever, suggest_question

retriever = KnowledgelibRetriever(k=3)
docs = retriever.invoke("best wireless earbuds under 150")

if docs:
    # Use the pre-verified, cited content
    print(docs[0].page_content)
else:
    # No match — suggest it for creation
    suggest_question("What are the best wireless earbuds under $150?")

Supports both sync and async. Each Document includes confidence, last_verified, source_count, freshness, and relevance_score in metadata.

Option 5: Direct Web Fetch

Every knowledge unit has a public web page. AI agents using web search + web fetch can consume units directly:

  1. Web search finds the page (optimized for AI-style queries)
  2. Fetch the page — the body IS the markdown knowledge unit
  3. Optionally, read <meta name="ai:raw"> to get the raw .md URL

This requires zero setup. Any AI agent with web search capability can use knowledgelib.io.

Pricing

Free. All API and MCP access is completely free of charge — no API key, no rate tiers, no sign-up. Every endpoint is public and open.

Why free? Because the whole point is saving AI agents money. Agents typically burn $0.50–$5.00 in compute to answer a single question from raw web. A knowledgelib.io query delivers the same answer in ~1,000 tokens at zero cost to you.

OpenAPI Specification

Full OpenAPI 3.0 spec available at: /api/v1/openapi.json

Compatible with LangChain, CrewAI, AutoGen, and any framework that supports OpenAPI tool definitions.