3

I followed this post to send flight requests using Google Flights/QPX API and it all works provided # of passengers, an origin airport, a destination airport and departure date.

I want to retrieve all possible destinations given # of passengers, an origin airport and departure date, thus leaving out destination airport (see desired output here). However, that is not possible because the API requires a destination. What is the best way to go about this:

  • send multiple requests for different destinations at the same time? That would be slow and expensive ($0.03/request).
  • Other suggestions

Following is my code:

HTML:

<!DOCTYPE html>
<html>
    <head>
        <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
        <script src="test.js"></script>
    </head>
    <body>
            <input type="submit" id="submit" value="Submit">
    </body>
</html>

JS:

var sendRequest = function(){
    var FlightRequest = {
      "request": {
        "passengers": {
          "adultCount": 1
        },
        "slice": [
          {
            "origin": "JFK",
            "date": "2015-05-01"
          }
        ],
        "maxPrice": "USD500",
        "refundable": false
      }
    };

    $.ajax({
     type: "POST",
     url: "https://www.googleapis.com/qpxExpress/v1/trips/search?key=YOUR_API_KEY", 
     contentType: 'application/json', 
     dataType: 'json',
     data: JSON.stringify(FlightRequest),
     success: function (data) {
      console.log(JSON.stringify(data));
    },
      error: function(){
       alert("Access to Google QPX Failed.");
     }
    });
}

$(document).ready(function(){
    $("#submit").click(function(){sendRequest();});
});

What am I missing? Any suggestions? Is there a different API that can do this?

neoJato
  • 121
  • 1
  • 5
xited
  • 877
  • 1
  • 10
  • 19
  • I am trying to achieve the same thing. Did you ever find a solution to this problem? :) – Saud Sep 29 '16 at 11:53
  • Not, yet. it seems the only way to do it is to make the call, and save the results for subsequent requests, then refresh the data as necessary. calls to the api are fairly expensive. All eyes and ears to new solutions. – xited Sep 29 '16 at 17:16

1 Answers1

2

Most likley you cant avoid having multiple queries within the QPX API. There might be a solution if you want to use the "business"-version which is offered by ITA Software by Google directly. It's called "Airfare Shopping System". This is also used by airlines and bigger travel agencies but is most-likely in a small-budget range.

However an idea might be SkyScanner for Business. Iam not sure about their conditions. However they offer "special" queries based on their cached flights. So maybe a drawback is that its not real-time data and only refreshed once a day. You might have to check the limitations for that.

Possible queries include following: Click

s1x
  • 574
  • 4
  • 15