Skip to main content

LangChain document loader, tool, and retriever backed by the Crawlbase API.

Project description

langchain-crawlbase

LangChain primitives backed by the Crawlbase Crawling API.

Three drop-in classes:

  • CrawlbaseLoader — a BaseLoader that fetches a list of URLs and returns clean Markdown Documents ready for chunking.
  • CrawlbaseTool — a BaseTool that lets an LLM agent fetch a live web page mid-conversation.
  • CrawlbaseRetriever — a BaseRetriever that fetches a fixed set of seed URLs and filters by query.

All three return GitHub-flavored Markdown via Crawlbase's format=md parameter, so you skip the HTML-stripping step entirely.

Installation

pip install langchain-crawlbase

Setup

Get a token from your Crawlbase dashboard. Use your normal token for static pages, or your JavaScript token for SPA / JS-rendered pages — Crawlbase routes the request automatically based on which token you send.

export CRAWLBASE_TOKEN=your_token

Usage

Document loader

import os
from langchain_crawlbase import CrawlbaseLoader

loader = CrawlbaseLoader(
    token=os.environ["CRAWLBASE_TOKEN"],
    urls=[
        "https://en.wikipedia.org/wiki/Large_language_model",
        "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
    ],
)
docs = loader.load()
print(docs[0].page_content[:500])
print(docs[0].metadata)  # {'source': '...', 'pc_status': 200, ...}

For SPA pages, just use your JavaScript token instead — same interface:

loader = CrawlbaseLoader(
    token=os.environ["CRAWLBASE_JS_TOKEN"],
    urls=["https://some-spa-site.com/page"],
)

Agent tool

import os
from langchain_crawlbase import CrawlbaseTool

tool = CrawlbaseTool(token=os.environ["CRAWLBASE_TOKEN"])

# Use directly:
markdown = tool.invoke({"url": "https://example.com"})

# Or bind to an LLM:
from langchain_anthropic import ChatAnthropic
llm = ChatAnthropic(model="claude-opus-4-7")
agent_llm = llm.bind_tools([tool])

Retriever

import os
from langchain_crawlbase import CrawlbaseRetriever

retriever = CrawlbaseRetriever(
    token=os.environ["CRAWLBASE_TOKEN"],
    urls=[
        "https://crawlbase.com/docs/crawling-api",
        "https://crawlbase.com/docs/crawling-api#parameters",
    ],
)
docs = retriever.invoke("how do I render JavaScript pages")

v0.1 uses simple substring matching. For semantic retrieval, pair CrawlbaseLoader with a vector store of your choice.

Extra Crawlbase parameters

Pass any Crawlbase API parameter via extra_params:

loader = CrawlbaseLoader(
    token=token,
    urls=["https://example.com"],
    extra_params={"country": "US", "device": "mobile"},
)

Development

pip install -e ".[dev]"
pytest tests/unit
ruff check .

Integration tests are gated on CRAWLBASE_TOKEN:

CRAWLBASE_TOKEN=xxx pytest tests/integration

License

MIT — © Crawlbase Team. Contact: support@crawlbase.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_crawlbase-0.1.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_crawlbase-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_crawlbase-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_crawlbase-0.1.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for langchain_crawlbase-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7b8e241ecb17e28414d120de52766cd4402727bcc5e15af1f5cbb720579856f1
MD5 d1e99325143a6cddfd6ec0171399ce46
BLAKE2b-256 cc4edc52f9234d04c7b9cbd7b0249d1a1c29f4c6d1ac82a72a27803ff00fc4c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_crawlbase-0.1.0.tar.gz:

Publisher: release.yml on crawlbase/langchain-crawlbase

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_crawlbase-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_crawlbase-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6409f10c14a90783f32e09b7447413cb9f32416fb4347e0769a3a8d59ac5fa3
MD5 a00d0de0aef1c613778103bda0db8853
BLAKE2b-256 9e4953ac68575aae9e92d2a5529299cb996df87d38b65b003d351822bef1b4ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_crawlbase-0.1.0-py3-none-any.whl:

Publisher: release.yml on crawlbase/langchain-crawlbase

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page