This guide walks you through loading spatial data directly from our GeoJSON API into QGIS using a simple Python script.
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).
Ctrl+Alt+P
Cmd+Option+P
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.
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)
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.
"YOUR_API_URL_HERE"
Replace "YOUR_API_KEY_HERE" with your personal API key.
"YOUR_API_KEY_HERE"
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.
Trouble logging in? Simply enter your email address OR username in order to reset your password.
For faster and more reliable delivery, add support@bridgestation.co.uk to your trusted senders list in your email software.
A code was sent to the recovery email address. Please provide the 6-digit code.
A code can be retrieved from your authentication app. Please provide the 6-digit code.
An email was sent to your recovery email address. If you need further assistance, please contact your system admin.