This guide walks you through loading spatial data directly from our GeoJSON API into QGIS using a simple Python script.
Step 1: Open the QGIS Python Editor
You do not need an external coding environment; QGIS has a Python console built right in.
Open a new or existing QGIS project.
In the top menu, click Plugins > Python Console (Shortcut: Ctrl+Alt+P on Windows, Cmd+Option+P on Mac).
A panel will open at the bottom of your screen. Look at the toolbar inside that panel and click the Notepad icon (Show Editor). A blank text editor will slide open on the right side.
Step 2: Paste the Script
Copy the following Python script and paste it into the blank text editor panel:
import requests
import os
from qgis.core import QgsProject, QgsVectorLayer
# 1. Provide your API URL and Key
endpoint_url = "YOUR_API_URL_HERE"
api_key = "YOUR_API_KEY_HERE"
# 2. Fetch the data securely via API headers
response = requests.get(endpoint_url, headers={'ApiKey': api_key})
response.raise_for_status()
# 3. Save the data to a temporary file on your computer
temp_file = os.path.join(os.path.expanduser('~'), 'temp_api_data.geojson')
with open(temp_file, 'w', encoding='utf-8') as f:
f.write(response.text)
# 4. Load the file directly into your map
vlayer = QgsVectorLayer(temp_file, "API Data Layer", "ogr")
if vlayer.isValid():
QgsProject.instance().addMapLayer(vlayer)Step 3: Run and View Your Data
Replace "YOUR_API_URL_HERE" with your actual API endpoint link. BridgeStation provides a number of standard GeoJSON endpoints. To tailor the data request to your specific requirements and obtain a dedicated endpoint for your authority, please contact BridgeStation Support.
Replace "YOUR_API_KEY_HERE" with your personal API key.
Click the Green Play Button (Run Script) at the top of the script editor panel.
A new layer named "API Data Layer" will instantly appear in your QGIS Layers panel on the left.
Tip: If you cannot see the data on your map right away, right-click "API Data Layer" in your Layers panel and select Zoom to Layer. QGIS will center your screen directly over the newly loaded data.
Article ID: 341, Created: 6/5/2026 at 10:58 AM, Modified: 6/30/2026 at 11:29 AM