Use the Context7 REST API directly with curl or HTTP clients when you need raw library search and context retrieval via CONTEXT7_API_KEY. Use this skill for scripted lookups, debugging Context7 results, or when the user explicitly wants the HTTP API instead of the ctx7 CLI.
Use this skill when the user wants direct Context7 HTTP requests instead of the ctx7 CLI.
Do not use this skill for normal doc lookup if context7-cli or find-docs already fits better. Use it when:
curl, REST, or HTTP usageContext7 REST API requests need:
-H "Authorization: Bearer $CONTEXT7_API_KEY"
Do not inline real API keys into committed files, scripts, or logs.
Always use the two-step flow:
libraryIdlibraryIdUse /api/v2/libs/search to find the correct library.
curl -X GET "https://context7.com/api/v2/libs/search?libraryName=next.js&query=setup+ssr" \
-H "Authorization: Bearer $CONTEXT7_API_KEY"
Guidance:
libraryName should be the product or package name the user mentionedquery should be the actual task or question, URL-encodedlibraryId before moving to step 2Use /api/v2/context with the exact libraryId from search.
curl -X GET "https://context7.com/api/v2/context?libraryId=/vercel/next.js&query=setup+ssr&type=txt" \
-H "Authorization: Bearer $CONTEXT7_API_KEY"
Guidance:
libraryId must come from search or an exact known Context7 library IDquery should stay specific to the user tasktype=txt is the default text-oriented response shape for prompt/context use+ or %20&Example with variables:
LIBRARY_NAME="next.js"
QUERY="setup ssr"
curl -X GET "https://context7.com/api/v2/libs/search?libraryName=${LIBRARY_NAME}&query=setup+ssr" \
-H "Authorization: Bearer $CONTEXT7_API_KEY"
/context before resolving a valid libraryIdlibraryIdAuthorization headerhooks or auth instead of the concrete user task401 or 403: missing, invalid, or unauthorized CONTEXT7_API_KEY404: invalid libraryId or endpoint misuse429: rate limit or quota issue; retry later or confirm account limitsIf the REST call fails, report the exact HTTP error and whether the failure happened during search or context.