Skip to main content

Universal knowledge retrieval API โ€” 18 sources, decay scoring, 3D/audio/simulation support

Project description


title: Knowledge Universe API emoji: ๐ŸŒŒ colorFrom: purple colorTo: green sdk: docker pinned: false

Knowledge Universe API

The Knowledge Layer for AI That Stays Current.
One API. 13+ official sources. Every result scored for freshness and decay.
Drop into any RAG pipeline. Your keys. Our intelligence.

Python 3.11+ FastAPI Redis License: MIT Live API


๐Ÿ“บ See It In Action

Cold Start vs. Cache Hit (3.5s โ†’ 14ms):

Full 90-Second Walkthrough โ€” 13 Crawlers, Decay Scores, Coverage Confidence:

0:15 Deep parallel search across 13+ sources ย |ย  0:30 14ms cache hits ย |ย  1:15 LLM reranking ย |ย  1:25 LangChain/LlamaIndex-ready output


The Problem

Your RAG pipeline answered with confidence. The source was 18 months old. Nothing broke. Nothing warned you.

LLM + vector store:    "The answer is X"  (source: Stack Overflow, 2021)
Knowledge Universe:    decay_score=0.72, label="stale"  โ† caught before it reaches your LLM

Every retrieval API today โ€” Tavily, Exa, SerpAPI โ€” returns results confidently. None of them tell you when those results are stale, mismatched to your query, or sourced from domains that age fast. Knowledge Universe is the first retrieval API built around time-awareness.


What This Does

Knowledge Decay Score

Every result carries a decay score from 0.0 (fresh) to 1.0 (fully decayed), computed from publication date, source type, and half-life constants tuned per platform:

decay = 1 - 0.5 ^ (age_days / half_life)
0.00 โ€“ 0.25  โ†’  fresh    โœ…  safe to use
0.25 โ€“ 0.50  โ†’  aging    โš ๏ธ  use with awareness
0.50 โ€“ 0.75  โ†’  stale    ๐Ÿ”ถ  verify before using
0.75 โ€“ 1.00  โ†’  decayed  โŒ  find a newer source

Coverage Confidence Score

The only retrieval API that tells you when it didn't find what you were looking for:

"coverage_intelligence": {
  "confidence": 0.71,
  "confidence_label": "high",
  "coverage_warning": false,
  "suggested_queries": []
}

When confidence is low, it suggests better search terms โ€” automatically.


Live API

Base URL https://vlsiddarth-knowledge-universe.hf.space
Health https://vlsiddarth-knowledge-universe.hf.space/health
Swagger UI https://vlsiddarth-knowledge-universe.hf.space/api-docs
Sign up POST /v1/signup?email=you@email.com

Quick Start

1. Get a free API key (no credit card)

curl -X POST "https://vlsiddarth-knowledge-universe.hf.space/v1/signup?email=you@email.com"
{
  "status": "created",
  "api_key": "ku_test_abc123...",
  "tier": "free",
  "calls_limit": 500,
  "message": "Save your API key โ€” it won't be shown again."
}

2. Discover sources with decay scores

curl -X POST https://vlsiddarth-knowledge-universe.hf.space/v1/discover \
  -H "X-API-Key: ku_test_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "topic": "transformer architecture",
    "difficulty": 3,
    "formats": ["pdf", "github", "stackoverflow"],
    "max_results": 5
  }'

3. Python โ€” read decay scores

import requests

resp = requests.post(
    "https://vlsiddarth-knowledge-universe.hf.space/v1/discover",
    headers={"X-API-Key": "ku_test_abc123..."},
    json={
        "topic": "RAG retrieval augmented generation",
        "difficulty": 3,
        "formats": ["pdf", "github"]
    }
).json()

# Every result has a decay score
for sid, decay in resp["decay_scores"].items():
    print(f"{decay['label']:8} score={decay['decay_score']:.2f}  {sid}")

# Coverage confidence โ€” did KU find good results?
cov = resp["coverage_intelligence"]
if cov["coverage_warning"]:
    print("Low confidence. Try:", cov["suggested_queries"])

4. LangChain integration

from knowledge_universe import KUClient  # pip install knowledge-universe

ku = KUClient(api_key="ku_test_...")
results = ku.discover("transformer architecture", difficulty=3)

# Direct LangChain injection
docs = results.to_langchain()  # List[Document] with decay_score in metadata

# Filter stale sources before they reach your LLM
safe_docs = [d for d in docs if d.metadata["decay_score"] < 0.5]

Response Schema

{
  "query": "transformer architecture",
  "total_found": 8,
  "cache_hit": false,
  "processing_time_ms": 3467.4,
  "credits_used": 1,
  "credits_remaining": 499,

  "decay_scores": {
    "arxiv:1706.03762": {
      "decay_score": 0.847,
      "freshness": 0.153,
      "label": "stale",
      "age_days": 2736,
      "penalty_multiplier": 0.268
    }
  },

  "coverage_intelligence": {
    "confidence": 0.71,
    "confidence_label": "high",
    "coverage_warning": false,
    "warning_message": null,
    "suggested_queries": [],
    "top_result_similarities": [
      { "title": "Attention Is All You Need", "similarity": 0.823 }
    ]
  },

  "sources": [ ... ]
}

Performance

Metric Value vs. Competition
Cold query latency ~3.5s Faster than Tavily (5.3s)
Cache hit latency 14ms Near SerpAPI (3.5s cold)
Sources crawled 13 platforms arXiv, GitHub, YouTube, SO, Kaggle...
Gap analysis score 2.52/3 5/5 test queries passing
Decay scoring โœ… Yes Tavily โœ— ยท Exa โœ— ยท SerpAPI โœ—
Confidence score โœ… Yes Industry-unique
Difficulty-aware ranking โœ… Yes Industry-unique

Architecture

YOUR APP
   โ”‚
   โ–ผ  POST /v1/discover  (X-API-Key header)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  KNOWLEDGE UNIVERSE API                   โ”‚
โ”‚                                                          โ”‚
โ”‚  Auth + Quota Check (Redis)                              โ”‚
โ”‚    โ†“                                                     โ”‚
โ”‚  Cache Check (Redis) โ”€โ”€โ”€โ”€ HIT โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ 14ms return   โ”‚
โ”‚    โ†“ MISS                                                โ”‚
โ”‚  Parallel Crawl (13 crawlers, per-crawler timeouts)      โ”‚
โ”‚    โ”œโ”€โ”€ arXiv           (12s)  No key needed              โ”‚
โ”‚    โ”œโ”€โ”€ Wikipedia        (5s)  No key needed              โ”‚
โ”‚    โ”œโ”€โ”€ StackOverflow    (6s)  No key needed              โ”‚
โ”‚    โ”œโ”€โ”€ HuggingFace      (8s)  No key needed              โ”‚
โ”‚    โ”œโ”€โ”€ OpenLibrary      (5s)  No key needed              โ”‚
โ”‚    โ”œโ”€โ”€ MIT OCW          (5s)  No key needed              โ”‚
โ”‚    โ”œโ”€โ”€ Podcast Index    (5s)  No key needed              โ”‚
โ”‚    โ”œโ”€โ”€ GitHub REST      (8s)  Optional token             โ”‚
โ”‚    โ”œโ”€โ”€ YouTube          (8s)  Optional key               โ”‚
โ”‚    โ”œโ”€โ”€ Kaggle           (6s)  Optional credentials       โ”‚
โ”‚    โ”œโ”€โ”€ CommonCrawl      (2s)  Fast-fail                  โ”‚
โ”‚    โ”œโ”€โ”€ GHArchive        (2s)  Fast-fail                  โ”‚
โ”‚    โ””โ”€โ”€ LibGen           (4s)  Supplementary              โ”‚
โ”‚    โ†“                                                     โ”‚
โ”‚  Normalize โ†’ Quality Score โ†’ Deduplicate (MinHash LSH)  โ”‚
โ”‚    โ†“                                                     โ”‚
โ”‚  Knowledge Decay Engine  โ†โ”€โ”€ Core IP                    โ”‚
โ”‚    โ†“                                                     โ”‚
โ”‚  Platform-aware LLM Reranker (all-MiniLM-L6-v2)        โ”‚
โ”‚    โ†“                                                     โ”‚
โ”‚  Coverage Confidence Score (shared embeddings, ~10ms)   โ”‚
โ”‚    โ†“                                                     โ”‚
โ”‚  Cache result (Redis, 4h TTL)                           โ”‚
โ”‚    โ†“                                                     โ”‚
โ”‚  Return: Sources + Decay Scores + Coverage Intelligence  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

API Reference

Endpoints

Method Endpoint Auth Description
POST /v1/signup No Get free API key
GET /v1/usage Yes Monthly quota and reset
POST /v1/discover Yes Multi-platform discovery + decay scores
POST /v1/knowledge Yes Enterprise KnowledgeObjects + embeddings
GET /v1/formats No All 54 supported source formats
GET /v1/crawlers No Active crawlers and status
GET /v1/cache/stats Yes Redis hit rate and memory
GET /health No Liveness check + Redis status
GET /api-docs No Interactive Swagger UI

/v1/discover Request Body

Field Type Required Description
topic string โœ… Search query (2โ€“200 chars)
difficulty int 1โ€“5 โœ… 1 = beginner, 5 = research-level
formats string[] โ€” Default: ["pdf","video","github","jupyter"]
max_results int 1โ€“50 โ€” Default: 10
output string โ€” json | embeddings (default: json)
min_freshness float 0โ€“1 โ€” Filter sources below this freshness score

Pricing

Plan Price Calls/month
Free $0 500
Starter $29/mo 5,000
Growth $79/mo 20,000
Pro $199/mo 75,000
Enterprise Custom Unlimited

Knowledge Decay Engine

Half-lives are tuned per platform based on how fast knowledge becomes outdated:

Platform Half-life Why
HuggingFace 120 days ML moves fastest โ€” models superseded constantly
GitHub 180 days Code goes stale as dependencies update
YouTube 270 days Tutorials date quickly with library releases
Stack Overflow 365 days Answers age with framework versions
Kaggle 365 days Competition context becomes irrelevant
arXiv 3 years Research papers have long shelf life
MIT OCW 3 years Academic courses revised on cycles
Wikipedia 4 years Actively maintained, slow to decay
Open Library 5 years Books revised infrequently

Sources

Source API Key Formats
arXiv None pdf, latex, html
Wikipedia None html, knowledge_graph
Stack Overflow None html
HuggingFace Hub None dataset, jupyter
Open Library None epub, pdf, html
MIT OCW None html, pdf, video, problem_set
Podcast Index None podcast, audio, transcript
GitHub REST Optional github, jupyter, markdown
YouTube Data v3 Optional video, video_playlist, transcript
Kaggle Optional kaggle, jupyter, dataset

All 54 supported formats: GET /v1/formats


Competitive Comparison

Feature Knowledge Universe Tavily Exa SerpAPI
Cold latency 3.5s 5.3s 1.5s 3.5s
Knowledge decay score โœ… โœ— โœ— โœ—
Coverage confidence โœ… โœ— โœ— โœ—
Difficulty-aware ranking โœ… โœ— โœ— โœ—
Publication dates โœ… โœ— โœ… โœ…
Embeddings output โœ… โœ— โœ— โœ—
Format filtering โœ… โœ— โœ— โœ—
LangChain/LlamaIndex ready โœ… โœ… โœ— โœ—
No API key needed (bulk) โœ… โœ— โœ— โœ—

Run Locally (5 Minutes)

git clone https://github.com/VLSiddarth/Knowledge-Universe.git
cd Knowledge-Universe
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt

# Start Redis
docker run -d --name ku-redis -p 6379:6379 redis:7-alpine

# Configure
cp .env.example .env
# Edit .env: set DEMO_MODE=false, add optional API keys

# Start
uvicorn src.api.main:app --reload --host 0.0.0.0 --port 8000

Then visit http://localhost:8000/health โ€” should return {"status":"healthy","redis":"connected"}.

Environment Variables

Variable Required Description
REDIS_HOST โœ… Redis hostname (Upstash or local)
REDIS_PORT โœ… Redis port (default: 6379)
REDIS_PASSWORD โœ… Redis password
SECRET_KEY โœ… 64-char random string
DEMO_MODE โœ… Set to false for live crawling
GITHUB_TOKEN Recommended Unlocks GitHub crawler
YOUTUBE_API_KEY Recommended Unlocks YouTube crawler
KAGGLE_USERNAME Optional Unlocks Kaggle crawler
KAGGLE_KEY Optional Unlocks Kaggle crawler

Generate SECRET_KEY:

python -c "import secrets; print(secrets.token_hex(32))"

Deploy to Production

See DEPLOYMENT.md for the full guide (HuggingFace Spaces + Upstash Redis).

Short version:

  1. Fork this repo
  2. Create a HuggingFace Space โ†’ Docker runtime โ†’ connect repo
  3. Create free Redis at upstash.com
  4. Add environment variables in Space Settings โ†’ Secrets
  5. Push to main โ€” auto-deploys

Troubleshooting

Redis not connecting:

redis-cli ping  # Should return PONG

Check REDIS_HOST, REDIS_PORT, and REDIS_PASSWORD are all set correctly.

First request is slow (30โ€“60s on cold start):
Normal. The all-MiniLM-L6-v2 embedding model loads on first use. After that, cache hits return in ~14ms.

GitHub / YouTube / Kaggle returning 0 results:
These crawlers return empty silently without credentials. Add keys to .env:

GITHUB_TOKEN=ghp_...
YOUTUBE_API_KEY=AIzaSy_...
KAGGLE_USERNAME=...
KAGGLE_KEY=...

422 Validation error on /v1/discover:
Check formats values are valid. Run GET /v1/formats to see all 54 accepted values.


Contributing

Pull requests welcome. See CONTRIBUTING.md for guidelines.

By contributing, you agree to grant Knowledge Universe a non-exclusive, irrevocable, royalty-free license to use your contributions.


License

MIT License โ€” see LICENSE.


Built with open source. No scrapers. No copyrighted data. Your keys, our intelligence.

Knowledge Universe โ€” because your RAG pipeline deserves to know how old its sources are.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

knowledge_universe-0.2.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

knowledge_universe-0.2.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file knowledge_universe-0.2.0.tar.gz.

File metadata

  • Download URL: knowledge_universe-0.2.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for knowledge_universe-0.2.0.tar.gz
Algorithm Hash digest
SHA256 262006657a983d549723d1a857c3fc2a9b7c77c434258be0676028600cc2ffb8
MD5 6f65b1d92b5c3a937a5da9447b3bd06d
BLAKE2b-256 5bf1ceba0aa0030d61f0228f47f5040d1dc5ce88103d933b2873a5cf936a2c2c

See more details on using hashes here.

File details

Details for the file knowledge_universe-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for knowledge_universe-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80799e6f62bf63d2dd7dcbf26e68c495d47f5b49ca8fbe69b727e71fd6ea35b9
MD5 f605ddd2fb474e0549b3c6a15ce6cf00
BLAKE2b-256 5c1c3303f39db81b7d0515ae3114a561823f910d971e70299d12943832c2c8eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page