Build a Custom SEO Tool with the Google SERP API
Track rankings, analyze competitors, and find content gaps using structured search data.
In this tutorial we'll build a minimal rank tracker that polls Google SERP daily and stores positions in SQLite. By the end you'll have a working tool you can extend into a full SEO product.
What we're building
- A Python script that fetches Google search results for a list of keywords
- Stores rank positions in SQLite with a timestamp
- Generates a simple report showing rank changes week-over-week
The Google SERP endpoint
GET /search?q=<keyword>&country=<cc>&num=10
Returns structured JSON with organic results, featured snippets, People Also Ask, and related searches. No HTML parsing required.
Step 1: Set up the database
import sqlite3
db = sqlite3.connect("ranks.db")
db.execute("""
CREATE TABLE IF NOT EXISTS ranks (
keyword TEXT, domain TEXT, position INTEGER, captured_at TEXT
)
""")Step 2: Fetch and parse
import requestsdef fetch_rank(keyword: str, domain: str) -> int | None: r = requests.get( "https://google-serp-by-helix-api.p.rapidapi.com/search", headers={ "X-RapidAPI-Key": "YOUR_KEY", "X-RapidAPI-Host": "google-serp-by-helix-api.p.rapidapi.com", }, params={"q": keyword, "num": 100} ) results = r.json()["data"]["organic_results"] for i, result in enumerate(results, 1): if domain in result["link"]: return i return None # Not in top 100 ```
Step 3: Track over time
Run this script daily via cron or GitHub Actions, and you'll quickly have a rank history dataset that rivals paid SEO tools costing $200+/month.
The full code is on our GitHub examples repo.