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 a form action in src/routes/search/+page.server.ts:
import Evocrawl from "@mendable/evocrawl-js";
import { EVOCRAWL_API_KEY } from "$env/static/private";

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

export const actions = {
  default: async ({ request }) => {
    const data = await request.formData();
    const query = data.get("query") as string;
    const results = await evocrawl.search(query, { limit: 5 });
    return { results: (results.web || []).map((r) => ({ title: r.title, url: r.url })) };
  },
};
Wire it up in src/routes/search/+page.svelte:
<script>
  export let form;
</script>

<form method="POST">
  <input name="query" placeholder="Search the web..." />
  <button>Search</button>
</form>

{#if form?.results}
  {#each form.results as result}
    <div><a href={result.url}>{result.title}</a></div>
  {/each}
{/if}

Scrape a page

Fetch data in a load function at src/routes/scrape/+page.server.ts:
import Evocrawl from "@mendable/evocrawl-js";
import { EVOCRAWL_API_KEY } from "$env/static/private";

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

export async function load({ url }) {
  const target = url.searchParams.get("url");
  if (!target) return { markdown: null };

  const result = await evocrawl.scrape(target);
  return { markdown: result.markdown };
}
Display it in src/routes/scrape/+page.svelte:
<script>
  export let data;
</script>

{#if data.markdown}
  <pre>{data.markdown}</pre>
{:else}
  <p>Pass ?url= to scrape a page</p>
{/if}

Interact with a page

Create a server endpoint at src/routes/api/interact/+server.ts:
import { json } from "@sveltejs/kit";
import Evocrawl from "@mendable/evocrawl-js";
import { EVOCRAWL_API_KEY } from "$env/static/private";

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

export async function POST() {
  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 json({ 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