AngularJS callback function ignored by FlightXML API

When using AngularJS $http.jsonp(url) to access the FlightXML API, AngularJS adds the argument &jsonp_callback=angular.callbacks._0 to the url. Unfortunately, this callback function is ignored by the FlightXML API. The default callback function ‘FlightXmlCallback’ is added to the JSONP response instead. This breaks the AngularJS $http mechanism. Could you fix the API to accept ‘angular.callbacks.x_N’ as a callback function?

Also tried a JSON request using $http.get but can’t get it to work. When I put the credentials in the url I get a 401 error. When I add the Authorization header, I get this error:

Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.

The jsonp_callback parameter does work, but not with callback names that include periods. This is a common issue across multiple providers:

I’ll open an issue to add support, but I can’t give you any timeline for adoption. JSONP is not really a standard as such, so there is variations on how it is implemented.

A plain JSON request will fail from a browser because it is a cross-domain request.

I would also recommend proxying requests to flightxml through your server, if you can. This has the advantages of (1) not exposing your FXML credentials to users, (2) allowing you to use plain JSON requests, and (3) allowing you to cache results on your server and therefore reduce the cost of using FXML.

Thanks for your replies and good suggestion jsulak. I see the advantages of a server-side proxy and we decided to make a proxy on our backend server.

I must say I find the FlightXML quite slow. We used the FlightStats API before we went to FlightAware. With FlightXML, a request takes about 1.8s. With FlightStats the results came back almost immediately.

Do you have example queries that are slow? … 1454281199

Last test: 3 sec

The AirlineFlightSchedules function is a very computationally intensive query for us, particularly if there are a large number of matching flights or the timespan is large. Longer response times for that function are not always avoidable.

Switched to FlightStats. Delivers results withing milliseconds.