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.
๐บ 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:
- Fork this repo
- Create a HuggingFace Space โ Docker runtime โ connect repo
- Create free Redis at upstash.com
- Add environment variables in Space Settings โ Secrets
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file knowledge_universe-0.3.0.tar.gz.
File metadata
- Download URL: knowledge_universe-0.3.0.tar.gz
- Upload date:
- Size: 30.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a35af44ca5ffe0a4815ed879795eb654545ec3d06df1d0f297dcbc03f9d2525f
|
|
| MD5 |
3c655af11db4fdc6cd0bff9a3fc8af07
|
|
| BLAKE2b-256 |
798925e06b1dd478725a8059f8beb1dcf2421a2ab3c3998f65b33833728934d1
|
File details
Details for the file knowledge_universe-0.3.0-py3-none-any.whl.
File metadata
- Download URL: knowledge_universe-0.3.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f661d105dcc9e6cf84b1b68e6f6321f40ddf514d75949e5de44f5298058744c8
|
|
| MD5 |
657c590198f8937d180e1f7336ed83b8
|
|
| BLAKE2b-256 |
361c70ec20bed1a16490448c60f800d80aaf174ef7dc75da9edd924435f8d3b0
|