Authentication
All API requests require authentication using an API key. Include your API key in theAuthorization header:
API Methods
Library ID format
A library ID is the URL path of the library on context7.com. If the library page is athttps://context7.com/websites/uploadcare, its ID is /websites/uploadcare. The same ID works for every endpoint that accepts a libraryId or libraryName — including Get Context and Refresh Library.
Use /owner/repo for GitHub repositories, or /<source>/<id> for other sources:
You can pin a specific version with either
/owner/repo/<version> or /owner/repo@<version>:
Search documentation in one request
The Search API is the simplest way to retrieve documentation. You provide a question, and Context7 selects relevant libraries before searching and reranking their snippets. If no documentation matches, Search returns404 no_documentation_found; treat it as an empty result. A temporary search failure returns 503 search_failed and can be retried.
version with at least one library hint, and use language when you want language-specific examples to rank higher.
Choose a library yourself
Use Search Library followed by Get Context when your application needs to inspect or choose a specific documentation source.Each Search API call counts as one request. The two-step flow makes two API calls when it searches for a library and then retrieves its documentation.
For TypeScript SDK usage, see Search, Search Library, and Get Context.
Rate Limits
- Without API key: Low rate limits and no custom configuration
- With API key: Higher limits based on your plan
- View current usage and reset windows in the dashboard.
429 status code with these headers:
Best Practices
Be Specific with Queries
Use detailed, natural language queries for better results:Add hints only when they provide useful context
Start with only the question when the relevant library is clear from the task. Add library hints when a name is ambiguous or when the answer needs documentation from more than one product.Cache Responses
Documentation updates are relatively infrequent, so caching responses for several hours or days reduces API calls and improves performance.Handle Rate Limits
Implement exponential backoff for rate limit errors:Use Specific Versions
Pin to a specific version for consistent results. Both/ and @ syntax are supported:
Error Handling
The Context7 API uses standard HTTP status codes:
All errors return a JSON object with
error and message fields:
301 redirects, the response also includes a redirectUrl field pointing to the new library ID.