How to Track an Airplane with Python

The output received when inputting N628TS into the opensky-network aircraft database
The output received when inputting N628TS into the opensky-network aircraft database
import requests
data = requests.get("https://opensky-network.org/api/states/all?time=0&icao24=a835af")
print(data)
{'time': 1644596111, 'states': None}
{'time': 1644596206, 'states': [['399184', 'VLJ945S ', 'France', 1644596206, 1644596206, 0.7225, 49.7943, 8839.2, False, 251.49, 139.73, 0, None, 8846.82, '6310', False, 0, 0]]}
import requestsdata = requests.get("https://opensky-network.org/api/states/all?time=0&icao24=40097f").json()if data["states"] != None:    print(f"The longitude of the plane is: {data['states'][0][5]}")    print(f"The latitude of the plane is: {data['states'][0][6]}")else:    print("The plane is currently on the ground!")print("The plane is currently on the ground!")
import requestsimport timeimport folium
def generate_map(points):
map = folium.Map(location=[0,0], zoom_start=2)
folium.PolyLine(points, color='black').add_to(map)
map.save("map.html")
points = []while True:
data = requests.get("https://opensky-network.org/api/states /all?time=0&icao24=HEX_OF_PLANE_YOU_WANT_TO_TRACK").json()
if data["states"] != None:
points.append((data['states'][0][6], data['states'][0][5]))
generate_map(points) else:
        print("The plane is currently on the ground!")    time.sleep(60)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store