How to access FlightInfoStatus API


#1

Hi,
I got an api key,but i’m struck in accessing the api via python. can you please guide me to to get output .
I want below information from API as output like json/xml data.
Flight number:
Date:
Source:
Destination:
Arrival date time:
Estimated Arrival date time:
Departure date:
Estimated departure date time:
Status:
Actual arrival time:

Below one is my code

import requests

username = "i gave my username here"
apiKey = " i gave here my api key"
fxmlUrl = “https://flightxml.flightaware.com/json/FlightXML3/

payload={‘ident’:‘ak10’}
response = requests.get(fxmlUrl,params=payload,auth=(username, apiKey))
if response.status_code == 200:
print response.json()
else:
print “Error executing request”

Output is exception
raise ValueError(“No JSON object could be decoded”)
ValueError: No JSON object could be decoded


#2

I don’t know Python, but:

fxmlUrl doesn’t contain a ‘command’, should that line be:

fxmlUrl =“https://flightxml.flightaware.com/json/FlightXML3/GetFlightTrack”


#3

Hi,
Thanks for your reply, i tested by the given URL, but receiving same exception

fxmlUrl=“https://flightxml.flightaware.com/json/FlightXML3/GetFlightTrack/

Need to access this API :FlightInfoStatus


#4

Your GET request is successful, but it’s not returning a JSON object because you’re not using the correct endpoint for the request.

The error is coming from print response.json()
because you’re not using a valid endpoint here: requests.get(fxmlUrl,params=payload,auth=(username, apiKey))

You need to use https://flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus, not just https://flightxml.flightaware.com/json/FlightXML3/


#5

Hi ,

Thanks a lot, its working fine now.

But with the request of flight id ak10 it returns error, then i figured in the flight aware website ak10 is referred as axm10.

Can you please guide me to get the actual and mapped flight ID in flight aware.