Getting Started
@upstash/context7-sdk is a TypeScript SDK for Context7, enabling easier access to library documentation with full type coverage.
Using @upstash/context7-sdk you can:
- Search across available libraries
- Retrieve code documentation with contextual examples
- Fetch informational documentation and guides
- Access library metadata and versioning information
- Filter documentation by topic and pagination
Install
Usage
Initializing the Client
To use the Context7 SDK, you need an API key. You can get your API key from the Context7 Dashboard.Using environment variables
The SDK automatically reads from environment variables if no API key is provided in the config:Using a configuration object
If you prefer to pass configuration in code, the constructor accepts a config object containing the apiKey value. This could be useful if your application needs to interact with multiple projects, each with a different configuration.The SDK checks for API keys in this order: 1.
config.apiKey (if provided) 2.
process.env.CONTEXT7_API_KEYQuick Start Example
Error Handling
The SDK throwsContext7Error for API errors:
Next Steps
Explore the SDK commands:- Search Library - Search for libraries
- Get Docs - Retrieve library documentation