PGN API Interactive Tutorial
This interactive notebook demonstrates how to use the PGN API with Python. Each cell can be executed independently by clicking the Run button.
Tip: Use the Copy button in each cell to copy the Python code to your clipboard.
Get all available locations from the API
import requests
BASE_URL = "https://api.pandonia-global-network.org/v1"
response = requests.get(f"{BASE_URL}/files/locations")
locations = response.json()
print(locations)
Get instruments for Innsbruck
location = "Innsbruck"
response = requests.get(f"{BASE_URL}/files/{location}")
instruments = response.json()
print(instruments)
Get daily L2 files for Innsbruck instrument 106
location = "Innsbruck"
instrument = 106
spectrometer = "1"
level = "L2"
code = "rnvs3"
start = "2025-01-01"
end = "2025-02-01"
url = f"{BASE_URL}/files/{location}/{instrument}/{spectrometer}/{level}?start={start}&end={end}&code={code}"
response = requests.get(url)
files = response.json()
print(files)
Download a specific file
filename = "Pandora106s1_Innsbruck_20250128_L2_rnvs3c26d20230717p1-8.txt"
download_url = f"{BASE_URL}/download/{filename}"
response = requests.get(download_url)
with open(filename, "wb") as f:
f.write(response.content)
print(f"Downloaded {filename}")
Download bulk L2 data for a date range
params = {
"pan_id": 106,
"spectrometer": "1",
"location": "Innsbruck",
"code": "rnvs3",
"blickp_version": "p1-8",
"start_datetime": "2023-01-09T00:00:00",
"end_datetime": "2023-01-09T23:59:59"
}
bulk_url = f"{BASE_URL}/download/bulk_l2"
response = requests.get(bulk_url, params=params)
if response.status_code == 200:
filename = response.headers.get('Content-Disposition').split('filename=')[1]
with open(filename, "wb") as f:
f.write(response.content)
print(f"Downloaded bulk L2 file: {filename}")
else:
print(f"Error: {response.status_code}")
Note: This tutorial uses Python with the
requests library. Install it with
pip install requests.
See the
API documentation for more details.