curl --request GET \
--url https://context7.com/api/v2/context \
--header 'Authorization: Bearer <token>'import requests
url = "https://context7.com/api/v2/context"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://context7.com/api/v2/context', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://context7.com/api/v2/context",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://context7.com/api/v2/context"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://context7.com/api/v2/context")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://context7.com/api/v2/context")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"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
}
]
}Get documentation context
Retrieve intelligent, LLM-reranked documentation context for natural language queries. Returns the most relevant code snippets and documentation for your specific question.
curl --request GET \
--url https://context7.com/api/v2/context \
--header 'Authorization: Bearer <token>'import requests
url = "https://context7.com/api/v2/context"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://context7.com/api/v2/context', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://context7.com/api/v2/context",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://context7.com/api/v2/context"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://context7.com/api/v2/context")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://context7.com/api/v2/context")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"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
}
]
}Authorizations
Get your API key at context7.com/dashboard. Treat your API key like a password and store it securely.
Query Parameters
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.
1 - 500^/[^/]+/[^/]+([/@][^/]+)?$User's original question or task - used for intelligent relevance ranking
1 - 500Response format type
json, txt When true, skip LLM reranking and return top vector-search results directly. Trades relevance quality for lower latency.
true, false Was this page helpful?