JavaScript / TypeScript SDK
@serpcheap/sdk는 공식 JavaScript/TypeScript 클라이언트입니다 — Node 18+, 의존성 없음(네이티브
fetch), 완전한 타입 지원.
npm install @serpcheap/sdk빠른 시작
섹션 제목: “빠른 시작”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}`);}const client = new SerpCheap("YOUR_API_KEY", { baseUrl: "https://api.serp.cheap", // default timeoutMs: 15000, // default maxRetries: 2, // retries on transient errors});페이지네이션
섹션 제목: “페이지네이션”searchPages가 페이지를 대신 순회합니다(from/to 포함):
for await (const page of client.searchPages({ q: "coffee makers" }, 1, 5)) { console.log(`page ${page.page}: ${page.organic.length} results`);}오류 처리
섹션 제목: “오류 처리”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})`); }}