Context

Get documentation context

Changed on

Retrieve intelligent, LLM-reranked documentation context for natural language queries. Returns the most relevant code snippets and documentation for your specific question. The text response lists them in relevance order across code and documentation; in JSON, rank gives that order. A version in the library ID that is not indexed is not an error: a ready tag that matches the requested numbers is served (15 serves v15.1.8); otherwise the newest stable release of the requested line when it is newer than the request (v2.3.1 for 2.0.0; below 1.0, the same minor), or else the library's current documentation. A prerelease tag serves only a request for that prerelease. The text response then starts with a version note when the served documentation is not the requested version, and the JSON response carries a version object. A version that is not indexed for a public GitHub library is queued for indexing in the background, so a later request for it can be answered. A branch or channel name that is not indexed (/owner/repo/canary), or a version with nothing ready to serve, still returns 404 version_not_found.

get/v2/context

Request

  • Base URL
    https://context7.com/api
  • URL
    https://context7.com/api/v2/context
  • Auth
    • none
    • or HTTP bearer

Query parameters

libraryIdstring 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.

querystring required

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

type'json' | 'txt'

Response format type

fast'true' | 'false'

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

languagestring

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.

Response

Documentation context

Example response

{
  "codeSnippets": [
    {
      "rank": 1
    }
  ],
  "infoSnippets": [
    {
      "rank": 1
    }
  ],
  "version": {
    "libraryId": "/vercel/next.js/v15.1.11",
    "requested": "v15.0.0",
    "served": "v15.1.11",
    "status": "unverified"
  }
}

Changes

    • info

      added the optional property to the response with the status

    • breaking

      the / response's property type changed from object to no type for status

    • breaking

      the / response's property type changed from object to no type for status

    • breaking

      removed the required property // from the response with the status

    • breaking

      removed the required property // from the response with the status

    • breaking

      removed the required property // from the response with the status

    • breaking

      removed the required property // from the response with the status

    • breaking

      removed the required property // from the response with the status

    • breaking

      removed the required property // from the response with the status

    • breaking

      removed the required property // from the response with the status

    • breaking

      removed the required property // from the response with the status

    • breaking

      removed the required property // from the response with the status

    • warning

      removed the optional property // from the response with the status

    • warning

      removed the optional property // from the response with the status

    • warning

      removed the optional property // from the response with the status

    • warning

      removed the optional property // from the response with the status

    • info

      added subschema #2 to the / response property allOf list for the response status

    • info

      added subschema #2 to the / response property allOf list for the response status