serpapi

SerpApi search engine results API via curl. Use this skill to scrape Google, Bing, YouTube, and other search engines.

151 stars

Best use case

serpapi is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

SerpApi search engine results API via curl. Use this skill to scrape Google, Bing, YouTube, and other search engines.

Teams using serpapi should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/serpapi/SKILL.md --create-dirs "https://raw.githubusercontent.com/nicepkg/ai-workflow/main/workflows/video-creator-workflow/.claude/skills/serpapi/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/serpapi/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How serpapi Compares

Feature / AgentserpapiStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

SerpApi search engine results API via curl. Use this skill to scrape Google, Bing, YouTube, and other search engines.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# SerpApi

Use SerpApi via direct `curl` calls to **scrape search engine results** from Google, Bing, YouTube, and more.

> Official docs: `https://serpapi.com/search-api`

---

## When to Use

Use this skill when you need to:

- **Scrape Google search results** (organic, ads, knowledge graph)
- **Search Google Images, News, Videos, Shopping**
- **Get local business results** from Google Maps
- **Scrape other search engines** (Bing, YouTube, DuckDuckGo, etc.)
- **Monitor SERP rankings** for SEO analysis

---

## Prerequisites

1. Sign up at [SerpApi](https://serpapi.com/)
2. Go to Dashboard and copy your API key
3. Store it in the environment variable `SERPAPI_API_KEY`

```bash
export SERPAPI_API_KEY="your-api-key"
```

### Pricing

- Free tier: 100 searches/month
- API key is passed as a query parameter `api_key`

---


> **Important:** When using `$VAR` in a command that pipes to another command, wrap the command containing `$VAR` in `bash -c '...'`. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.
> ```bash
> bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"'
> ```

## How to Use

All examples below assume you have `SERPAPI_API_KEY` set.

Base URL: `https://serpapi.com/search`

---

### 1. Basic Google Search

Search Google and get structured JSON results:

```bash
bash -c 'curl -s "https://serpapi.com/search?engine=google&q=artificial+intelligence&api_key=${SERPAPI_API_KEY}"' | jq '.organic_results[:3] | .[] | {title, link, snippet}
```

---

### 2. Search with Location

Search from a specific location:

```bash
bash -c 'curl -s "https://serpapi.com/search?engine=google&q=best+coffee+shops&location=San+Francisco,+California&gl=us&hl=en&api_key=${SERPAPI_API_KEY}"' | jq '.organic_results[:3]'
```

**Parameters:**
- `location`: City, state, or address
- `gl`: Country code (us, uk, de, etc.)
- `hl`: Language code (en, de, fr, etc.)

---

### 3. Google Image Search

Search for images:

```bash
bash -c 'curl -s "https://serpapi.com/search?engine=google_images&q=sunset+beach&api_key=${SERPAPI_API_KEY}"' | jq '.images_results[:3] | .[] | {title, original, thumbnail}
```

---

### 4. Google News Search

Search news articles:

```bash
bash -c 'curl -s "https://serpapi.com/search?engine=google_news&q=technology&api_key=${SERPAPI_API_KEY}"' | jq '.news_results[:3] | .[] | {title, link, source, date}
```

---

### 5. Google Shopping Search

Search products:

```bash
bash -c 'curl -s "https://serpapi.com/search?engine=google_shopping&q=wireless+headphones&api_key=${SERPAPI_API_KEY}"' | jq '.shopping_results[:3] | .[] | {title, price, source}
```

---

### 6. YouTube Search

Search YouTube videos:

```bash
bash -c 'curl -s "https://serpapi.com/search?engine=youtube&search_query=python+tutorial&api_key=${SERPAPI_API_KEY}"' | jq '.video_results[:3] | .[] | {title, link, channel, views}
```

---

### 7. Google Maps / Local Results

Search local businesses:

```bash
bash -c 'curl -s "https://serpapi.com/search?engine=google_maps&q=restaurants&ll=@40.7128,-74.0060,15z&api_key=${SERPAPI_API_KEY}"' | jq '.local_results[:3] | .[] | {title, rating, address}
```

**Parameters:**
- `ll`: Latitude, longitude, and zoom level (e.g., `@40.7128,-74.0060,15z`)

---

### 8. Pagination

Get more results using the `start` parameter:

```bash
# First page (results 1-10)
bash -c 'curl -s "https://serpapi.com/search?engine=google&q=machine+learning&start=0&api_key=${SERPAPI_API_KEY}"' | jq '.organic_results | length'

# Second page (results 11-20)
bash -c 'curl -s "https://serpapi.com/search?engine=google&q=machine+learning&start=10&api_key=${SERPAPI_API_KEY}"' | jq '.organic_results | length'
```

---

### 9. Check Account Info

Check your API usage and credits:

```bash
bash -c 'curl -s "https://serpapi.com/account?api_key=${SERPAPI_API_KEY}"' | jq '{plan_name, searches_per_month, this_month_usage}
```

---

## Supported Engines

| Engine | Parameter | Description |
|--------|-----------|-------------|
| Google Search | `engine=google` | Web search results |
| Google Images | `engine=google_images` | Image search |
| Google News | `engine=google_news` | News articles |
| Google Shopping | `engine=google_shopping` | Product search |
| Google Maps | `engine=google_maps` | Local businesses |
| YouTube | `engine=youtube` | Video search |
| Bing | `engine=bing` | Bing web search |
| DuckDuckGo | `engine=duckduckgo` | Privacy-focused search |

---

## Common Parameters

| Parameter | Description |
|-----------|-------------|
| `q` | Search query (required) |
| `engine` | Search engine to use |
| `location` | Geographic location for search |
| `gl` | Country code (e.g., us, uk) |
| `hl` | Language code (e.g., en, de) |
| `start` | Pagination offset (0, 10, 20...) |
| `num` | Number of results (max 100) |
| `safe` | Safe search (`active` or `off`) |
| `device` | Device type (`desktop`, `mobile`, `tablet`) |

---

## Guidelines

1. **Use specific engines**: Use `google_images`, `google_news` etc. instead of `tbm` parameter for cleaner results
2. **Add location for local searches**: Use `location` and `gl` for geo-targeted results
3. **Cache results**: SerpApi caches results by default; use `no_cache=true` for fresh data
4. **Monitor usage**: Check `/account` endpoint to track API credits
5. **Use jq filters**: Filter large JSON responses to extract only needed data

Related Skills

youtube-to-markdown

151
from nicepkg/ai-workflow

Use when user asks YouTube video extraction, get, fetch, transcripts, subtitles, or captions. Writes video details and transcription into structured markdown file.

youtube-seo-optimizer

151
from nicepkg/ai-workflow

Optimize YouTube videos for search and discovery. Generates SEO-optimized titles, descriptions, tags, hashtags, and chapters. Includes keyword research and competitor analysis. Use when publishing videos, improving discoverability, or optimizing existing content.

webfluence

151
from nicepkg/ai-workflow

Content web architecture framework. Use when diagnosing offer doc usage, content-to-conversion pathways, or why someone isn't getting sales despite traffic.

video-to-gif

151
from nicepkg/ai-workflow

Convert video clips to optimized GIFs with speed control, cropping, text overlays, and file size optimization. Create perfect GIFs for social media, documentation, and presentations.

video-title-optimizer

151
from nicepkg/ai-workflow

Optimize video titles for maximum click-through rate (CTR) and YouTube/TikTok SEO. Generates multiple title variations balancing curiosity, keywords, and platform best practices. Use when naming videos, improving CTR, or A/B testing titles.

video-script-writer

151
from nicepkg/ai-workflow

Write engaging video scripts for YouTube, TikTok, and other platforms. Creates complete scripts with hooks, main content, and CTAs. Supports various formats including tutorials, vlogs, reviews, explainers, and storytelling. Use when creating video scripts, writing YouTube content, or planning video structure.

video-script-collaborial

151
from nicepkg/ai-workflow

将视频脚本转换为更适合实际录制的口语化表达,去除书面化语言,增加自然感和亲和力。当用户提到"视频脚本"、"录制"、"口语化"、"自然一点"、"像说话一样"、"太书面了"时使用此技能。

video-hook-generator

151
from nicepkg/ai-workflow

Generate attention-grabbing hooks for the first 3 seconds of videos. The hook determines if viewers stay or scroll. Creates multiple hook variations for A/B testing. Use when crafting video openings, improving retention, or creating scroll-stopping content for YouTube, TikTok, or Reels.

youtube-downloader

151
from nicepkg/ai-workflow

Download YouTube videos with customizable quality and format options. Use this skill when the user asks to download, save, or grab YouTube videos. Supports various quality settings (best, 1080p, 720p, 480p, 360p), multiple formats (mp4, webm, mkv), and audio-only downloads as MP3.

video-comparer

151
from nicepkg/ai-workflow

This skill should be used when comparing two videos to analyze compression results or quality differences. Generates interactive HTML reports with quality metrics (PSNR, SSIM) and frame-by-frame visual comparisons. Triggers when users mention "compare videos", "video quality", "compression analysis", "before/after compression", or request quality assessment of compressed videos.

video-analytics-interpreter

151
from nicepkg/ai-workflow

Interpret YouTube Analytics, TikTok Analytics, and video performance data. Identifies trends, explains metrics, and provides actionable recommendations for growth. Use when analyzing video performance, understanding metrics, or optimizing channel strategy.

thumbnail-concept-generator

151
from nicepkg/ai-workflow

Generate thumbnail concepts and ideas for YouTube, TikTok, and other video platforms. Creates detailed visual briefs with composition, text, colors, and emotion suggestions. Use when planning thumbnails, improving CTR, or briefing designers.