Skip to main content
langchain-spidra integrates Spidra into LangChain in two ways:
  • Document loader. SpidraLoader pulls web content as LangChain Document objects, ready to feed into a vector store or retrieval chain.
  • Agent tools. SpidraScrape, SpidraCrawl, and SpidraBatchScrape are BaseTool classes you can bind to any LangChain agent so it can browse the web on its own.

Installation

Requires Python 3.9 or higher. This package is for LangChain’s Python framework; if you are building agents in JavaScript, see the Node SDK’s AI agent integration instead.
Get your API key from app.spidra.io under Settings > API Keys. Set it as an environment variable so you never hardcode it.

Document loader

SpidraLoader implements LangChain’s BaseLoader interface and returns a list of Document objects, each with page_content and metadata.

Scrape a page

The default mode. Returns raw markdown, which is ideal for RAG indexing where you want clean, unmodified content:
Pass up to three URLs at once and get one document per URL:

AI extraction

Add a prompt to run AI extraction. You get back a single document containing the structured result instead of raw markdown:

Crawl a site

Set mode="crawl" to crawl an entire site. Returns one document per discovered page, which is exactly what you want for indexing a docs site or knowledge base:
Omitting transform_instruction returns raw markdown per page with no AI processing and no token charges. Pass it only when you need AI extraction on each crawled page.
With AI extraction per page:

Batch scrape

Set mode="batch" to scrape many URLs in parallel. Returns one document per completed URL:

Use with a vector store

The most common use case: crawl a site and build a searchable knowledge base.

Lazy loading

For large crawls, use lazy_load() to process documents as they arrive instead of waiting for everything to finish:

Loader parameters


Agent tools

Each Spidra capability is available as a standalone BaseTool you can bind to an agent.

Available tools

Standalone usage

What each tool returns: Error handling: the tools never raise. On failure they return the error as a plain string, so the agent can read what went wrong and adjust. When calling a tool yourself, check the type before indexing into the result:

Bind to an agent

Tool parameters

SpidraScrape SpidraCrawl SpidraBatchScrape

Source

The package is open-source at github.com/spidra-io/spidra-langchain. Bug reports and contributions welcome.

Python SDK

Use the Spidra Python SDK directly without LangChain.

Node.js SDK

Official Node.js SDK for JavaScript and TypeScript projects.