serpapi-sdk-patterns

Featured

Production-ready SerpApi client patterns with caching, typing, and multi-engine support. Use when building search services, implementing result caching, or wrapping SerpApi with typed responses. Trigger: "serpapi patterns", "serpapi best practices", "serpapi client wrapper".

AI & Automation 2,940 stars 439 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# SerpApi SDK Patterns ## Overview Production patterns for SerpApi: typed result interfaces, response caching (critical since each search costs credits), multi-engine abstraction, and async search with the Searches Archive API. ## Instructions ### Step 1: Typed Result Interfaces ```typescript interface SerpApiOrganicResult { position: number; title: string; link: string; snippet: string; displayed_link: string; source?: string; } interface SerpApiSearchResult { search_metadata: { id: string; status: string; created_at: string }; search_parameters: Record<string, string>; organic_results: SerpApiOrganicResult[]; answer_box?: { answer?: string; snippet?: string; title?: string }; knowledge_graph?: { title: string; description?: string; type?: string }; related_questions?: Array<{ question: string; snippet: string }>; pagination?: { next: string }; } ``` ### Step 2: Cached Search Client ```typescript import { getJson } from 'serpapi'; import { LRUCache } from 'lru-cache'; const cache = new LRUCache<string, SerpApiSearchResult>({ max: 500, ttl: 3600_000, // 1 hour -- search results are relatively stable }); async function cachedSearch(params: Record<string, any>): Promise<SerpApiSearchResult> { const key = JSON.stringify(params); const cached = cache.get(key); if (cached) return cached; const result = await getJson({ ...params, api_key: process.env.SERPAPI_API_KEY, }) as SerpApiSearchResult; cache.set(key, result); r...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category