Skip to main content
The Context7 SDK (@upstash/context7-sdk) provides a simple, type-safe interface for searching libraries and retrieving relevant documentation snippets programmatically.

What is Context7?

Context7 is a documentation retrieval service that helps you find and access relevant library documentation based on natural language queries. Instead of manually searching through docs, you can programmatically retrieve the exact information you need.

Key Features

  • Type-safe API: Full TypeScript support with detailed type definitions
  • Dual response formats: Get results as JSON objects or formatted text
  • Smart search: Query-based relevance ranking for better results
  • Automatic retries: Built-in retry logic with exponential backoff
  • Zero dependencies: Minimal footprint for production applications

Use Cases

AI-Powered Code Assistants

Provide your AI with relevant documentation context:

Library Discovery

Help users find the right libraries for their needs:

Documentation Chatbots

Build intelligent chatbots that answer framework-specific questions:

IDE Extensions

Create editor plugins that provide contextual documentation:

Core Concepts

Library IDs

Libraries are identified by a path-like ID format: /owner/repository Examples:
  • /facebook/react
  • /vuejs/core
  • /expressjs/express
  • /microsoft/typescript

Query-Based Ranking

Both searchLibrary and getContext use your query to rank results by relevance. More specific queries yield more targeted documentation.

Response Formats

  • JSON (default): Structured data as TypeScript objects
  • Text: Pre-formatted strings ready for display or LLM consumption

Next Steps

Installation

Install the SDK with npm, yarn, or pnpm

Client Setup

Initialize and configure the Context7 client

Search Libraries

Search for available libraries

Get Documentation

Retrieve relevant documentation snippets