FlightAware authentication - python

Hey gang,
Im using Python to with my RPi and FlightAware. There are settings in the config to get additional flight data from FA, but Im getting the following debug message in my log file.

FA API status code: 401

Authentication Required

Authentication Required

The following is in my config file, of which the API key is taken from my flightaware account, and my username is my name here.

[flightaware]
; FlightAware API allows to get more information on the flights. Basic API access is now free
; and if you are FA feeder, your request limit is doubled. For more details check:
; https://flightaware.com/commercial/flightxml/pricing_class.rvt
fa_enable = True
fa_username = shodgsonaus
fa_api_key = ***************************

Can anyone please kindly shed some light on why I might be getting authentication issues?

Many thanks…Simon

I take it you do have fxmlUrl Set to the correct value for FlightXML3 ?https://flightxml.flightaware.com/json/FlightXML3/
I know that authentication issues arise if you call the wrong version to that associated with your account.
See this discussion where someone had a similar problem:

@LawrenceHill
To the rescue once more champion

I’ll look into that right now. Thankyou.

I’ll let you know if any success.

Thankyou again Sir.

Unfortunately no success on that front Im afraid.
Im trying to set the variable in my python code as follows:

Assign FlightAware variables.

fxmlUrl = ‘https://flightxml.flightaware.com/json/FlightXML3/
fa_enable = parser.getboolean(‘flightaware’, ‘fa_enable’)
fa_username = parser.get(‘flightaware’, ‘fa_username’)
fa_api_key = parser.get(‘flightaware’, ‘fa_api_key’)

And this in my config.ini

[flightaware]
; FlightAware API allows to get more information on the flights. Basic API access is now free
; and if you are FA feeder, your request limit is doubled. For more details check:
; https://flightaware.com/commercial/flightxml/pricing_class.rvt
fa_enable = True
fa_username = shodgsonaus
fa_api_key = xxxxxxxxxxxxxxxxxxxxxxxxx

Im sure Im missing something incredibly simple.

Cheers
Simon

Sorry for the confusion. All new AeroAPI users should be on version 4 now. This means that the old AeroAPI examples involving a FlightAware username as a part of the authentication or “flightxml” in the url are out of date and should not longer be referenced for new users.

The new api URL is https://aeroapi.flightaware.com/aeroapi/ and and only the API Key is used for authentication in the request header x-apikey. The various resources can be seen in the Documentation Portal. With a slight change to the apiKey line, the python snippet from the product page can be used to fetch the API key from your config.ini.

import requests

apiKey = parser.get(‘flightaware’, ‘fa_api_key’)
apiUrl = "https://aeroapi.flightaware.com/aeroapi/"

airport = 'KSFO'
payload = {'max_pages': 1}
auth_header = {'x-apikey':apiKey}

response = requests.get(apiUrl + f"airports/{airport}/flights",
    params=payload, headers=auth_header)

if response.status_code == 200:
    print(response.json())
else:
    print("Error executing request")
1 Like

Hey gang,
Im using Python to with my RPi and FlightAware. There are settings in the config to get additional flight data from FA, but Im getting the following debug message in my log file.

FA API status code: 401

Authentication Required

Authentication Required

The following is in my config file, of which the API key is taken from my flightaware account, and my username is my name here.

[flightaware]
; FlightAware API allows to get more information on the flights. Basic API access is now free
; and if you are FA feeder, your request limit is doubled. For more details check:
; https://flightaware.com/commercial/flightxml/pricing_class.rvt
fa_enable = True
fa_username = shodgsonaus
fa_api_key = ***************************

Can anyone please kindly shed some light on why I might be getting authentication issues?

Many thanks…Simon

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.