CLI to query the Context7 API
npm install context7c7)
A simple and convenient command-line interface (CLI) for interacting with the Context7 API.
Quickly search for projects, get information about them, and query specific topics within a project's context, all directly from your terminal. Provides the c7 command.
⚠️ Important: All data provided by this tool comes directly from the official Context7 API (https://context7.com). This tool is simply a convenient wrapper and does not generate or host any content itself.
* Query: Ask questions or request information on specific topics within a project's documentation context.
* Search: Discover available projects indexed by Context7 based on keywords.
* Info: Get metadata about a specific project (like its source repository, last update time, etc.).
* Flexible Output: Get query results in plain text (txt, default) or structured json.
* Save Results: Easily save query output directly to a file (llms_{project}.{format}).
* User-Friendly: Uses spinners for feedback during API calls and colored output for readability.
* Node.js (Version 18+ recommended for native fetch, but should work with v16+ if needed)
* npm (usually comes with Node.js) or Bun
``bash`
npm install -g context7
yarn i -g context7
bun i -g context7
The basic command structure is:
`bash`
c7 [command] [arguments...] [options...]
#### 1. Query (Default Command)
Fetches information about a specific topic within a project. This is the default command if no other command (search, info) is specified.
Syntax:
`bash`
c7
Arguments:
* : The exact name of the project (e.g., nextjs, react, uv). Use c7 search to find valid names. (Required)
* : The topic, question, or keywords to query within the project's context. (Required)
Options:
* --type, -t: Specify the output format.txt
* (Default)json
* --save
* , -s: Save the output to a file named llms_{projectname}.{format} in the current directory instead of printing to the console. (Boolean flag)--tokens
* , -k: Specify the maximum number of tokens for the API response. (e.g., --tokens 1000). The API default is used if omitted. (Number)
Examples:
`bashGet info about data fetching in Next.js (default TXT output)
c7 nextjs data fetching strategies
#### 2. Search
Searches for available Context7 projects based on a keyword in their title. It filters out projects whose internal path contains a
/, as these are often duplicates or not directly queryable via this tool.Syntax:
`bash
c7 search
`Arguments:
*
: The keyword to search for in project titles (e.g., react, python, aws). (Required)Example:
`bash
c7 search next
Output might look like:
--- Search Results (Use "Project Name" for queries) ---
- Next.js (Project Name: nextjs)
-------------------------------------------------------
Example query: c7 nextjs
`#### 3. Info
Displays metadata associated with a specific project.
Syntax:
`bash
c7 info
`Arguments:
*
: The exact project name (e.g., nextjs, react). Use the name shown in parentheses from the search command results. (Required)Example:
`bash
c7 info react
Output will show details like Title, Project Name, Docs Source, Last Update, etc.
`$3
You can always get help on commands and options:
`bash
c7 --help # General help for all commands
c7 query --help # Help specifically for the query command (same as default)
c7 search --help # Help for the search command
c7 info --help # Help for the info command
`Development
1. Clone the repository.
2. Install dependencies (
npm install or bun install).
3. Link for local testing (npm link or bun link`).