Skip to main content

Search

Search Context7 documentation in one request. Context7 selects relevant libraries, searches them in parallel, and returns the best snippets together. The SDK returns structured JSON by default, consistent with its other methods. Set type to txt when you need plain text for an LLM prompt. The REST endpoint defaults to text unless you request type=json.

Arguments

string
required
The question or task to search for. Specific, natural language questions produce the best results.
SearchOptions

Text response

JSON response

JSON responses return a SearchResponse object with codeSnippets, infoSnippets, and optional rules. Each snippet includes the libraryId that it came from.
Use a library hint with version when your question depends on a particular release.
Library names do not need to be exact. Use a Context7 library ID when you need to select a specific documentation source. If nothing matches, client.search() throws Context7Error with status 404. A temporary search failure returns status 503 and follows the SDK retry policy.