Published · Updated
Building an SEO Rank Tracker with a SERP API
Rank tracking, meaning checking where your pages (or a client's) land in Google search results for a list of target keywords, is one of the most common reasons teams reach for a SERP API instead of building their own Google scraper. Here's how the pieces fit together if you're building one yourself.
For endpoint examples, targeting, and collection costs, start with the rank tracker API. PrismCrawl's SERP API overview covers the live Google and Bing endpoints, targeting controls, pagination, request history, and pricing used by this workflow. The Google Search API guide focuses on retrieving those results programmatically.
Core architecture
- Keyword list. The queries you care about, usually tagged by page, client, or campaign.
- Scheduled search execution. Running each keyword through search on a recurring basis (commonly daily or weekly).
- Position extraction. Finding your target domain in the organic results and recording its rank, along with metadata like the URL that ranked, the page title shown, and whether it appeared in any SERP features (featured snippet, "People also ask," local pack, etc.).
- Historical storage. Keeping every check over time, not just the latest one, so you can chart movement and correlate ranking changes with content or backlink work.
- Reporting/alerting. Surfacing significant rank drops or gains, usually to a dashboard or a notification channel. Re-check a sudden drop before alerting, because Google sometimes serves trackers poisoned SERPs with the usual results swapped out.
Why raw scraping struggles here specifically
Rank tracking has a property that makes it harder than typical scraping: you need a consistent search context, including location and device type, since rankings vary by geography and by mobile vs. desktop. A basic scraper making requests from one IP location, with generic headers, doesn't reliably reproduce this. Volume makes it worse, because a rank tracker running hundreds or thousands of keyword checks daily looks exactly like the kind of automated traffic Google's systems are built to detect and block. The same sensitivity is why tracked rankings often differ from what you see in Google.
# Position extraction from a successful PrismCrawl JSON response.
from urllib.parse import urlparse
target_domain = "example.com"
for result in payload["data"]["content"].get("results", []):
host = (urlparse(result["url"]).hostname or "").lower()
if result["type"] == "organic" and (
host == target_domain or host.endswith("." + target_domain)
):
print(f'Ranked #{result["rank"]}: {result["title"]}')
break
else:
print("Not found on the checked page")
Tracking past page one
Each request returns one page of results. To track deeper, request start=0, 10, 20, and so on. Don't number results by page offset alone. Google doesn't always return 10 organic results per page, and separately fetched pages overlap, so the same URL can appear at #10 on one page and #11 on the next. Merge the pages in order, drop URLs you've already seen, and renumber. Because of that overlap, reaching 50 unique positions usually takes six pages.
For organic-only tracking, add udm=14, Google's Web filter. Separately from location targeting, Google doesn't always serve the same ranking to every network, especially for local searches like service businesses. The Web filter largely removes that difference, so repeated checks agree much more often. It also drops SERP features like AI Overviews and local packs, so run a separate unfiltered page-one check if you report on those. Our guide to why tracked rankings don't match Google covers this in more detail.
# Collect absolute organic positions 1-50 from separately fetched pages.
import os
import requests
from urllib.parse import urlparse
def normalize(url):
parsed = urlparse(url)
host = (parsed.hostname or "").lower().removeprefix("www.")
return host + parsed.path.rstrip("/")
def organic_positions(query, depth=50):
seen, ranked = set(), []
for start in range(0, depth + 1, 10):
response = requests.post(
"https://api.prismcrawl.com/v1/google/search",
headers={"x-api-key": os.environ["PRISMCRAWL_API_KEY"]},
json={
"query": query, "gl": "us", "hl": "en-US",
"device": "desktop", "udm": 14, "start": start,
},
timeout=120,
)
response.raise_for_status()
results = response.json()["data"]["content"].get("results", [])
organic = [r for r in results if r["type"] == "organic"]
if not organic:
break
for result in organic:
key = normalize(result["url"])
if key not in seen:
seen.add(key)
ranked.append(result["url"])
if len(ranked) >= depth:
break
return ranked[:depth] # list index + 1 is the absolute organic position
Treat an overlap between pages as normal rather than as a failed check. Positions past page two also move by a few spots between checks, so compare trends rather than single deep readings.
Location and device accuracy
Because rankings vary by location, a rank tracker ideally requests results as if searching from each location you're tracking (a specific city, state, or country), not just from wherever your server happens to run. This is one of the trickier parts to get right with raw scraping, and geographically distributed proxies alone don't solve it. The exit IP is only one of several signals Google weighs, and it's the weakest of them. Our guide to Google search localization covers which parameters actually control result geography and why a proxy in a given city doesn't reliably return that city's results.
Using a SERP API for this
Running a query and getting ranked results back as data instead of HTML is the textbook use case for a SERP API. PrismCrawl returns structured, ranked JSON for a given query, so the position-extraction step above is just reading a field rather than parsing HTML. Geo-sensitive tracking is handled through explicit parameters (country and interface language, plus city-level location or coordinates targeting), so each tracked location is a value in the request rather than a property of your infrastructure. To compare providers by cost at 1,000 and 10,000 keywords, see the best rank tracking APIs.
- Structured output. Organic results, positions, and SERP features come back as JSON, matching the schema in the API reference.
- No subscription required. Rank tracking is a recurring, scheduled job, and with PrismCrawl's one-time credit pricing your cost follows the number of checks you actually run instead of a monthly plan sized for peak usage.
- Free tier to prototype with. The 100 free credits are enough to build and test your extraction logic against real data before committing to a plan.
For a complete, runnable version that also records whether Google's AI Overview, Google AI Mode, and Bing's AI answer cite your site, see how to build a rank and AI Overview citation tracker in TypeScript.
Frequently asked questions
How often should I check keyword rankings?
Daily is common for actively-managed campaigns; weekly is often sufficient for stable, lower-priority keywords. Balance freshness against the cost of checks. Our best SERP APIs comparison shows how per-check costs add up at different frequencies.
Do rankings really vary that much by location?
Yes, especially for anything with local intent (services, restaurants, "near me" searches) — the same keyword can show completely different top results in different cities.
Can I build a rank tracker without maintaining my own scraper?
Yes — a SERP API handles the search execution and parsing, so your rank tracker only needs to handle scheduling, storage, and reporting. Sign up for PrismCrawl to get started with 100 free credits.