콘텐츠로 이동

JavaScript / TypeScript SDK

@serpcheap/sdk는 공식 JavaScript/TypeScript 클라이언트입니다 — Node 18+, 의존성 없음(네이티브 fetch), 완전한 타입 지원.

Terminal window
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})`);
}
}