Python technical support

I have obtained the API key, and I want to obtain some flight data, including the actual takeoff and landing time and type of aircraft. I tried to verify with the example you provided, but failed. I hope to obtain python code support.

This is the output, can you help me to see what the problem is

Are you using the python example seen at https://flightaware.com/commercial/flightxml/? If you are using a Python 3 environment it will require a small change to make the print statements correct. Otherwise, can you please post the example, with your username and key removed, that isn’t working properly?

This is my Python code, can you help me see what went wrong

The API key associated with your account is for FlightXML v2, but the fxmlURL in the example used is for FlightXML v3. This will cause the authentication to fail and the response status code to be a 401. If your example only prints a result on a status code 200 occurs then this is why there is no output.

Please try changing the fxmlUrl the value to https://flightxml.flightaware.com/json/FlightXML2/ and update the request to match the format of one of the FlightXML v2 requests found here. You may also want to add a condition to print the error if a status code 200 is not returned.

I have fxmlUrl change to https://flightxml.flightaware.com/json/FlightXML2/, but the result is still the same, according to “the Process finished with exit code 0”, is there any solution?

You need to make your program print out the error message if the status_code != 200, otherwise it will be very difficult to debug. You are likely getting an authentication failure, or invalid arguments or function name. Be sure you are not still attempting to call FlightInfoStatus if you are using FlightXML2–that function is only available under FlightXML3 (the closest equivalent in FlightXML2 is FlightInfoEx).

My KPI key is invalid. What’s the matter,Can you give me a solution?

The following works fine for me:

import requests
import sys

result = []

username = "xxxxxxxxx"
apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"

fxmlUrl = "https://flightxml.flightaware.com/json/FlightXML2/"

payload = {'ident': 'N56821', 'howMany': 5}

response = requests.get(fxmlUrl + "FlightInfoEx", params=payload, auth=(username, apiKey))
if response.status_code == 200:
    decodedResponse = response.json()
    for flight in decodedResponse['FlightInfoExResult']['flights']:
        print(f"{flight['ident']} = {flight['faFlightID']} ({flight['origin']} to {flight['destination']})")
else:
    print(f"Got error {response.status_code}")
    print(response.text)

My code problem has been solved. I tried it with my colleague’s KPI key and found that the code is valid, so I found that there is a problem with my KPI key. What is the reason? The expiration date on my KPI key says “never” (as shown in the picture above). Is there a solution?

Your account currently has two API Keys assigned to it, and both appear to be enabled so they should both work.

Ensure that you have typed in your username and API key into your program correctly. If you are still having problems, please indicate what error code and message is being returned by our server. Use the python code I provided in my prior message as a starting point, if you are still having issues with your own code.

Hello, my API key is already in use, thank you very much for your help!

Now I have a problem. I want to obtain all flight data of a certain airport within a month. Could you please give me some code support

For past flights at an airport, you will probably want to use Arrived and Departed. Keep in mind that FlightXML only provides access to data for approximately 14 days.

If you have a need for a longer time period, then a custom report might be a possible option for you.

hello

The Flightaware account description shows that an enterprise account can get eight months of historical flight data.What does that mean?

That entire page and table is only describing feature differences between account types on the website, not through FlightXML or any API services.

Hello ,bovineone
When I use the API to get the flight schedule, I need to display a large amount of flight data at one time, but the calling rules state that a maximum of 15 pieces of information are displayed at a time, which is obviously not enough for me. I have learned that I can use the SetMaximumResultSize method to display more information, but I am not very familiar with the method of calling SetMaximumResultSize. I hope to get some code help. For example, can you give me an example of using SetMaximumResultSize?

Same as above, except for the inner part:

# ... more preceding code ...

payload = {'max_size': 100}
response = requests.get(fxmlUrl + "SetMaximumResultSize", params=payload, auth=(username, apiKey))

# ... more following code ...

Hello bovineone

Our school will start the winter vacation now, and the laboratory will be unattended by then.Can ADS-B be turned off, and will this have any impact on future use?

Hello bovineone:

Now we want to download a whole day’s data of an airport at one time through API. The amount of data will be a little large, and there may be thousands of flight information. Is there any way to download the data at one time?