How to Track Local Google Rankings by City (Python Guide)
Google silently ignores a location it does not recognise, so a typo gives you non-local results and a used call. Learn the City,Region,Country format, verify it in meta.googleURL, and build a city grid with Python.
Google ignores a location it does not recognise, and it does so silently. Send a misspelled city to our API and you still get a normal 200, one used call and a page of results that were never local at all. I'll show you how the location parameter works, how to prove it was applied, and how to build a city grid for one keyword across desktop and mobile, with a complete Python script.

Why location changes the results
Search for "plumber" in Austin and you will see different results than someone in Dallas. Two cities can show different domains in the top 10, and the same domain can rank 3 in one city and 14 in the next. So to track local SEO you must run the same keyword once per city you care about. Without a location, JustSERP searches as a general user in the country you pick (default "United States"), which hides these differences. We switch off personalisation (pws=0) and result filtering on every request, so your own search history never leaks in and location is the one thing you set on purpose.
The location format
The location parameter takes a place name written as City,Region,Country, with commas and no extra labels. Use Google's own canonical place names:
Austin,Texas,United StatesToronto,Ontario,CanadaManchester,England,United Kingdom
Use the full English spelling of the region and country, the way they appear in Google's location list. Behind the scenes we turn the string into Google's uule parameter exactly as you wrote it. There is no lookup and no validation, so a misspelled place is never rejected: Google just ignores a uule it cannot resolve, you get non-local results, and the call is used. Already generating Google uule strings? Pass one in uule instead (it has to start with w+). If both are sent, location wins.
One more thing the location does not do: it does not change the Google domain or language. For a UK city, send country as well, using the full English name ("United Kingdom", not "UK"). An unrecognised country or language name falls back to United States and English without any error, and still uses a call.
A request looks like this (the key comes from an environment variable and the call runs on your server, never in browser code):
import os
import requests
response = requests.post(
"https://api.justserp.com/v1/search",
headers={"X-API-Key": os.environ["JUSTSERP_API_KEY"]},
json={
"keyword": "emergency plumber",
"location": "Austin,Texas,United States",
"country": "United States",
"device": "mobile",
},
timeout=90,
)
response.raise_for_status()
data = response.json()
print(data["meta"]["googleURL"])
print(data["meta"]["params"])
Only keyword is required. A typical request takes 2 to 4 seconds, but I set the timeout to 90 seconds on purpose: a hard query can keep us working for over a minute, and if your client hangs up first the call is still counted and you lose the answer. A 200 uses one call; 400 and 500 errors are not charged, and 401 and 429 never count.
Check that Google really used your location
Because nothing validates the place name, the response is where you verify it. The meta object echoes the Google URL and the parameters used. When a location was applied, meta.googleURL ends with a uule value that begins w+CAIQICI. After one length character, the rest of that value is just your location string in base64, so you can decode it and compare. This helper does that:
import base64
from urllib.parse import unquote
def location_applied(data, location):
"""True if meta.googleURL carries a uule built from exactly this location."""
url = unquote(data["meta"].get("googleURL", ""))
marker = "uule=w+CAIQICI"
if marker not in url:
return False
tail = url.split(marker, 1)[1][1:].split("&", 1)[0] # skip the length character
try:
decoded = base64.b64decode(tail + "=" * (-len(tail) % 4)).decode("utf-8")
except ValueError:
return False
return decoded == location
That proves the string reached Google, not that Google understood it. For that, run the same keyword once without a location and compare the top results. If the lists are identical for a city where you expect local differences, the name was probably not recognised. Check it against the names Google uses for its location targeting, and keep the exact City,Region,Country spelling that worked.

The parameters that matter for local tracking
These are the options you will combine in local work:

Mobile versus desktop
Most local searches happen on phones, and rankings differ between devices. Set device to "desktop" or "mobile" (the default is desktop). For local work, track both, and treat mobile as the number to optimize first. The mobile response is slightly thinner: it has no inline_videos and no totalResults, so do not build a report that depends on them.
Build a city grid for one keyword
The script below checks one keyword in a list of cities on both devices, finds your domain in each result set, and prints a grid. Every city and device is its own request, so 5 cities on 2 devices uses 10 calls. A thread pool runs them in parallel while staying inside the 10 concurrent requests that the Free and Personal plans allow (25 on Business, 50 on Enterprise). Each result also gets the location_applied check from above, so a mistyped city shows up as a warning instead of a believable but non-local rank.
import base64
import csv
import os
import time
from concurrent.futures import ThreadPoolExecutor
from urllib.parse import unquote, urlparse
import requests
API_URL = "https://api.justserp.com/v1/search"
API_KEY = os.environ["JUSTSERP_API_KEY"]
KEYWORD = "emergency plumber"
DOMAIN = "example.com"
CITIES = [
"Austin,Texas,United States",
"Dallas,Texas,United States",
"Houston,Texas,United States",
"San Antonio,Texas,United States",
"El Paso,Texas,United States",
]
DEVICES = ["desktop", "mobile"]
COUNTRY = "United States" # full English name, matches the cities above
THREADS = 10 # keep at or below your plan's concurrency
def search(keyword, location, device):
for attempt in range(4):
response = None
try:
response = requests.post(
API_URL,
headers={"X-API-Key": API_KEY},
json={
"keyword": keyword,
"location": location,
"country": COUNTRY,
"device": device,
"nfpr": "1",
},
timeout=90,
)
except requests.RequestException:
pass # network error or timeout: retry below
if response is not None:
if response.status_code == 200:
return response.json()
if response.status_code in (400, 401, 429):
raise RuntimeError(f"{response.status_code}: {response.text}")
time.sleep(2 ** attempt)
raise RuntimeError(f"Gave up on {location} ({device})")
def location_applied(data, location):
"""True if meta.googleURL carries a uule built from exactly this location."""
url = unquote(data["meta"].get("googleURL", ""))
marker = "uule=w+CAIQICI"
if marker not in url:
return False
tail = url.split(marker, 1)[1][1:].split("&", 1)[0] # skip the length character
try:
decoded = base64.b64decode(tail + "=" * (-len(tail) % 4)).decode("utf-8")
except ValueError:
return False
return decoded == location
def host_matches(link, domain):
host = (urlparse(link).hostname or "").removeprefix("www.")
return host == domain or host.endswith("." + domain)
def check(job):
location, device = job
try:
data = search(KEYWORD, location, device)
except RuntimeError as err:
return location, device, f"error: {err}", [], False
applied = location_applied(data, location)
results = data.get("organic_results") or []
rank = next((r["position"] for r in results if host_matches(r["link"], DOMAIN)), None)
top3 = [urlparse(r["link"]).hostname for r in results[:3]]
return location, device, rank, top3, applied
jobs = [(city, device) for city in CITIES for device in DEVICES]
with ThreadPoolExecutor(THREADS) as pool:
rows = list(pool.map(check, jobs))
grid = {}
for location, device, rank, top3, applied in rows:
grid.setdefault(location, {})[device] = rank
print(f"{'City':<36}{'desktop':<10}{'mobile':<10}")
for location, by_device in grid.items():
cells = [str(by_device.get(d) or "-") for d in DEVICES]
print(f"{location:<36}{cells[0]:<10}{cells[1]:<10}")
for location, device, rank, top3, applied in rows:
if not applied:
print(f"WARNING: no uule for {location} ({device}), check the spelling")
with open("local_ranks.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["city", "device", "rank", "top_3", "location_applied"])
for location, device, rank, top3, applied in rows:
writer.writerow([location, device, rank or "", " | ".join(top3), applied])
How to read the results
The output grid looks like this:
City desktop mobile
Austin,Texas,United States 3 2
Dallas,Texas,United States 8 11
Houston,Texas,United States - 14
San Antonio,Texas,United States 5 5
El Paso,Texas,United States - -A few rules for interpreting it:
- A dash means "not on the first results page", not "banned". This script checks page 1 only. To look deeper, add
"page": 2to the body and compute the rank as(page - 1) * 10 + position, becausepositionrestarts at 1 on every page. - Compare cities, not just numbers. Strong in Austin and missing in El Paso usually points to weak local signals there: no listing, reviews or content for that city.
- Look at the competitors. The
top_3column in the CSV shows who beats you in each city. The same competitor across all cities is a different problem from a different one in each. - Watch the gap between devices. Ranking well on desktop and poorly on mobile suggests a page experience issue on phones.
This guide tracks organic results (organic_results). Responses include paid_ads too, as one list in page order with no top or bottom flag. Blocks like that only appear when Google showed them, so default them to an empty list when you read them.
Habits for clean local data
- Keep keyword and city lists in a file or sheet so adding a city is one line, not a code change.
- Use the exact same locations every run, so changes in your numbers are real changes.
- Save each run with a date. One snapshot says little; a month of snapshots shows a trend. Our Python rank tracker guide shows how to store history in SQLite.
- Mind the call count. Calls equal keywords times cities times devices. Ten keywords in 20 cities on 2 devices is 400 calls per run.
- Check
meta.googleURLwhen a result looks wrong, to see exactly what was requested: the Google domain, the language and theuule.
Next steps
Create a free account for 2,000 free requests, no credit card needed, and run the grid on your own city list. See the pricing when you scale up, and read the Python guide for every parameter and the full error reference.