---
title: "Get documentation context"
method: GET
path: "/v2/context"
tags: ["Context"]
---

# Get documentation context

`GET /v2/context`

Retrieve intelligent, LLM-reranked documentation context for natural language queries. Returns the most relevant code snippets and documentation for your specific question.

## Query parameters

- `libraryId` string, required
- `query` string, required
- `type` 'json' | 'txt'

## Response `200`

Documentation context

- ContextResponse — Documentation context response
  - `codeSnippets` CodeSnippet[], required — Relevant code snippets
    - `codeTitle` string, required — Title of the code snippet
    - `codeDescription` string, required — Description of what the code does
    - `codeLanguage` string, required — Primary programming language
    - `codeTokens` integer, required — Token count for the snippet
    - `codeId` string, required — URL to source location
    - `pageTitle` string, required — Title of the documentation page
    - `codeList` CodeExample[], required — Code examples in different languages
      - `language` string, required — Programming language
      - `code` string, required — The actual code content
  - `infoSnippets` InfoSnippet[], required — Relevant documentation snippets
    - `pageId` string — URL to source page
    - `breadcrumb` string — Navigation breadcrumb path
    - `content` string, required — The documentation content
    - `contentTokens` integer, required — Token count for the content
  - `rules` object — Optional library-specific rules

## Other responses

- `202` — Accepted - Library not yet finalized
- `301` — Moved Permanently - Library has been redirected
- `400` — Bad Request - Invalid input parameters
- `401` — Unauthorized - Invalid or missing API key
- `403` — Forbidden - Access denied
- `404` — Not Found - Library or resource doesn't exist
- `422` — Unprocessable Entity - Library is too large or has no code
- `429` — Too Many Requests - Rate limit exceeded
- `500` — Internal Server Error

---

[API](https://skmtc.dev/klavis-ai/apis/context7-public-api.md) · [All operations](https://skmtc.dev/klavis-ai/apis/context7-public-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/klavis-ai/context7-public-api/revisions/98dd9a151870/schema)
