Skip to main content
GET
Get documentation context

Authorizations

Authorization
string
header
required

Get your API key at context7.com/dashboard. Treat your API key like a password and store it securely. Every key can read the management API (/v2/teamspaces/*), except personal data: member and invitation emails, library requesters, visitor questions, Docs7 reader searches, conversations, feedback and feature requests, and the GitHub account behind a build. To read those or make changes there, the key must be created with Write access ticked; other keys get 403 write_access_required. A teamspace can limit API keys to owners and admins, or turn them off for OAuth only; a key that its teamspace's policy refuses gets 403 api_key_admins_only or api_keys_disabled.

Query Parameters

libraryId
string
required

Context7-compatible library ID — the URL path of the library on context7.com. Use /owner/repo for GitHub repositories, or /<source>/<id> for other sources (websites, llms.txt, GitLab/Bitbucket, etc.). Optionally suffix with /<version> or @<version> to pin a specific version. See Library ID format.

Required string length: 1 - 500
Pattern: ^/[^/]+/[^/]+([/@][^/]+)?$
query
string
required

User's original question or task - used for intelligent relevance ranking

Required string length: 1 - 500
type
enum<string>
default:txt

Response format type

Available options:
json,
txt
fast
enum<string>
default:false

When true, skip LLM reranking and return top vector-search results directly. Trades relevance quality for lower latency.

Available options:
true,
false
language
string

Optional programming language the caller writes in, such as Python or TypeScript. A soft ranking preference: the SDK and code examples in that language rank first, and other documentation is still returned when nothing in that language matches. Only the first 40 characters are used.

version
string

Optional version of the library the caller's project uses, such as 15.4.3. It wins over a version in libraryId. A value copied from a package file (^15.4.3, ~1.2, 15.x) keeps its first version. latest (any case) is the same as no version; any other value with no version (any) is a 400 validation_error with the message Invalid version, as on /v3/search. A version with indexed documentation is served as is. Otherwise the smallest indexed version above it in its major serves it (versions are tagged at the newest release of a group of releases whose docs barely differ, so that version covers the releases below it); for an old major newer than all its indexed versions, that major's newest version; else the current documentation. The response then names the version served (a Version note in text, the version field in JSON).

Pattern: ^([Ll][Aa][Tt][Ee][Ss][Tt]|(.*[^A-Za-z0-9._])?[Vv]?[0-9].*)$

Response

Documentation context

Documentation context response

codeSnippets
object[]
required

Relevant code snippets

infoSnippets
object[]
required

Relevant documentation snippets

libraryId
string

ID of the library that served the response, with the requested version tag. It differs from the requested ID when the library has moved; a served version that differs from the requested one is reported in version.

Example:

"/vercel/next.js"

rules
object

Optional library-specific rules and guidelines

version
object

Present only when the library ID names a version that is not indexed. Says what was served instead, with the fields of each entry of the Search API's version.libraries. The text response states the same in a leading version note when the status is unverified.

Example: