Skip to main content

Authentication

Use an API key with every request. Include your API key in the Authorization header:
Get your API key at context7.com/dashboard. Learn more about creating and managing API keys.

API Methods

Library ID format

A library ID is the URL path of the library on context7.com. If the library page is at https://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>:
Don’t know the ID for a library? Find it on context7.com — the URL path of the library page is the ID. Or call Search Library and use the id from the response.

Search Context7 documentation

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 returns 404 no_documentation_found; treat it as an empty result. A temporary search failure returns 503 search_failed and can be retried.
Library hints are optional and do not need to be exact. You can provide up to four names or exact Context7 library IDs. Use 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.

MCP Tools

The Context7 MCP server exposes the same lookups as agent tools. Each tool maps to one REST endpoint, with the same parameters as the query fields: Call the REST API directly to control requests from your own code, or use the MCP tools when you want an agent to fetch documentation automatically during inference. Both use the same API key.

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.
Call Get Usage (GET /api/v2/usage) to read the same numbers from your own code. The response has plan, usageResetsAt (when the monthly count resets, in UTC), member (the member who owns the API key, with requests this month and includedInPlan) and teamspace (all members, with extraRequests, extraCostUsd for the extra requests this month, spendingLimitUsd or null, and a daily array). Each daily entry has date and requests, plus searchRequests, docsRequests and extraCostUsd. The days query parameter sets how many days teamspace.daily covers, ending today in UTC. It defaults to 30, accepts 1 to 90, and on the Free plan returns at most the last 10 days. The member numbers match the RateLimit-* headers on search and docs responses. Calling this endpoint does not count as a request. When you exceed rate limits, the API returns a 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:
If that version is not indexed, the request still succeeds and serves the closest documentation Context7 has: a tag matching the requested numbers, a newer release of the same line, or the library’s current documentation. JSON responses include a version object that says which version was served. A text response starts with a version note when it serves another release or the current documentation. A branch or channel name that is not indexed, such as /vercel/next.js/canary, still returns 404 version_not_found. A library ID with no version tag also follows the version named in the question. For libraryId=/vercel/next.js and the query How do I cache in Next.js 15?, an older line than the library’s current documentation is served when Context7 has a matching indexed release, and the JSON version object reports that release as verified. When no indexed release matches, the current documentation is served as before, without a version object, and Context7 queues that version for indexing. A question that names more than one version, or that names the source of a migration such as upgrade from Next.js 15 to 16, leaves the current documentation in place.

Error Handling

The Context7 API uses standard HTTP status codes: All errors return a JSON object with error and message fields:
For 301 redirects, the response also includes a redirectUrl field pointing to the new library ID.

SDK and Libraries

For TypeScript SDK installation and usage, see the Getting Started guide.