Last active
March 27, 2018 08:06
-
-
Save joakimsk/60c31fe528262d5fba4ff38350a52cb0 to your computer and use it in GitHub Desktop.
Flightaware FlightXML2 REST API test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import requests | |
username = 'YOURUSERNAMEHERE' | |
api_token = 'YOURKEYHERE' | |
fxml_urlbase = 'http://flightxml.flightaware.com/json/FlightXML2/'; | |
print('Flightaware FlightXML2 test') | |
print(fxml_urlbase) | |
# Get scheduled departures | |
# Needs ICAO style airport handles | |
response = requests.get(fxml_urlbase+'Scheduled?airport=ENVA&startTime=0&howMany=15&filter=airline&offset=0', auth=(username, api_token)) | |
if response.status_code == 200: | |
data = json.loads(response.content.decode('utf-8')) | |
for row in data['ScheduledResult']['scheduled']: | |
print(row) | |
else: | |
print('Error status_code:' + response.status_code) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import requests | |
username = 'YOURUSERNAMEHERE' | |
api_token = 'YOURKEYHERE' | |
fxml_urlbase = 'http://flightxml.flightaware.com/json/FlightXML2/'; | |
print('Flightaware FlightXML2 test') | |
print(fxml_urlbase) | |
response = requests.get(fxml_urlbase+'MetarEx?airport=KJFK&startTime=0&howMany=1&offset=0', auth=(username, api_token)) | |
if response.status_code == 200: | |
print(json.loads(response.content.decode('utf-8'))) | |
else: | |
print('Error status_code:' + response.status_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment