Documentation menu
Docs / Guides / Export results to CSV or a spreadsheet

Export results to CSV or a spreadsheet

Pull records across pages and write them to a CSV you can open in Excel or Sheets.

Pull every matching record from BuildData and write a CSV you can open in Excel or Google Sheets. This loops pages until the results run out.

import csv, requests

URL = "https://api.builddata.ca/permit"
HEADERS = {"X-API-Key": "YOUR_API_KEY"}

rows, cursor = [], None
while True:
    params = {"limit": 500}
    if cursor:
        params["cursor"] = cursor
    r = requests.get(URL, headers=HEADERS, params=params).json()
    rows += r.get("results", [])
    cursor = r.get("next_cursor")
    if not cursor:
        break

with open("export.csv", "w", newline="") as f:
    w = csv.DictWriter(f, fieldnames=rows[0].keys())
    w.writeheader()
    w.writerows(rows)

Swap in the filters from the endpoint's reference page to export exactly the slice you want.

Ready to build?Create a free key and start calling BuildData in minutes. No card required.
Get your API key →