Skip to main content

Prerequisites

Install the SDK

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

Search the web

Create server/api/search.post.ts:
import Evocrawl from "@mendable/evocrawl-js";

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

export default defineEventHandler(async (event) => {
  const { query } = await readBody(event);
  const results = await evocrawl.search(query, { limit: 5 });
  return results;
});
Call it from a Vue component:
<script setup>
const query = ref("");
const { data, execute } = useFetch("/api/search", {
  method: "POST",
  body: { query },
  immediate: false,
});
</script>

<template>
  <div>
    <input v-model="query" placeholder="Search the web..." />
    <button @click="execute()">Search</button>
    <ul v-if="data?.web">
      <li v-for="result in data.web" :key="result.url">
        <a :href="result.url">{{ result.title }}</a>
      </li>
    </ul>
  </div>
</template>

Scrape a page

Create server/api/scrape.post.ts:
import Evocrawl from "@mendable/evocrawl-js";

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

export default defineEventHandler(async (event) => {
  const { url } = await readBody(event);
  const result = await evocrawl.scrape(url);
  return result;
});
Call it from a Vue component:
<script setup>
const url = ref("https://example.com");
const { data, execute } = useFetch("/api/scrape", {
  method: "POST",
  body: { url },
  immediate: false,
});
</script>

<template>
  <div>
    <input v-model="url" placeholder="Enter URL" />
    <button @click="execute()">Scrape</button>
    <pre v-if="data">{{ data.markdown }}</pre>
  </div>
</template>

Interact with a page

Create server/api/interact.post.ts:
import Evocrawl from "@mendable/evocrawl-js";

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

export default defineEventHandler(async (event) => {
  const result = await evocrawl.scrape("https://www.amazon.com", {
    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 };
});

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