Skip to main content

Prerequisites

Setup

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

Search the web

import Fastify from "fastify";
import Evocrawl from "@mendable/evocrawl-js";

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

fastify.post("/search", async (request) => {
  const { query } = request.body;
  return evocrawl.search(query, { limit: 5 });
});

fastify.listen({ port: 3000 });

Scrape a page

fastify.post("/scrape", async (request) => {
  const { url } = request.body;
  return evocrawl.scrape(url);
});

Interact with a page

Use interact to control a live browser session — click buttons, fill forms, and extract dynamic content.
fastify.post("/interact", async (request) => {
  const { url } = request.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);

  return { output: response.output };
});

As a Fastify plugin

Encapsulate the client in a plugin for reuse across routes:
import fp from "fastify-plugin";
import Evocrawl from "@mendable/evocrawl-js";

export default fp(async function evocrawlPlugin(fastify) {
  const client = new Evocrawl({ apiKey: process.env.EVOCRAWL_API_KEY });
  fastify.decorate("evocrawl", client);
});
Register the plugin, then use fastify.evocrawl in any route:
fastify.register(evocrawlPlugin);

fastify.post("/search", async function (request) {
  const { query } = request.body;
  return this.evocrawl.search(query, { limit: 5 });
});

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