How to Monitor Competitor Google Ads with a SERP API
The API's paid_ads is one list in page order, with no top or bottom flag. Still enough to see who bids on your keywords by city and device. A Python script collects ads and writes a CSV.
Ask the API which ads sit above the results and which sit below, and the honest answer is that it cannot tell you. paid_ads is a single list in page order, with no top or bottom flag. That sounds like a limit, but it is enough to answer the question that matters: who keeps showing up on your keywords, in which city, and on which device. Here is a Python script that collects the ads over time, pulls out the domains and writes a CSV of the most frequent advertisers.

What you need
- Python 3.9 or newer and
requests(pip install requests). - A JustSERP API key. Sign up and copy it from your dashboard.
export JUSTSERP_API_KEY="your-key-here"Run the script on your own machine or server so the key is never exposed to a browser.
What paid_ads contains
When Google shows text ads for a search, the response includes a paid_ads list. Each entry has a position, a title, a link and a description. When Google shows no ads, the field is missing, so your code must treat it as an empty list.
"paid_ads": [
{ "position": 1, "title": "Project Software for Teams", "link": "https://www.example.com/lp", "description": "..." }
]Read position as "the nth ad in page order", not as "the nth bid". Because the list does not separate the block above the results from the block below, a low number means the ad appeared earlier on the page and nothing more. Shopping and local ads are not part of this list either, so the report below covers text ads only.
Ads depend on the auction at that moment, so a single check proves little. The useful signal comes from repeating the same checks and counting. We always request unfiltered, non-personalised results (filter=0, pws=0), so your own browsing history never shapes which ads you collect.
How the monitor works
For every keyword and every variation (a city, a device), the script makes one request, turns each ad into one row with the keyword, variation, time, title and domain, and appends the rows to a CSV. A second function reads the file and counts advertisers.

Each request that returns results uses one API call, so 10 keywords across 3 variations is 30 calls per run. Every call is a fresh fetch from Google, so there is no cached answer to worry about.
Collecting ads
This part fetches one search and flattens its ads into rows. Domains come from the standard library: urllib.parse reads the host, and a leading www. is removed so the same advertiser always gets the same name. The timeout is 90 seconds. A search can take longer than usual when Google pushes back, because we retry before giving up, and a client that hangs up early still has the call counted.
import os
from datetime import datetime, timezone
from urllib.parse import urlparse
import requests
API_URL = "https://api.justserp.com/v1/search"
API_KEY = os.environ["JUSTSERP_API_KEY"]
def search(keyword, **options):
response = requests.post(
API_URL,
headers={"X-API-Key": API_KEY},
json={"keyword": keyword, **options},
timeout=90,
)
response.raise_for_status()
return response.json()
def domain_of(url):
host = (urlparse(url or "").hostname or "").lower()
return host[4:] if host.startswith("www.") else host
def collect_ads(keyword, label, **options):
data = search(keyword, **options)
seen_at = datetime.now(timezone.utc).isoformat(timespec="seconds")
rows = []
for ad in data.get("paid_ads") or []:
rows.append({
"seen_at": seen_at,
"keyword": keyword,
"variation": label,
"position": ad.get("position"),
"domain": domain_of(ad.get("link")),
"title": ad.get("title"),
"link": ad.get("link"),
})
return rows
If an ad has no usable link, domain comes out empty. The report step ignores those rows, so they do not pollute the counts.
Location and device variations
Advertisers often target specific cities, and mobile auctions differ from desktop ones. A variation is just a label plus the extra request options, so the same keyword can be checked in several places:
KEYWORDS = ["plumber near me", "emergency plumber", "water heater repair"]
VARIATIONS = {
"austin-desktop": {"location": "Austin,Texas,United States", "country": "United States", "device": "desktop"},
"austin-mobile": {"location": "Austin,Texas,United States", "country": "United States", "device": "mobile"},
"dallas-desktop": {"location": "Dallas,Texas,United States", "country": "United States", "device": "desktop"},
}
location uses Google's canonical place name in the form City,Region,Country, with no spaces after the commas. We turn it into Google's uule parameter as it is, without checking it. A misspelled city is not rejected: Google ignores it, you get ads for wherever the request came from, and the call is used. If a city report looks suspiciously like your default one, check meta.googleURL in a response and confirm the uule is there.
Location does not change the country. That is why each variation also sets country, as a full English name ("United States", "Canada", "United Kingdom"), never a code like "US" or "UK". An unrecognised name falls back to United States without an error. Keep the set small to start. The number of calls per run is keywords times variations.
Saving to CSV over time
Append to one file on every run, writing the header only the first time. Over days, the file becomes your history.
import csv
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
CSV_PATH = Path("ads_log.csv")
FIELDS = ["seen_at", "keyword", "variation", "position", "domain", "title", "link"]
def run_once():
jobs = [(kw, label, opts) for kw in KEYWORDS for label, opts in VARIATIONS.items()]
def work(job):
keyword, label, opts = job
try:
return collect_ads(keyword, label, **opts)
except requests.RequestException as err:
print(f"skipped {keyword!r} / {label}: {err}")
return []
with ThreadPoolExecutor(max_workers=5) as pool:
batches = list(pool.map(work, jobs))
is_new = not CSV_PATH.exists()
with CSV_PATH.open("a", newline="", encoding="utf-8") as handle:
writer = csv.DictWriter(handle, fieldnames=FIELDS)
if is_new:
writer.writeheader()
for rows in batches:
writer.writerows(rows)
Five workers stay safely below the 10 simultaneous requests allowed on the Free and Personal plans. A failed request is skipped and a 500 does not use a call, so you can rerun the script.
Reporting who advertises most

Now count. For each domain, this report shows on how many checks it appeared, on how many different keywords, and its average position in the ad list.
from collections import defaultdict
def build_report(report_path="advertisers_report.csv"):
stats = defaultdict(lambda: {"checks": 0, "keywords": set(), "positions": []})
with CSV_PATH.open(newline="", encoding="utf-8") as handle:
for row in csv.DictReader(handle):
if not row["domain"]:
continue
entry = stats[row["domain"]]
entry["checks"] += 1
entry["keywords"].add(row["keyword"])
if row["position"]:
entry["positions"].append(int(row["position"]))
ranked = sorted(stats.items(), key=lambda item: item[1]["checks"], reverse=True)
with open(report_path, "w", newline="", encoding="utf-8") as handle:
writer = csv.writer(handle)
writer.writerow(["domain", "ad_appearances", "keywords", "avg_position"])
for domain, entry in ranked:
average = sum(entry["positions"]) / len(entry["positions"]) if entry["positions"] else ""
writer.writerow([domain, entry["checks"], len(entry["keywords"]), round(average, 1) if average != "" else ""])
if __name__ == "__main__":
run_once()
build_report()
Open advertisers_report.csv in a spreadsheet. A domain that shows up on many keywords is a broad competitor; one that shows up only in one city is probably a local business or a regional campaign.
Reading the report
The CSV answers a few practical questions. Which domains appear on the most keywords? Those are your broad competitors, and the ones to study first. Which domains appear only on your most valuable keywords? They are probably bidding where it matters most to you. Does a domain appear on mobile but not desktop, or in one city only? That points to a targeted campaign.
Check the average position as well, with the page-order caveat in mind. An advertiser that is consistently near the start of the list is placed early on the page, while one that appears late and only now and then is testing. Look at both numbers together: appearances tell you how persistent a competitor is, position tells you where they tend to sit.
Remember what the data is. It is a sample of what Google showed at the moments you checked, not a full list of everyone who bids, and it does not tell you what anyone pays. Use it to spot patterns and changes over weeks, and treat any single run as a snapshot.
Habits that make the report trustworthy
- Run it on a schedule at a few different times of day. Ads rotate, so one daily check at the same hour can miss advertisers.
- Look at ad copy too. The
titleanddescriptioncolumns show the offers competitors test. - No ads is a result. An empty list means Google showed no ads for that search at that moment.
- Keep the variation list focused on the cities and devices your customers actually use.
- Store the key in an environment variable and keep the CSV files out of public repositories.
Next steps
You can now see who is advertising on your keywords and how that changes by place and device. Create a free account for 2,000 free requests, no credit card needed, and look at the pricing when you scale up. For every request option, read the Python guide to the JustSERP API.