← Back to blog

Google Search API with curl: Quick Reference (2026)

Test a Google Search API with curl: auth header, country and time filters, pagination, and jq one-liners — from $0.0003 per request.

1 min read

The fastest way to test a Google Search API is from your terminal. Examples use serp.cheap.

Basic request

Put your key in an env var once, then every example below is copy-paste:

export SERP_KEY="your-api-key"

curl https://api.serp.cheap/v1/search \
  -H "X-API-Key: $SERP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"q": "best electric cars 2026", "gl": "us", "page": 1}'

Response (trimmed to the first two organic results — a full page returns more, plus knowledgeGraph when Google shows one):

{
  "search": "best electric cars 2026",
  "page": 1,
  "organic": [
    {
      "position": 1,
      "title": "Best Electric Cars of 2026 - Car and Driver",
      "link": "https://www.caranddriver.com/rankings/best-electric-cars/",
      "snippet": "Our editors test and rank the EVs worth buying in 2026, from budget hatchbacks to long-range sedans...",
      "date": "Jun 2, 2026"
    },
    {
      "position": 2,
      "title": "Top Electric Cars for 2026 | Edmunds",
      "link": "https://www.edmunds.com/electric-car/best-electric-cars/",
      "snippet": "The best electric cars balance range, charging speed and price. Here are our top picks..."
    }
  ],
  "stats": { "balance": 9994, "cost": 6, "cached": false }
}

stats.cost is in credits: 6 for a fresh fetch ($0.0006), 3 for a cache hit ($0.0003).

Country and time filters

# Results from Brazil, last 24 hours
curl https://api.serp.cheap/v1/search \
  -H "X-API-Key: $SERP_KEY" -H "Content-Type: application/json" \
  -d '{"q": "eleições", "gl": "br", "tbs": "qdr:d"}'

See all options in Google Search API parameters.

Pretty-print and extract with jq

# Just the organic links
curl -s https://api.serp.cheap/v1/search \
  -H "X-API-Key: $SERP_KEY" -H "Content-Type: application/json" \
  -d '{"q": "serp api curl", "gl": "us"}' | jq -r '.organic[].link'

# Fetch once, slice many ways
resp=$(curl -s https://api.serp.cheap/v1/search \
  -H "X-API-Key: $SERP_KEY" -H "Content-Type: application/json" \
  -d '{"q": "serp api curl", "gl": "us"}')

# Position + title + link as TSV
echo "$resp" | jq -r '.organic[] | [.position, .title, .link] | @tsv'

# What did this call cost?
echo "$resp" | jq '.stats'

Pagination

for p in 1 2 3; do
  curl -s https://api.serp.cheap/v1/search \
    -H "X-API-Key: $SERP_KEY" -H "Content-Type: application/json" \
    -d "{\"q\": \"serp api\", \"page\": $p}" | jq -r '.organic[].link'
done

page is 1-indexed. Keep your key in the env var rather than pasting it into scripts or shell history.

Next

Try serp.cheap

Every snippet above runs as-is once you export your key. 100 free searches on signup — no card required; pay-as-you-go from $0.75/1k after that, and credits stay valid for 12 months.

Frequently asked questions

How do I test a Google Search API with curl?+

POST a JSON body with your key in the header: curl https://api.serp.cheap/v1/search -H 'X-API-Key: KEY' -H 'Content-Type: application/json' -d '{"q":"...","gl":"us"}'.

How do I extract just the links?+

Pipe the response to jq: ... | jq -r '.organic[].link'.

Get your API key

Cheapest direct, pay by card or crypto, no KYC. Or use a marketplace.