LangChain.js integration for Reader. Load web pages as LangChain Documents and use Reader as an agent tool.
npm install @vakra-dev/langchain-reader @langchain/coreUse ReaderLoader to scrape web pages and load them as LangChain Document objects for RAG pipelines.
import { ReaderLoader } from "@vakra-dev/langchain-reader";
// Single URL
const loader = new ReaderLoader({
apiKey: "rdr_...",
urls: ["https://example.com"],
});
const docs = await loader.load();
console.log(docs[0].pageContent); // Markdown content
console.log(docs[0].metadata); // { url, title, source, ... }
// Multiple URLs (batch)
const loader = new ReaderLoader({
apiKey: "rdr_...",
urls: [
"https://example.com/page1",
"https://example.com/page2",
"https://example.com/page3",
],
});
const docs = await loader.load();| Parameter | Type | Default | Description |
|---|---|---|---|
apiKey |
string | required | Reader API key |
urls |
string[] | required | URLs to scrape |
baseUrl |
string | undefined | Custom API URL for self-hosted Reader |
formats |
string[] | ["markdown"] | Output formats |
proxyMode |
string | undefined | "standard" or "premium" |
onlyMainContent |
boolean | true | Extract main content only |
Use ReaderScrapeTool to give LangChain agents the ability to read web pages.
import { ReaderScrapeTool } from "@vakra-dev/langchain-reader";
const tool = new ReaderScrapeTool({ apiKey: "rdr_..." });
// Use directly
const result = await tool.invoke({ url: "https://example.com" });
// Or add to an agent
import { AgentExecutor } from "langchain/agents";
const agent = AgentExecutor.fromAgentAndTools({
agent,
tools: [tool],
});MIT