Skip to Content
BuddyGeoDocs

Python (geopy) & QGIS setup

Fix public Nominatim 403 blocks in Python geopy in three lines, geocode pandas DataFrames via /v1/batch, and speed up QGIS workflows.

If your Python geopy script or QGIS workflow is getting HTTP 403 Forbidden or throttled at 1 request/second on nominatim.openstreetmap.org, you can switch to BuddyGeo without rewriting your geocoding parser.

Python geopy drop-in fix (3 lines)

BuddyGeo serves Nominatim-compatible /search and /reverse endpoints (jsonv2), so geopy.geocoders.Nominatim works directly by changing the domain and adding X-API-Key:

import os
from geopy.geocoders import Nominatim

geolocator = Nominatim(
    domain="www.buddygeo.com",
    scheme="https",
    user_agent="my-app/1.0",
    timeout=15,
)
geolocator.headers["X-API-Key"] = os.environ["BUDDYGEO_API_KEY"]

location = geolocator.geocode("290 Bremner Boulevard, Toronto, Canada")
print(location.latitude, location.longitude, location.address)

reverse = geolocator.reverse((43.6426, -79.3871))
print(reverse.address)

Download the complete runnable geopy_buddygeo.py script (includes both geopy drop-in usage and asynchronous POST /v1/batch polling).

Bulk geocoding a pandas DataFrame via /v1/batch

For hundreds or thousands of addresses, submit a single POST /v1/batch request instead of looping row by row:

import os, time, requests

API_KEY = os.environ["BUDDYGEO_API_KEY"]
HEADERS = {"X-API-Key": API_KEY, "Content-Type": "application/json"}

rows = [
    {"id": "1", "q": "290 Bremner Boulevard, Toronto, Canada"},
    {"id": "2", "q": "5 Avenue Anatole France, Paris, France"},
]

job_id = requests.post(
    "https://www.buddygeo.com/v1/batch",
    headers=HEADERS,
    json={"rows": rows},
    timeout=30,
).json()["job_id"]

while True:
    job = requests.get(
        f"https://www.buddygeo.com/v1/batch/{job_id}",
        headers=HEADERS,
        timeout=30,
    ).json()
    if job["status"] in ("completed", "partial", "failed", "cancelled"):
        print(job["counts"], job["rows"])
        break
    time.sleep(1.0)

Faster QGIS geocoding (instead of waiting hours on MMQGIS)

MMQGIS against public Nominatim runs at ≤1 row per second (~14 hours for 50,000 rows) and routinely fails mid-run with 403 blocks. The fastest workflow for QGIS layers:

  1. Export your attribute table or address list as CSV or XLSX.
  2. Upload it in BuddyGeo Bulk Geocoding (up to 50,000 rows / 25 MB, free preview + exact max-credit estimate, 0 credits on unmatched rows).
  3. Download the enriched CSV with bg_latitude, bg_longitude, and bg_match_level appended.
  4. In QGIS, open Layer → Add Layer → Add Delimited Text Layer, select bg_longitude as X field, bg_latitude as Y field, and EPSG:4326 (WGS 84) as CRS.

Open in the app

On this page