Skip to main content
GET
/
v2
/
docs
/
code
/
{owner}
/
{repo}
Get code snippets for a library
curl --request GET \
  --url https://context7.com/api/v2/docs/code/{owner}/{repo} \
  --header 'Authorization: Bearer <token>'
{
"snippets": [
{
"codeTitle": "Create and Run Next.js App with create-next-app (Quick Start)",
"codeDescription": "Quickly set up and start a new Next.js application using `create-next-app` with various package managers. This command creates a new project directory, installs dependencies, and starts the development server. The `--yes` flag skips interactive prompts, enabling a default setup with TypeScript, Tailwind, ESLint, App Router, and Turbopack.",
"codeLanguage": "bash",
"codeTokens": 185,
"codeId": "https://github.com/vercel/next.js/blob/canary/docs/01-app/01-getting-started/01-installation.mdx#_snippet_0",
"pageTitle": "Installation",
"codeList": [
{
"language": "bash",
"code": "pnpm create next-app@latest my-app --yes\ncd my-app\npnpm dev"
},
{
"language": "bash",
"code": "npx create-next-app@latest my-app --yes\ncd my-app\nnpm run dev"
},
{
"language": "bash",
"code": "yarn create next-app@latest my-app --yes\ncd my-app\nyarn dev"
},
{
"language": "bash",
"code": "bun create next-app@latest my-app --yes\ncd my-app\nbun dev"
}
]
}
],
"totalTokens": 185,
"pagination": {
"page": 1,
"limit": 10,
"totalPages": 10,
"hasNext": true,
"hasPrev": false
},
"metadata": {
"authentication": "none"
}
}

Authorizations

Authorization
string
header
required

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

Path Parameters

owner
string
required

Repository owner - GitHub username or organization name (case-insensitive)

Required string length: 1 - 500
repo
string
required

Repository name (case-insensitive)

Required string length: 1 - 500

Query Parameters

topic
string

Filter snippets by topic or search term

Maximum string length: 500
type
enum<string>
default:txt

Response format type

Available options:
json,
txt
page
integer
default:1

Page number for pagination (1-indexed). Maximum 10 pages accessible for each topic.

Required range: x >= 1
limit
integer
default:10

Number of items per page

Required range: 1 <= x <= 10

Response

Successful response with code snippets

Response containing code snippets

snippets
object[]
required

Array of code snippets

totalTokens
integer
required

Total token count for all returned snippets

pagination
object
required

Pagination metadata

metadata
object
required

Response metadata