← Zurück zum Blog

Google Search API in Node.js: Komplettes Tutorial (2026)

Eine Google Search API in Node.js / JavaScript nutzen — fetch-basierte Requests, asynchrone Paginierung, Retries und ein typisierter Helper. Beispiele mit serp.cheap.

1 Min. Lesezeit

Frage Google aus Node.js ab und erhalte strukturiertes JSON, mit serp.cheap. Node 18+ hat fetch bereits eingebaut — keine Abhängigkeiten nötig.

Minimales Beispiel

const res = await fetch("https://api.serp.cheap/v1/search", {
  method: "POST",
  headers: { "X-API-Key": "YOUR_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({ q: "best electric cars 2026", gl: "us", page: 1 }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const { organic, stats } = await res.json();
organic.forEach(r => console.log(`#${r.position} ${r.title} — ${r.link}`));
console.log("cost (credits):", stats.cost, "cached:", stats.cached);

Ein kleiner Helper mit Retry

async function search(q, { gl = "us", page = 1, tbs, retries = 4 } = {}) {
  const body = JSON.stringify({ q, gl, page, ...(tbs && { tbs }) });
  for (let attempt = 0; ; attempt++) {
    const res = await fetch("https://api.serp.cheap/v1/search", {
      method: "POST",
      headers: { "X-API-Key": process.env.SERP_KEY, "Content-Type": "application/json" },
      body,
    });
    if (res.ok) return res.json();
    if (![429, 500, 502, 503, 504].includes(res.status) || attempt >= retries) {
      throw new Error(`HTTP ${res.status}`);
    }
    await new Promise(r => setTimeout(r, 1000 * 2 ** attempt)); // backoff
  }
}

const data = await search("serp api nodejs", { gl: "us" });

Paginieren

async function pages(q, n = 3) {
  const results = [];
  for (let p = 1; p <= n; p++) results.push(...(await search(q, { page: p })).organic);
  return results;
}

Jede Seite ist eine separat abgerechnete Anfrage. Halte deinen API-Key serverseitig — gib ihn niemals an den Browser weiter.

Weiter

Häufige Fragen

Wie rufe ich eine Google Search API in Node.js auf?+

Nutze das eingebaute fetch (Node 18+), um deine Anfrage per POST zu senden. Mit serp.cheap: fetch('https://api.serp.cheap/v1/search', { method: 'POST', headers: { 'X-API-Key': KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ q, gl: 'us' }) }).

Brauche ich ein SDK?+

Du musst nicht — eine SERP API ist ein einfacher HTTP-Endpunkt, daher reicht das native fetch (oder axios) aus. Aber serp.cheap liefert auch ein offizielles JavaScript/TypeScript-SDK (npm install @serpcheap/sdk) mit typisierten Aufrufen, Retries und Paginierung, plus NestJS- und Next.js-Integrationen.

Hol dir deinen API-Key

Am günstigsten direkt, mit Karte oder Krypto zahlen, kein KYC. Oder über einen Marktplatz.