questions regarding FlightXML 2.0 Search methods

I would like to run a search that finds all flights currently in the air, however I am having trouble validating that I am getting the correct number of flights.

For example in the code below, I would expect the number of flights returned in result a and b to be the same, instead I receive 990 and 393 results respectively.



api.service.SetMaximumResultSize(10000)
a = api.service.SearchBirdseyeInFlight(query='{true inAir}', howMany=1000)
b = api.service.Search(query='-inAir 1', howMany=1000)


The other concern I have is that these number seem quite low. I would imagine there would be several thousand flights in the air around the entire world at any given time.

Any help/advice would be appreciated.

–Brice

Both functions have to do an initial search with a first-pass limit, then apply some secondary processing to remove blocked flights, and then apply the requested howMany limit.

Search happens to have an legacy internal limit of 400 initial results before doing the blocked flight removal, so that’s why you got 393.

SearchBirdseyeInFlight happens to use your specified howMany as the basis for the internal limit, and then apply the blocked flight removal, so that’s why you got 990.

Oh I was expecting to see the next_offset = 990 or 1000 if it actually had more data (before removing the blocked flights). Instead the next_offset is -1. What is your recommendation for iterating over all the results in this case? Do I just run another query with offset = 990, or 1000 and then see if there is more?

–Brice

If you are iterating over all flights with no other major filtering, then your use-case is probably not well-suited for FlightXML. You need to place more restrictions on what you’re attempting to search by.

If you truly need to monitor traffic on all flights worldwide at any time, then a solution like FlightAware Firehose might be more appropriate for you. Contact Max using the link at the bottom of flightaware.com/commercial/data/adsb/

Thanks for your help! I found the firehose api while searching the FlightAware website and I have already reached out to Max earlier today because I figured that was probably a more suitable method for attaining the data.

One complication I thought of while coding the solution below is… what guarantees that the next_offset is even relevant by time the next query is made, seeing that the data is changing while the queries are being made. Seems like the firehose solution is the best way to go.



api.service.SetMaximumResultSize(10000)
offset = 0
howMany = 90
while True:
    try:
        result = api.service.SearchBirdseyeInFlight(query='{true inAir}', howMany=howMany, offset=offset)
    except:
        break
    else:
        show(result)
        offset += howMany


–Brice