Skip to content

Instantly share code, notes, and snippets.

@RichLogan
Created September 24, 2016 09:21
Show Gist options
  • Save RichLogan/b75e60330e8faf8e04b8a1eed3ff85de to your computer and use it in GitHub Desktop.
Save RichLogan/b75e60330e8faf8e04b8a1eed3ff85de to your computer and use it in GitHub Desktop.
import json
from opensky_api import OpenSkyApi
api = OpenSkyApi()
states = api.get_states()
results = {}
results["states"] = []
for state in states.states:
state_dict = {}
state_dict["icao24"] = state.icao24
state_dict["callsign"] = state.callsign
state_dict["country"] = state.origin_country
state_dict["time_position"] = state.time_position
state_dict["time_velocity"] = state.time_velocity
state_dict["longitude"] = state.longitude
state_dict["latitude"] = state.latitude
state_dict["altitude"] = state.altitude
state_dict["on_ground"] = state.on_ground
state_dict["velocity"] = state.velocity
state_dict["heading"] = state.heading
state_dict["vertical_rate"] = state.vertical_rate
state_dict["sensors"] = state.sensors
results["states"].append(state_dict)
print(json.dumps(results))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment