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.
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.
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);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.
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);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.
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.
Grab a key, spend 500 free credits on a real fan-out, and read the Envelope back. Charged only on success.