Skip to main content
GET
/
v2
/
context
Get documentation context
curl --request GET \
  --url https://context7.com/api/v2/context \
  --header 'Authorization: Bearer <token>'
{ "codeSnippets": [ { "codeTitle": "Middleware Authentication Example", "codeDescription": "Shows how to implement authentication checks in Next.js middleware", "codeLanguage": "typescript", "codeTokens": 150, "codeId": "https://github.com/vercel/next.js/blob/canary/docs/middleware.mdx#_snippet_0", "pageTitle": "Middleware", "codeList": [ { "language": "typescript", "code": "import { NextResponse } from 'next/server'\nimport type { NextRequest } from 'next/server'\n\nexport function middleware(request: NextRequest) {\n const token = request.cookies.get('token')\n if (!token) {\n return NextResponse.redirect(new URL('/login', request.url))\n }\n return NextResponse.next()\n}" } ] } ], "infoSnippets": [ { "pageId": "https://github.com/vercel/next.js/blob/canary/docs/middleware.mdx", "breadcrumb": "Routing > Middleware", "content": "Middleware allows you to run code before a request is completed...", "contentTokens": 200 } ] }

Documentation Index

Fetch the complete documentation index at: https://context7.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Get your API key at context7.com/dashboard. Treat your API key like a password and store it securely.

Query Parameters

libraryId
string
required

Context7-compatible library ID in format /owner/repo, /owner/repo/version, or /owner/repo@version

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
researchMode
enum<string>
default:false

When true, run a deeper agentic research pipeline that returns a single synthesized infoSnippet instead of ranked snippets. Requires an API key and is subject to a weekly per-user quota.

Available options:
true,
false

Response

Documentation context

Documentation context response

codeSnippets
object[]
required

Relevant code snippets

infoSnippets
object[]
required

Relevant documentation snippets

rules
object

Optional library-specific rules and guidelines