I need to retrieve faFlightId for particular flight.
Firstly, I am checking what flights are scheduled by:
https://username:token@flightxml.flightaware.com/json/FlightXML2/AirlineFlightSchedules?startDate=1528212881&endDate=1528299281&howMany=7&offset=0&origin=SVO&destination=LHR
Gives me the following:
{
“ident”: “AFL2578”,
“actual_ident”: “”,
“departuretime”: 1528268400,
“arrivaltime”: 1528283100,
“origin”: “UUEE”,
“destination”: “EGLL”,
“aircrafttype”: “A333”,
“meal_service”: “Economy: Lunch”,
“seats_cabin_first”: 0,
“seats_cabin_business”: 0,
“seats_cabin_coach”: 268
}
then I am executing GetFlightID to get faFlightId:
http://username:token@flightxml.flightaware.com/json/FlightXML2/GetFlightID?ident=AFL2578&departureTime=1528268400
I am getting
{
“error”: “flight not found”
}
why???
The flight schedule is based on information the airline published months in advance, and they occasionally change their schedules.
The timestamp you are requesting is 1528268400, which is Wed Jun 06 07:00:00 GMT 2018
The flight on June 6 is viewable on our website and is filed to depart at 2018-06-06 07:10:00 (differs by 10 minutes):
https://flightaware.com/live/flight/AFL2578/history/20180606/0710Z/UUEE/EGLL
The GetFlightID function only works when the filed departure time (or actual departuretime) differs by less than a minute.
When GetFlightID is not able to find a match, then you may have to try FlightInfoEx with just the ident (no timestamp or faFlightID) and iterate through the results to locate a flight that most closely matches the flight you are looking for.
That makes sense, i thought faFlightID is a static value.
if it is a dynamic variable, how do you recommend handle push notifications which are POSTed from your service to our webserver endpoint (https://flightaware.com/commercial/flightxml/send.rvt)?
Lets say user created an alert 15 days before actual flight and we store his alert with primary field faAlertId. When POST notification comes to our endpoint, we want to query users which have the same faAlertId from the notification and send them Push notification. If faFlightId can differ time-to-time, our method does not work. So we need to handle FlightAware notifications by ident
and departureTime
values and try to find the closest matches ?
In general, the faFlightID is generated by FlightAware at most 48 hours prior to departure, though it can be much less if we don’t receive data from the operator to indicate that the flight is still scheduled.
If a flight is further in the future, you can still use SetAlert to create an alert on a flight based on its ident (or airline + flight number) instead of faFlightID. When alerts start occurring for that flight, they will always have a faFlightID assigned by that point.