Build a rank tracker with a Google SERP API

A rank tracker searches each of your keywords on Google on a schedule, finds the position of your domain in the results, and stores it with the date. With BestSERP each keyword costs one credit per page of 10 results checked, so tracking 100 keywords in the top 20 every day costs about $3 a month.

Last updated:

Key takeaways

  • 100 keywords, top 10, daily: 3,000 credits, about $1.50 a month.
  • 100 keywords, top 20, daily: 6,000 credits, about $3.00 a month.
  • Built on the Google Search API and the Google Maps API.
  • A complete Python example is below: set BESTSERP_API_KEY and run it.

The problem

Search Console reports average positions with a delay and only for your own site. To see today's ranking for a keyword, in a given country, for your site and your competitors, you need the results page itself.

Checking pages by hand does not scale past a few keywords, and scraping Google yourself means maintaining browsers, proxies and parsers. A SERP API returns the ranked results as JSON, so the tracker is a loop and a database table.

Suggested architecture

  1. 1

    Keyword list

    Store each keyword with its country (gl), language (hl) and the domain to look for. Group keywords by project.

  2. 2

    Scheduler

    A cron job or a queue runs the check once a day. Spread requests to stay under 60 searches per minute, or ask for a higher limit.

  3. 3

    Search and match

    Call /search with num 20 (two pages, 2 credits) or num 10 (1 credit). Walk organic[] and match the domain field against your domain and its subdomains.

  4. 4

    History

    Insert one row per keyword and day: date, position (or empty when not found), URL that ranked. Charts and alerts read from this table.

Complete example

Daily rank tracker (Python, appends to ranks.csv). Set BESTSERP_API_KEY and run it with Python 3.9+ and requests.
import os
import time

import requests

API = "https://api.bestserp.com"
HEADERS = {"X-API-KEY": os.environ["BESTSERP_API_KEY"]}


def search(endpoint: str, **body) -> dict:
    """POST one search and return the JSON. Polls while the API answers 202 (still running)."""
    r = requests.post(f"{API}/{endpoint}", headers=HEADERS, json={"timeout": 120, **body}, timeout=130)
    while r.status_code == 202:
        time.sleep(2)
        r = requests.get(f"{API}/requests/{r.json()['requestId']}", headers=HEADERS, timeout=30)
    r.raise_for_status()
    return r.json()


import csv
import datetime

DOMAIN = "example.com"
KEYWORDS = ["running shoes", "trail running shoes", "best marathon shoes"]
COUNTRY, LANGUAGE = "us", "en"


def find_rank(keyword: str):
    results = search("search", q=keyword, gl=COUNTRY, hl=LANGUAGE, num=20)  # top 20 = 2 credits
    for item in results.get("organic", []):
        domain = item.get("domain", "")
        if domain == DOMAIN or domain.endswith("." + DOMAIN):
            return item["position"], item["link"]
    return None, None


with open("ranks.csv", "a", newline="") as f:
    out = csv.writer(f)
    for keyword in KEYWORDS:
        position, url = find_rank(keyword)
        out.writerow([datetime.date.today().isoformat(), keyword, COUNTRY, position or "", url or ""])
        print(keyword, position or "not in top 20")
        time.sleep(1)  # stay well under 60 searches per minute

What it costs

1 credit per page of 10 results, $0.50 per 1,000 credits. The first 3,000 credits are free.
ScenarioCredits per monthCost per month
100 keywords, top 10, daily3,000$1.50
100 keywords, top 20, daily6,000$3.00
1,000 keywords, top 10, daily30,000$15.00
1,000 keywords, top 50, weekly20,000$10.00

Frequently asked questions

How do I track rankings in several countries?
Run the same keyword once per country with a different gl (and hl if the language differs). Each run is a separate search and costs its own credit.
Should I check the top 10 or the top 100?
The API returns up to 50 results per request (num 50, 5 credits). Most trackers check the top 10 or 20 daily and deeper positions less often.
Why does my position differ from what I see in my browser?
Your browser results are personalized by location, history and device. The API sees a clean desktop results page for the country and language you set.
Can I track local rankings on Google Maps?
Yes, use /maps with the city in the query (for example "dentist austin") and match the place title or placeId instead of a domain.
Are failed checks charged?
No. If a search fails or the system is busy, its credits are refunded automatically; retry it later in the same run.

Start with 3,000 free searches

No credit card. Sign in with Google, create a key, send your first request.