Skip to main content
All integrations

AI Development

AdsCrawl for LangGraph

Add AdsCrawl to a LangGraph node when an agent workflow needs current web evidence. Store the requested URL and rendered Markdown in graph state so later nodes can extract, summarize or route the result.

What you can do

01

A browser-backed node

Call the Markdown API inside read_page, using the URL from graph state.

02

Shared evidence

Pass the page text and URL to later nodes without fetching the same page at every step.

03

Explicit execution order

Connect START, the reading node and END; extend the graph with your own processing nodes.

Before you start

  • An AdsCrawl account with an API key and available credits.
  • Node.js 22.22 or newer, running on your server or local development machine.

SETUP METHOD 01

Add a web-reading node

Define a StateSchema, add one AdsCrawl node and compile a runnable graph.

  1. Install dependencies

    Run this in your application directory.

    Shell
    npm install adscrawl @langchain/core @langchain/langgraph zod
  2. Configure your API key

    Set the variables in your server environment or local shell. Replace the placeholders with your own keys; keep them out of browser bundles and source control.

    Shell
    export ADSCRAWL_API_KEY="your_adscrawl_api_key"
  3. Save langgraph-web.mjs

    The graph accepts a URL and adds Markdown to state. Empty page content raises an error instead of passing an empty result downstream.

    JavaScript
    import AdsCrawl from "adscrawl";
    import { END, START, StateGraph, StateSchema } from "@langchain/langgraph";
    import { z } from "zod";
    
    const browser = new AdsCrawl({ apiKey: process.env.ADSCRAWL_API_KEY });
    const PageState = new StateSchema({
      url: z.string().url(),
      markdown: z.string().default(""),
    });
    
    export const graph = new StateGraph(PageState)
      .addNode("read_page", async ({ url }) => {
        const markdown = await browser.markdown({
          url, waitUntil: "domcontentloaded",
        });
        if (!markdown.trim()) throw new Error("The page returned no text");
        return { markdown };
      })
      .addEdge(START, "read_page")
      .addEdge("read_page", END)
      .compile();
    
    const result = await graph.invoke({ url: "https://example.com" });
    console.log({ source: result.url, markdown: result.markdown });
  4. Run and connect the next step

    Expect result.url to retain the input and result.markdown to contain Example Domain. Insert a processing node between read_page and END when you add extraction or summarization; configure a model only if that node needs one.

    Shell
    node langgraph-web.mjs

Usage & limits

  • This minimal graph has no checkpointer, retry policy or cross-run cache. Replaying the reading node can issue another billable request; add persistence and bounded retries deliberately for production.
  • Each page request uses AdsCrawl credits. These examples fetch one public URL; JavaScript-rendered pages may need a different waitUntil setting or additional browser interactions.
  • Keep the source URL with the content. For longer pages, choose a chunking or context-budget strategy before passing text to a model.
See pricing and credit conversion

Further reading

LangGraph documentationAdsCrawl JavaScript / TypeScript SDK