FlightXML3 AirlineFlightSchedules

Hi Team,

I am trying to retrieve all flight schedules for a particular carrier for the next 24 hours using AirlineFlightSchedules. Initially I was only receiving 15 flights, when there should have been many more than that. The API documentation and discussion here indicated that 15 was default and that I need to use the howMany parameter to increase this number.

However, when I increased the howMany parameter to 500, I still only get 15 responses. The documentation also seems to suggest that the howMany parameter may only cover past flights, not future flights, is this the case? If so, what parameter do I set to retrieve ALL flights for the specified time period?

Other conversations here also talk about an account setting called “SetMaximumResultSize” which is also defaulted to 15, which might be limiting my results. Looking through the account settings I cannot find this option. Does this option still exist? If so, how do I go about increasing it?

What is your package? You may have to work with the “next_offset” parameter. Here is some sample code.

from json import loads, dumps
import time
from string import ascii_uppercase

def get_Schedule_by_Airline(airline):

    t1 = int(time.mktime(time.strptime("18.09.2017", "%d.%m.%Y")))
    t2 = int(time.mktime(time.strptime("25.09.2017", "%d.%m.%Y")))

    fxmlUrl = "https://flightxml.flightaware.com/json/FlightXML3/"
    list_of_flights = []
    next_offset = -1

    payload = {'start_date' : str(t1), 'end_date' : str(t2), 'airline' : airline, 'exclude_codeshare' : 'True',
        'howMany':'150', 'offset' : '0'}
    response = requests.get(fxmlUrl + "AirlineFlightSchedules",
        params=payload, auth=(username, apiKey))
    wait()
    kr = 'AirlineFlightSchedulesResult'
    if response.status_code == 200:
        r2 = loads(response.content)
        if kr in r2:
            list_of_flights = r2[kr]['flights']
            next_offset = r2[kr]['next_offset']
        else:
            print "Error executing request"+ response.content
            next_offset = -1

    while next_offset > -1:
        payload['offset'] = str(next_offset)
        response = requests.get(fxmlUrl + "AirlineFlightSchedules",
                                params=payload, auth=(username, apiKey))

        if response.status_code == 200:
            r2 = loads(response.content)
            list_of_flights.append(r2['AirlineFlightSchedulesResult']['flights'])
            next_offset = r2['AirlineFlightSchedulesResult']['next_offset']
            print next_offset
            if next_offset == -1:
                break
            wait()
        else:
            print ("Stopped with offset" + str(next_offset) + response.content)
            break
    flights_pd = pd.concat([pd.DataFrame(t, index=range(len(t))) for t in list_of_flights]) # for schedule results
 
    return flights_pd.drop_duplicates()

Hi funkmeister380,

Thanks for answering :slight_smile:

I am aware of the next_offset option and this would certainly work, however i would rather not use it due to the volume of schedules i will potentially be accessing.

15 results per request is very limited, and as i mentioned in my initial post, there has been talk in other discussions on this issue that settings exist to increase this limit, however i cannot find them in either the documentation or the account settings pages.

Now i’m curious to know if these options are limited to FlightXML2 and have been discontinued in version 3 or if they have simply been moved elsewhere.

It appears you are on the starter plan, unless you have another account on a different username. Under the starter account, offsets are not a feature of that tier, nor are flight schedules. You would need to be on the Silver Plan (49.95/month) in order to have those 2 features.