Context7 — Real-Time Documentation Lookup
Retrieve current documentation for software libraries, frameworks, and components via the Context7 API. Use instead of relying on potentially outdated training data.
Workflow
Step 1: Search for the Library
curl -s "https://context7.com/api/v2/libs/search?libraryName=LIBRARY_NAME&query=TOPIC" | jq '.results[0]'
Parameters:
libraryName(required): e.g. "react", "nextjs", "fastapi", "axios"query(required): topic description for relevance ranking
Response: id (library identifier), title, description, totalSnippets
Step 2: Fetch Documentation
curl -s "https://context7.com/api/v2/context?libraryId=LIBRARY_ID&query=TOPIC&type=txt"
- Use
type=txtfor readable plain-text output - No API key required (rate-limited for basic usage)
- Be specific with
queryto improve relevance
Examples
# React hooks
curl -s "https://context7.com/api/v2/libs/search?libraryName=react&query=hooks" | jq '.results[0].id'
curl -s "https://context7.com/api/v2/context?libraryId=/websites/react_dev_reference&query=useState&type=txt"
# Next.js routing
curl -s "https://context7.com/api/v2/context?libraryId=/vercel/next.js&query=app+router&type=txt"
# FastAPI
curl -s "https://context7.com/api/v2/context?libraryId=/fastapi/fastapi&query=dependency+injection&type=txt"
Tips
type=txtgives more readable output than JSON- URL-encode spaces in queries (use
+or%20) - Check additional results if the first isn't correct
- No API key needed for basic usage