JavaScript / TypeScript SDK
@serpcheap/sdk is the official JavaScript/TypeScript client — Node 18+, zero dependencies (native
fetch), fully typed.
Install
Section titled “Install”npm install @serpcheap/sdkQuickstart
Section titled “Quickstart”import { SerpCheap } from "@serpcheap/sdk";
const client = new SerpCheap("YOUR_API_KEY");
const res = await client.search({ q: "best running shoes", gl: "us" });for (const r of res.organic) { console.log(`${r.position}. ${r.title} — ${r.link}`);}Options
Section titled “Options”const client = new SerpCheap("YOUR_API_KEY", { baseUrl: "https://api.serp.cheap", // default timeoutMs: 15000, // default maxRetries: 2, // retries on transient errors});Pagination
Section titled “Pagination”searchPages iterates pages for you (inclusive from/to):
for await (const page of client.searchPages({ q: "coffee makers" }, 1, 5)) { console.log(`page ${page.page}: ${page.organic.length} results`);}Error handling
Section titled “Error handling”import { SerpCheapError } from "@serpcheap/sdk";
try { const res = await client.search({ q: "query" });} catch (err) { if (err instanceof SerpCheapError) { console.error(`[${err.code}] ${err.message} (retryable=${err.retryable})`); }}