BOOTING NEURAL FEED…
NEWSBOX v0.2 · NEON SPONSOR ↗
← WSZYSTKIE NEWSY
Tech & Dev 75% CONFIDENCE Dev.to Top 15 czerwca 2026 01:41

How to Use a SERP API with Python to Track Google Rankings

AUTHOR · Cecilia Hill

Tracking Google rankings sounds simple at first. You have a keyword. You search it on Google. You check where your website appears. That works if you only have one keyword. But once you need to track 50, 500, or 5,000 keywords across different countries, cities, languages, or devices, manual checking stops making sense. You need a repeatable workflow. A simple ranking tracker usually looks like this: Keyword list → SERP API → organic results → ranking check → CSV/report In this tutorial, we’ll build a basic Google ranking tracker with Python and a SERP API. We will: Load a list of keywords Sen

Tracking Google rankings sounds simple at first. You have a keyword. You search it on Google. You check where your website appears. That works if you only have one keyword. But once you need to track 50, 500, or 5,000 keywords across different countries, cities, languages, or devices, manual checking stops making sense. You need a repeatable workflow. A simple ranking tracker usually looks like this: Keyword list → SERP API → organic results → ranking check → CSV/report In this tutorial, we’ll build a basic Google ranking tracker with Python and a SERP API. We will: Load a list of keywords Send each keyword to a SERP API Extract Google organic results Check whether a target domain appears Save ranking data to a CSV file This is not a full SEO platform, but it gives you the core logic behind many rank tracking tools. Why use a SERP API? You can try to scrape Google directly. For a small experiment, it may work. But production scraping gets messy quickly. Google result pages can change by: country city language device search intent query type result features A single result page may include: organic results ads local packs maps images videos shopping results news results People Also Ask related searches Then there are the operational issues: blocked requests CAPTCHA proxy management unstable HTML parser maintenance retry logic localization problems If your real goal is to track rankings, you probably do not want to maintain all of that infrastructure. A SERP API helps by returning structured search results in JSON. Instead of parsing raw HTML, you get data like: { "query" : "best project management software" , "organic_results" : [ { "position" : 1 , "title" : "Best Project Management Software Tools" , "link" : "https://example.com" , "snippet" : "Compare project management tools and pricing..." } ] } That is much easier to work with in Python. What we are building Let’s say we want to track whether our target domain appears for several keywords. Example target domain: example.com Example keywords: best project management software project management tools task management app team collaboration software For each keyword, we want to collect: keyword target domain ranking position result title result URL snippet whether the domain was found Example CSV output: keyword,target_domain,found,position,title,url best project management software,example.com,yes,3,Example Project Tool,https://example.com task management app,example.com,no,,, Install dependencies We only need two Python packages: pip install requests python-dotenv requests is used to call the SERP API. python-dotenv is used to load your API key from a .env file. Create a .env file Create a file named .env : SERP_API_KEY=your_api_key_here SERP_API_URL=https://your-serp-api-endpoint.example.com/search Do not hardcode API keys directly in your script. The exact endpoint depends on your SERP API provider. You can use providers such as SerpApi, Serper, SearchAPI, Bright Data, or Talordata . In this tutorial, we’ll use a generic request format so you can adapt it to your provider. Create a keyword list Create a file named keywords.txt : best project management software project management tools task management app team collaboration software Each line is one keyword. Basic SERP API request Create a file named rank_tracker.py . import os import requests from dotenv import load_dotenv load_dotenv () SERP_API_KEY = os . getenv ( " SERP_API_KEY " ) SERP_API_URL = os . getenv ( " SERP_API_URL " ) def fetch_google_results ( query , location = " United States " , language = " en " ): if not SERP_API_KEY : raise ValueError ( " Missing SERP_API_KEY environment variable " ) if not SERP_API_URL : raise ValueError ( " Missing SERP_API_URL environment variable " ) params = { " api_key " : SERP_API_KEY , " engine " : " google " , " q " : query , " location " : location , " language " : language , " output " : " json " , } response = requests . get ( SERP_API_URL , params = params , timeout = 30

CZYTAJ ŹRÓDŁOWY ARTYKUŁ → WIĘCEJ Z TECH & DEV