🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@upstash/context7-sdk

Package Overview
Dependencies
Maintainers
8
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@upstash/context7-sdk

JavaScript/TypeScript SDK for Context7

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
8
Created
Source

Upstash Context7 SDK

@upstash/context7-sdk is an HTTP/REST based client for TypeScript, built on top of the Context7 API.

Why Context7?

LLMs rely on outdated or generic training data about the libraries you use. This leads to:

  • Code examples based on year-old training data
  • Hallucinated APIs that don't exist
  • Generic answers for old package versions

Context7 solves this by providing up-to-date, version-specific documentation and code examples directly from the source. Use this SDK to:

  • Build AI agents with accurate, current documentation context
  • Create RAG pipelines with reliable library documentation
  • Power code generation tools with real API references

Quick Start

Install

npm install @upstash/context7-sdk

Get API Key

Get your API key from Context7

Basic Usage

import { Context7 } from "@upstash/context7-sdk";

const client = new Context7({
  apiKey: "<CONTEXT7_API_KEY>",
});

// Search for libraries in the Context7 database
const libraries = await client.searchLibrary("react");
console.log(libraries.results);

// Query the documentation with specific topics
const filteredDocs = await client.getDocs("/facebook/react", {
  topic: "hooks",
  limit: 10,
  page: 1,
});

// Get documentation as JSON by default
const docs = await client.getDocs("/vercel/next.js");
console.log(docs.snippets);

// Get documentation as TXT
const codeDocs = await client.getDocs("/mongodb/docs", {
  format: "txt",
  mode: "code",
});
console.log(codeDocs.content);

Configuration

Environment Variables

You can set your API key via environment variable:

CONTEXT7_API_KEY=ctx7sk-...

Then initialize without options:

const client = new Context7();

Docs

See the documentation for details.

Contributing

Running tests

pnpm test

Building

pnpm build

Keywords

context7

FAQs

Package last updated on 28 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts