INTEGRATIONS / HTTP RECIPE

pageflock, meet Node.js.

A small server-side request connects your application to the pageflock Extraction Engine. No pageflock SDK is required.

← All integrations

Your first connection.

  1. 01

    Use a supported Node.js runtime with fetch, such as Node.js 22.

  2. 02

    Set WAGGLE_BASE_URL and WAGGLE_API_KEY in the server environment. Keep the key out of client components and browser bundles.

  3. 03

    Run the JavaScript example from an ES module or an async server function. Check the HTTP status before using the returned JSON.

Build the request.

Set the environment variables in your terminal for these code examples. In automation tools, enter the URL and credentials in the tool’s own fields.

// Node.js 20+. Run on your server; keep the key out of browser code.
const baseUrl = process.env.WAGGLE_BASE_URL.replace(/\/$/, "");
const response = await fetch(baseUrl + "/api/pageflock/v1/scrape", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WAGGLE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "url": "https://example.com"
}),
  signal: AbortSignal.timeout(45000),
});
const result = await response.json();
console.log("Credits this call:", response.headers.get("X-PageFlock-Credits-Used") ?? response.headers.get("X-Waggle-Credits-Used"));
if (!response.ok) {
  console.error("Request ID:", response.headers.get("X-PageFlock-Request-Id") ?? response.headers.get("X-Waggle-Request-Id"));
  throw new Error(result.error?.message || `HTTP ${response.status}`);
}
console.log(result);

This edits a code example. It does not send a request or use credits.

Run a request in your workspace
YOUR PRIVACY

Choose what works for you. You can reopen these settings from the footer at any time.