Skip to main content

Prerequisites

Setup

npm install express @mendable/evocrawl-js
Add your API key to .env:
EVOCRAWL_API_KEY=fc-YOUR-API-KEY

Search the web

import express from "express";
import Evocrawl from "@mendable/evocrawl-js";

const app = express();
app.use(express.json());

const evocrawl = new Evocrawl({ apiKey: process.env.EVOCRAWL_API_KEY });

app.post("/search", async (req, res) => {
  try {
    const { query } = req.body;
    const results = await evocrawl.search(query, { limit: 5 });
    res.json(results);
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

app.listen(3000, () => console.log("Server running on port 3000"));

Scrape a page

app.post("/scrape", async (req, res) => {
  try {
    const { url } = req.body;
    const result = await evocrawl.scrape(url);
    res.json(result);
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

Interact with a page

Use interact to control a live browser session — click buttons, fill forms, and extract dynamic content.
app.post("/interact", async (req, res) => {
  try {
    const { url } = req.body;

    const result = await evocrawl.scrape(url, { formats: ['markdown'] });
    const scrapeId = result.metadata?.scrapeId;

    await evocrawl.interact(scrapeId, { prompt: 'Search for iPhone 16 Pro Max' });
    const response = await evocrawl.interact(scrapeId, { prompt: 'Click on the first result and tell me the price' });

    await evocrawl.stopInteraction(scrapeId);

    res.json({ output: response.output });
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

Test it

curl -X POST http://localhost:3000/search \
  -H "Content-Type: application/json" \
  -d '{"query": "evocrawl web scraping"}'

Next steps

Scrape docs

All scrape options including formats, actions, and proxies

Search docs

Search the web and get full page content

Interact docs

Click, fill forms, and extract dynamic content

Node SDK reference

Full SDK reference with crawl, map, batch scrape, and more