Skip to main content
A Node.js LangChain plugin that lets developers use Decodo’s Web Data API alongside their LangChain applications. Decodo LangChain tools work with any Web Data API plan. Free trials are available on the dashboard.
More information can be found on GitHub here.
Building in Python? See LangChain (Python), which also includes a document loader for RAG pipelines.

Features

  • Web scraping – scrape any URL and retrieve Markdown content
  • Google Search – search Google and retrieve structured results
  • Amazon Search – search Amazon and retrieve structured product data
  • Web search – search the web and retrieve ranked results
  • Site mapping – list the URLs on a website without fetching their content
  • Crawling – crawl a website and retrieve the content of every page found
  • Full TypeScript support – complete type definitions for all parameters
  • LangChain integration – seamless integration with LangChain’s tool system

Quick start

Prerequisites

  • Node.js >= v20
  • A Decodo Web Data API subscription
Installation:
Once you have a plan activated, copy your API key from the Web Data API playground. Older plans only have a generated username and password, which also work. A simple agentic example:

Running the bundled samples

  1. Clone the repo and install dependencies
  1. Copy .env.example to .env and fill in SCRAPER_API_KEY. On an older plan, fill in SCRAPER_API_USERNAME and SCRAPER_API_PASSWORD instead. The examples also read OPENAI_API_KEY.
  1. Run any of the samples
Skipping step 2 throws Decodo config requires either an apiKey or both a username and a password. as soon as a tool is constructed.

Available tools

The tools fall into two groups, which differ in how they authenticate and what input they take:
  • Scrape tools – DecodoUniversalTool, DecodoGoogleSearchTool and DecodoAmazonSearchTool. They share one input schema and accept either credential type.
  • Data API tools – DecodoSearchTool, DecodoMapTool, DecodoCrawlTool and DecodoCrawlCancelTool. Each has its own input schema, and all four require an API key.

Configuration

The scrape tools accept a DecodoConfig object holding either an API key (recommended) or, for older plans, a username and password:
It is one or the other. Passing both throws Decodo config accepts either apiKey or username and password, not both. Passing neither – or a username without a password – throws Decodo config requires either an apiKey or both a username and a password.
The four data API tools take only { apiKey }. Constructing one with a username and password throws <ToolName> requires an apiKey. Username and password credentials cannot call it. Under the hood the tools wrap the Decodo TypeScript SDK.

Parameters

Parameter names are camelCase – jsRender, not JsRender.
Unknown fields are silently dropped, not rejected. Passing JsRender: true instead of jsRender: true raises no error – the field is stripped and JavaScript rendering never happens.

Scrape tools

decodo_universal_tool, decodo_google_search and decodo_amazon_search share one input schema.

Values fixed by each tool

Each tool sets some parameters itself, after your input, so a value you pass for one of these is overwritten: In other words, decodo_universal_tool always returns Markdown, and the two search tools always return parsed results without JavaScript rendering. For the full list of API parameters, see Parameters. Results carry a title, link and description. To read a result, scrape its link with decodo_universal_tool.

decodo_map and decodo_crawl

Both tools start from a URL and discover pages from there, so they share these parameters: decodo_map adds: decodo_crawl adds:
On a large site, narrow the crawl with selectPaths or excludePaths first, or use decodo_map to list the URLs and then scrape only the pages you need.

decodo_crawl_cancel

Crawl behaviour

DecodoCrawlTool waits until the crawl finishes. It returns the crawl’s status, reason and discovered, completed and failed page counts, along with each page’s url and content, or content_error when a page failed.
A crawl that ends faulted, cancelled or truncated still returns the pages collected so far, so check status.status in the result. Anything other than done means the crawl stopped early.
By default the tool checks the crawl every 5 seconds and waits up to 10 minutes for it to finish. Fetching the pages of a finished crawl comes on top of that. Pass pollInterval and timeout in milliseconds to change either:
The tool sends its timeout to Decodo as the crawl’s max_duration, so a crawl the tool stops waiting for is stopped on Decodo’s side at the same limit, and the tool’s error says so. Decodo rejects a max_duration above 4 hours, so a longer timeout leaves the server default in place. If a timeout above 4 hours runs out, the crawl keeps running on Decodo’s side. The error carries the crawl id, so register DecodoCrawlCancelTool alongside DecodoCrawlTool to let the agent stop it.

Error handling

API errors are rethrown as Error('Decodo API error: ...') with the SDK’s error as cause, so its statusCode is still available. A crawl timeout is a TimeoutError, which the package re-exports from the SDK so you can check it with instanceof:
A search the API reports as failed throws Decodo search failed: ... with the failed response, including its status_code, as cause.

Support

Need help or just want to say hello? Our support is available 24/7.
You can also reach us anytime via email at support@decodo.com.

Feedback

Can’t find what you’re looking for? Request an article!
Have feedback? Share your thoughts on how we can improve.