DEV Community

Dylan Parker
Dylan Parker

Posted on

Tracking Google Rankings Across Devices with Python and SERP APIs

I recently needed a way to verify how a site was ranking for a specific set of keywords across different regions and devices without checking everything manually.

The biggest surprise was how different the results were between desktop and mobile SERPs for the exact same keywords.

To automate the process, I put together a simple Python script using a live ranking API:

import requests

API_KEY = "your_api_key_here"

def check_rankings(keywords, location, device):
results = {}

for kw in keywords:
response = requests.get(
"https://api.serpspur.com/v1/rankings",
headers={
"Authorization": f"Bearer {API_KEY}"
},
params={
"keyword": kw,
"location": location,
"device": device,
"engine": "google"
}
)
data = response.json()
results[kw] = data.get("position", "Not found")
Enter fullscreen mode Exit fullscreen mode

return results

Enter fullscreen mode Exit fullscreen mode




Example usage

keywords = [
"SEO tools",
"keyword research",
"backlink checker"
]

rankings = check_rankings(
keywords,
"United States",
"mobile"
)

for kw, pos in rankings.items():
print(f"{kw}: Position {pos}")

A few things I noticed while testing:

Mobile rankings shifted much more frequently
Local intent keywords behaved differently by region
Some pages ranked significantly higher on desktop than mobile
Personalized SERPs make manual checking unreliable

Automating this saved a lot of time compared to constantly opening incognito windows and switching VPN locations.

Curious if anyone else here tracks rankings separately for:

mobile vs desktop
different countries
local SERPs
AI Overviews / SGE visibility

Would love to hear what workflows or APIs others are using for accurate SERP monitoring.

Top comments (3)

Collapse
 
kevincarroll85 profile image
kevincarroll

Great point about mobile vs. desktop—I've seen similar shifts, especially with local keywords where Google seems to favor mobile-friendly sites. Did you notice any specific industries where the gap was wider?

Collapse
 
lucy-green profile image
Lucy Green

Nice approach to automate cross-device ranking checks. I've seen similar gaps too, especially with local keywords where mobile results often prioritize different SERP features like maps or snack packs.

Collapse
 
burhanchaudhry profile image
Burhan

Nice approach! I've seen mobile rankings drop by 10+ spots on some queries, especially for local searches where Google prioritizes map packs. Do you factor in personalized results or location rounding when automating this?