# SERP API with curl and jq: one-line recipes

> One-line SerpCrypto SERP API recipes with curl and jq: top 10 links, People Also Ask, AI Overview sources, local pack and Maps, plus a PowerShell version.

- URL: https://serpcrypto.com/docs/curl/
- Last updated: 2026-10-22
- Publisher: SerpCrypto (https://serpcrypto.com)

The fastest way to see what the API returns is a terminal. These recipes print exactly one thing each: links, questions, sources or local businesses. They work in bash and zsh; a PowerShell version closes the page.

**Quick answer — How do I query a SERP API with curl?**

Run `curl -sG "https://serpcrypto.com/api/v1/search" -H "Authorization: Bearer $KEY" --data-urlencode "q=your query"` and pipe the JSON to `jq`. With **SerpCrypto**, each successful search costs 1 credit, from $0.30/1K searches, and errors are free. `-G` turns the data flags into a query string. Credits are paid in crypto, with no KYC.

## Which curl flags matter here?

Set the key once per shell with `export SERPCRYPTO_API_KEY=…`. Install `jq` from your package manager if it is missing.

| Flag | Why |
| --- | --- |
| `-s` | Silent: no progress bar mixed with the JSON. |
| `-G` | Send the `-d` and `--data-urlencode` values as a query string on a GET request. |
| `--data-urlencode` | Encode spaces, quotes and accents in `q` and `location`. |
| `-H "Authorization: Bearer …"` | Your API key. Keep it in an environment variable. |
| `-w '%{http_code}'` | Print the HTTP status, useful when a call fails. |

## How do I print the top 10 links for a keyword?

Ask for the organic results and let `jq` print the position and link of each one, separated by a tab. The `[]?` form prints nothing instead of failing when a block is absent, which keeps scripts quiet on unusual pages.

*Top 10 links*

```bash
# Top 10 organic links, one per line
curl -sG "https://serpcrypto.com/api/v1/search" \
  -H "Authorization: Bearer $SERPCRYPTO_API_KEY" \
  --data-urlencode "q=kubernetes cost monitoring" -d gl=us -d hl=en \
  | jq -r '.organic_results[]? | "\(.position)\t\(.link)"'
```

## How do I list the People Also Ask questions?

Read `people_also_ask[].question`. The questions follow the language in `hl` and change with the country in `gl`, so run the same query in each market you write for. Content teams paste this list straight into a brief.

*People Also Ask*

```bash
# People Also Ask questions, ready for a content brief
curl -sG "https://serpcrypto.com/api/v1/search" \
  -H "Authorization: Bearer $SERPCRYPTO_API_KEY" \
  --data-urlencode "q=how to brew cold brew" -d gl=gb -d hl=en \
  | jq -r '.people_also_ask[]?.question'
```

## How do I see which sources an AI Overview cites?

Read `ai_overview.references`. The block exists only when Google shows an AI Overview for that query and place, so the recipe prints a clear message otherwise. Tracking these sources over time shows whether your pages are cited in Google's generated answers.

*AI Overview sources*

```bash
# Sources cited by the AI Overview, if the page shows one
curl -sG "https://serpcrypto.com/api/v1/search" \
  -H "Authorization: Bearer $SERPCRYPTO_API_KEY" \
  --data-urlencode "q=what is a heat pump" -d gl=us -d hl=en \
  | jq -r 'if .ai_overview then .ai_overview.references[] | "\(.index)\t\(.source)\t\(.link)" else "no AI Overview for this query" end'
```

## How do I get the local pack and the Maps list?

A web search with `location` returns the local pack shown on the results page, usually a few businesses. `engine=google_maps` returns the longer Maps list with address, rating and review count, which `@tsv` turns into rows for a spreadsheet. Both are 1 credit each.

*Local pack, then Google Maps*

```bash
# Local pack in a city, then the full Maps list for the same query
curl -sG "https://serpcrypto.com/api/v1/search" \
  -H "Authorization: Bearer $SERPCRYPTO_API_KEY" \
  --data-urlencode "q=vegan restaurant" \
  --data-urlencode "location=Toronto, Ontario, Canada" -d gl=ca -d hl=en \
  | jq -r '.local_results[]? | "\(.position)\t\(.title)\t\(.rating // "-")"'

curl -sG "https://serpcrypto.com/api/v1/search" \
  -H "Authorization: Bearer $SERPCRYPTO_API_KEY" \
  -d engine=google_maps --data-urlencode "q=vegan restaurant Toronto" -d gl=ca -d hl=en \
  | jq -r '.local_results[]? | [.title, .address, .rating, .reviews] | @tsv'
```

## How do I see the error when a call fails?

Add `-w '\nHTTP %{http_code}\n'` to print the status after the body. An error body is small JSON with `code` and `message`; the [errors page](https://serpcrypto.com/docs/errors/) lists all six codes. The second command reads your credits, which is free.

*Status code and credits*

```bash
# Print the body, then the HTTP status on its own line
curl -sG "https://serpcrypto.com/api/v1/search" \
  -H "Authorization: Bearer $SERPCRYPTO_API_KEY" \
  --data-urlencode "q=test" -w '\nHTTP %{http_code}\n'

# Credits left (free call)
curl -s "https://serpcrypto.com/api/v1/credits" -H "Authorization: Bearer $SERPCRYPTO_API_KEY" | jq .
```

## What is the PowerShell equivalent on Windows?

`Invoke-RestMethod` sends the request and parses the JSON into objects, so you do not need `jq`. Pass the parameters as a hashtable in `-Body`: with a GET request, PowerShell encodes them into the query string. `Format-Table` then prints positions, titles and links.

*PowerShell*

```powershell
# Windows PowerShell 5.1 or PowerShell 7
$headers = @{ Authorization = "Bearer $env:SERPCRYPTO_API_KEY" }
$query = @{ q = "kubernetes cost monitoring"; gl = "us"; hl = "en" }
$data = Invoke-RestMethod -Uri "https://serpcrypto.com/api/v1/search" -Headers $headers -Body $query -Method Get
$data.organic_results | Select-Object position, title, link | Format-Table -AutoSize
```

## When should I move from curl to code?

As soon as you repeat a command with a list of keywords. A shell loop works for a few dozen searches, but retries, parallelism and storage are easier in [Python](https://serpcrypto.com/docs/python/) or [Node.js](https://serpcrypto.com/docs/node/). The requests are the same, so a recipe tested here carries over unchanged. Each search stays at 1 credit, at $0.75/1K searches on the 10,000 searches pack.

## curl questions

### Why does my query return a 400 error in curl?

Usually because `q` was sent with `-d` and contains a character that needs encoding. Use `--data-urlencode "q=…"` for the query and for `location`; plain codes such as `gl=us` can stay with `-d`.

### Can I save the full JSON to a file?

Yes: add `-o result.json` instead of piping to `jq`. Saving raw answers lets you re-parse them later without paying for the search again.

### Does curl on Windows work the same way?

Windows 10 and 11 include `curl.exe`, and the flags are the same. Quoting differs in `cmd.exe`, so PowerShell with `Invoke-RestMethod` is usually simpler there.

---

SerpCrypto: SerpCrypto is a SERP API for developers and AI agents that returns Google and Bing results as JSON, paid in crypto with no ID upload. Prepaid search credits from $0.30/1K searches never expire. No KYC — no ID, no selfie, no documents. Pay in crypto.
