AI Search API in Node.js.

Modern Node ships fetch, so AI Search API needs zero dependencies. Capture what a real user sees on ChatGPT, Perplexity, Copilot or Google AI and get one canonical Envelope back, typed however you like.

Bearer-authenticate, POST your query to /v1/search, then block for the Envelope (sync) or take the 202 and poll. You are charged only on a successful capture; 500 free credits to start.

search.mjs, one surface, inline Envelope
const res = await fetch(
  "https://api.aisearchapi.dev/v1/search?mode=sync",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.AISEARCH_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      query: "best crm for startups",
      surfaces: ["chatgpt"],
    }),
  },
);
if (!res.ok) throw new Error(`${res.status}`);
const { children } = await res.json();
console.log(children[0].answer.text);

Fan out across surfaces.

Add more surfaces or regions and the call goes async: a 202 with a jobId, one child capture per (surface × region). Poll /v1/jobs/:id or attach a signed webhook.

The full submit → poll → read round-trip and a webhook receiver are in the docs.

fanOut.mjs, many surfaces, poll to completion
const BASE = "https://api.aisearchapi.dev";
const H = {
  Authorization: `Bearer ${process.env.AISEARCH_API_KEY}`,
  "Content-Type": "application/json",
};

const submit = await fetch(`${BASE}/v1/search`, {
  method: "POST",
  headers: H,
  body: JSON.stringify({
    query: "best crm for startups",
    surfaces: ["chatgpt", "perplexity", "google_ai_overview"],
    regions: [{ country: "US" }, { country: "GB" }],
  }),
}).then((r) => r.json());

let job;
do {
  await new Promise((r) => setTimeout(r, 2000));
  job = await fetch(`${BASE}/v1/jobs/${submit.jobId}`, {
    headers: H,
  }).then((r) => r.json());
} while (!["completed", "partial", "failed", "canceled", "expired"].includes(job.job.status));

console.log(job.job.status);

Node.js + AI Search API, asked precisely.

Is there an npm package?

Not yet. Node’s built-in fetch is all you need; the snippets here are the full integration. When an official SDK ships, the HTTP contract stays the same.

Can I verify webhooks in Node?

Yes. Each delivery carries an X-AISearch-Signature (lowercase-hex HMAC-SHA256 keyed on your webhook secret) plus an X-AISearch-Timestamp (unix seconds). Capture the raw request bytes, reject if the timestamp skew is over ~5 minutes, recompute the HMAC over `${timestamp}.${rawBody}`, and compare with crypto.timingSafeEqual; the docs ship a receiver.

Ship it in Node.js today.

Grab a key, spend 500 free credits on a real fan-out, and read the Envelope back. Charged only on success.

other languages:PythonGoPHPRuby