context7
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseContext7
Context7
Overview
概述
This skill enables retrieval of current documentation for software libraries and components by querying the Context7 API via curl. Use it instead of relying on potentially outdated training data.
此技能通过curl调用Context7 API,能够检索软件库和组件的最新文档。请使用它来替代可能过时的训练数据。
Workflow
工作流程
Step 1: Search for the Library
步骤1:搜索库
To find the Context7 library ID, query the search endpoint:
bash
curl -s "https://context7.com/api/v2/libs/search?libraryName=LIBRARY_NAME&query=TOPIC" | jq '.results[0]'Parameters:
- (required): The library name to search for (e.g., "react", "nextjs", "fastapi", "axios")
libraryName - (required): A description of the topic for relevance ranking
query
Response fields:
- : Library identifier for the context endpoint (e.g.,
id)/websites/react_dev_reference - : Human-readable library name
title - : Brief description of the library
description - : Number of documentation snippets available
totalSnippets
要查找Context7库ID,请查询搜索端点:
bash
curl -s "https://context7.com/api/v2/libs/search?libraryName=LIBRARY_NAME&query=TOPIC" | jq '.results[0]'参数:
- (必填):要搜索的库名称(例如:"react"、"nextjs"、"fastapi"、"axios")
libraryName - (必填):主题描述,用于相关性排序
query
响应字段:
- :用于上下文端点的库标识符(例如:
id)/websites/react_dev_reference - :易读的库名称
title - :库的简要描述
description - :可用的文档片段数量
totalSnippets
Step 2: Fetch Documentation
步骤2:获取文档
To retrieve documentation, use the library ID from step 1:
bash
curl -s "https://context7.com/api/v2/context?libraryId=LIBRARY_ID&query=TOPIC&type=txt"Parameters:
- (required): The library ID from search results
libraryId - (required): The specific topic to retrieve documentation for
query - (optional): Response format -
type(default) orjson(plain text, more readable)txt
要检索文档,请使用步骤1中的库ID:
bash
curl -s "https://context7.com/api/v2/context?libraryId=LIBRARY_ID&query=TOPIC&type=txt"参数:
- (必填):搜索结果中的库ID
libraryId - (必填):要检索文档的特定主题
query - (可选):响应格式 -
type(默认)或json(纯文本,更易读)txt
Examples
示例
React hooks documentation
React hooks 文档
bash
undefinedbash
undefinedFind React library ID
查找React库ID
curl -s "https://context7.com/api/v2/libs/search?libraryName=react&query=hooks" | jq '.results[0].id'
curl -s "https://context7.com/api/v2/libs/search?libraryName=react&query=hooks" | jq '.results[0].id'
Returns: "/websites/react_dev_reference"
返回: "/websites/react_dev_reference"
Fetch useState documentation
获取useState文档
Next.js routing documentation
Next.js 路由文档
bash
undefinedbash
undefinedFind Next.js library ID
查找Next.js库ID
curl -s "https://context7.com/api/v2/libs/search?libraryName=nextjs&query=routing" | jq '.results[0].id'
curl -s "https://context7.com/api/v2/libs/search?libraryName=nextjs&query=routing" | jq '.results[0].id'
Fetch app router documentation
获取App Router文档
undefinedFastAPI dependency injection
FastAPI 依赖注入
bash
undefinedbash
undefinedFind FastAPI library ID
查找FastAPI库ID
curl -s "https://context7.com/api/v2/libs/search?libraryName=fastapi&query=dependencies" | jq '.results[0].id'
curl -s "https://context7.com/api/v2/libs/search?libraryName=fastapi&query=dependencies" | jq '.results[0].id'
Fetch dependency injection documentation
获取依赖注入文档
Tips
提示
- Use for more readable output
type=txt - Use to filter and format JSON responses
jq - Be specific with the parameter to improve relevance ranking
query - If the first search result is not correct, check additional results in the array
- URL-encode query parameters containing spaces (use or
+)%20 - No API key is required for basic usage (rate-limited)
- 使用以获得更易读的输出
type=txt - 使用过滤和格式化JSON响应
jq - 参数要具体,以提高相关性排序
query - 如果第一个搜索结果不正确,请检查数组中的其他结果
- 对包含空格的查询参数进行URL编码(使用或
+)%20 - 基础使用无需API密钥(有速率限制)