Skip to content

Instantly share code, notes, and snippets.

@Steve-Tech
Created July 1, 2023 13:52
Show Gist options
  • Save Steve-Tech/7ec564d3d7adda47ae92ed3c2b56fb23 to your computer and use it in GitHub Desktop.
Save Steve-Tech/7ec564d3d7adda47ae92ed3c2b56fb23 to your computer and use it in GitHub Desktop.
Flight Recorder for BoardConnect
# Flight Recorder for BoardConnect (Lufthansa Systems GmbH & Co. KG)
# Records flight data in a csv format, see the headers variable for the headers.
import requests
import csv
from time import sleep
header = ('utc', 'flightNumber', 'aircraftRegistration', 'aircraftType', 'callSign', 'altitude', 'groundSpeed', 'heading', 'lon', 'lat', 'distDest', 'temperature')
first = True
with open("flight.csv", 'a', newline='') as f:
writer = csv.DictWriter(f, header)
writer.writeheader()
try:
while True:
json_data = requests.get("https://www.boardconnect.aero/map/api/flightData").json()
utc = json_data['utc']
# Strip out the excess data, stripping whitespace from strings in the process
data = {k: (v.rstrip() if type(v) == str else v) for k, v in json_data.items() if k in header}
print(utc, data)
writer.writerow(data)
# Data seems to only update every 5 seconds
sleep(5)
except KeyboardInterrupt:
print("Exiting...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment