Skip to main content

langchain-decodo

LangChain partner package for the Decodo web scraping API.

Provides LangChain tools for scraping, web search, site mapping and crawling, plus a document loader, that let LLM agents and RAG pipelines fetch live web content without managing proxies, JavaScript rendering, or anti-bot protection.

Installation

pip install langchain-decodo

Authentication

Use the Web Data API key from your Web Data API subscription on the Decodo Dashboard. All classes read it from the DECODO_API_TOKEN environment variable, or you can pass it explicitly. DecodoWebScrapeTool, DecodoSearchTool and DecodoLoader also need auth_mode="token" when using the key:

export DECODO_API_TOKEN="your-decodo-api-key"
from langchain_decodo import DecodoWebScrapeTool

tool = DecodoWebScrapeTool(auth_mode="token")

Older plans only have a basic authentication token (base64-encoded username:password). That is the default auth_mode="basic", so omit auth_mode and export the basic token as DECODO_API_TOKEN.

DecodoWebSearchTool, DecodoMapTool, DecodoCrawlTool and DecodoCrawlCancelTool call endpoints that only accept an API key, so they need no auth_mode and do not work with a basic authentication token.

Components

DecodoWebScrapeTool

Scrape any URL and return its full content as markdown or plain text. Handles JavaScript rendering, CAPTCHAs, and geo-blocking automatically.

from langchain_decodo import DecodoWebScrapeTool

tool = DecodoWebScrapeTool(auth_mode="token")  # reads DECODO_API_TOKEN from env
content = tool.run("https://example.com")
print(content)

Pass explicitly:

from pydantic import SecretStr
from langchain_decodo import DecodoWebScrapeTool

tool = DecodoWebScrapeTool(
    decodo_api_token=SecretStr("YOUR_API_KEY"),
    auth_mode="token",
)

DecodoSearchTool

Search Google, Amazon, or Reddit and return structured JSON results.

from langchain_decodo import DecodoSearchTool

tool = DecodoSearchTool(auth_mode="token")

# Google search (default)
results = tool.run({"query": "LangChain latest release", "engine": "google"})

# Amazon product search
results = tool.run({"query": "Python programming book", "engine": "amazon"})

# Reddit discussion search
results = tool.run({"query": "best web scraping libraries", "engine": "reddit"})

Returns a JSON string — a list of objects with content, url, and status_code fields.

Supported engines:

engine Decodo target Description
google google_search Google SERP
amazon amazon_search Amazon product search
reddit google_search + site:reddit.com Reddit via Google

DecodoWebSearchTool

Search the web and return ranked results with title, link and description. Unlike DecodoSearchTool, which scrapes a specific engine's results page, this returns one normalized result document. Requires an API key.

from langchain_decodo import DecodoWebSearchTool

tool = DecodoWebSearchTool()
results = tool.invoke({"query": "coffee shops", "geo": "United States", "page": 1})

Returns a JSON string; the results are under organic, alongside top_stories, people_also_ask and related_searches when the search has them.

DecodoMapTool

List the URLs on a website without fetching their content. Requires an API key. Raises an error when the site could not be mapped, for example when it blocks the request.

from langchain_decodo import DecodoMapTool

tool = DecodoMapTool()
result = tool.invoke(
    {
        "url": "https://www.python.org",
        "select_paths": ["^/downloads/"],
        "limit": 50,
    }
)

Optional arguments: sitemap (include, only or skip), domain_filter (domain, subdomain or all), select_paths and exclude_paths (regular expressions matched against URL paths), geo, locale, limit (up to 500, default 100) and js_render.

DecodoCrawlTool and DecodoCrawlCancelTool

Crawl a website from a start URL and return the content of every page found. The tool runs the crawl through the Decodo SDK, waits for it to finish and returns {"status": {...}, "pages": [...]}. Requires an API key.

from langchain_decodo import DecodoCrawlTool

tool = DecodoCrawlTool(timeout=300, poll_interval=5)
result = tool.invoke({"url": "https://example.com", "limit": 10, "max_depth": 2})

Takes the same optional arguments as DecodoMapTool except js_render, plus limit (up to 100, default 10), max_depth and output (markdown or html).

status is the crawl's status response and each entry in pages is a page as the API returns it, including its own status. A status.status other than done means the crawl stopped early and pages holds only what was collected. status is null when it could not be read, for example when the crawl collected no pages.

timeout (seconds, default 600) is also sent as the crawl's max_duration, capped at the API's 4-hour limit. A crawl still running at timeout comes back as pending with the pages collected so far; Decodo stops it at the same limit shortly after. To stop it sooner, pass status.crawl_id to DecodoCrawlCancelTool:

import json

from langchain_decodo import DecodoCrawlCancelTool, DecodoCrawlTool

result = json.loads(DecodoCrawlTool(timeout=60).invoke({"url": "https://example.com"}))
status = result["status"]
if status and status["status"] == "pending":
    DecodoCrawlCancelTool().invoke({"crawl_id": status["crawl_id"]})

DecodoLoader

Load one or more URLs as LangChain Document objects for use in RAG pipelines.

from langchain_decodo import DecodoLoader

loader = DecodoLoader(
    urls=[
        "https://python.org/about/",
        "https://docs.python.org/3/whatsnew/3.12.html",
    ],
    auth_mode="token",
)
docs = loader.load()

for doc in docs:
    print(doc.metadata["url"], "—", len(doc.page_content), "chars")

Each Document has:

  • page_content — scraped text/markdown.
  • metadata["url"] — the source URL.
  • metadata["source"] — same as url (LangChain convention).
  • metadata["status_code"] — HTTP status from the target site.

LangChain agent example

pip install langchain langchain-openai langchain-decodo
from langchain.agents import create_agent
from langchain_decodo import DecodoMapTool, DecodoWebScrapeTool, DecodoWebSearchTool

agent = create_agent(
    model="openai:gpt-6.1-sol",
    tools=[
        DecodoWebSearchTool(),
        DecodoMapTool(),
        DecodoWebScrapeTool(auth_mode="token"),
    ],
)

result = agent.invoke(
    {
        "messages": [
            {
                "role": "user",
                "content": "What is the latest stable version of Python? Check python.org.",
            }
        ]
    }
)
print(result["messages"][-1].text)

RAG pipeline example

pip install langchain-openai langchain-text-splitters langchain-decodo numpy
from langchain_core.vectorstores import InMemoryVectorStore
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_decodo import DecodoLoader

docs = DecodoLoader(urls=["https://python.org/about/"], auth_mode="token").load()

splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
chunks = splitter.split_documents(docs)

store = InMemoryVectorStore.from_documents(chunks, OpenAIEmbeddings())
context = "\n\n".join(
    doc.page_content for doc in store.similarity_search("What is Python used for?", k=4)
)

llm = ChatOpenAI(model="gpt-6.1-sol")
answer = llm.invoke(
    f"Answer using only this context:\n\n{context}\n\nQuestion: What is Python used for?"
)
print(answer.text)

Metadata

Release files for langchain-decodo 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-decodo 0.2.0
File Size Uploaded Provenance Actions
langchain_decodo-0.2.0.tar.gz 212.0 kB With provenance Details for langchain_decodo-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-decodo 0.2.0
File Interpreter ABI Platform Actions
langchain_decodo-0.2.0-py3-none-any.whl Python 3 none any Details for langchain_decodo-0.2.0-py3-none-any.whl

Total release size: 232.2 kB

Release files / langchain_decodo-0.2.0.tar.gz

Download URL langchain_decodo-0.2.0.tar.gz
Size 212.0 kB
Tags Source
SHA-256 checksum
How to use checksums
96211d08d0cb81001513f11340ac9803be63c0a4879ef9995f3ca240e4b95e15
BLAKE2b-256 checksum
How to use checksums
a7ec83362b44029364d8a462a9549752be210f302560d1662d8a955dfdaf932d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / langchain_decodo-0.2.0-py3-none-any.whl

Download URL langchain_decodo-0.2.0-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b8f94a93beb74f04303cef68bf1c3032a830fcb053c51e4bdf11a11741aa8fb
BLAKE2b-256 checksum
How to use checksums
c08d6c30ffcc5fcad9411be566fe24cfe9e19f1caef96f33425f860d8ff25783
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Security for langchain-decodo 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_decodo-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page