本文介绍了没有目的地的 Google Flights/QPX 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我关注了这个使用 Google Flights/QPX API 发布以发送航班请求,并且在提供乘客数量的情况下一切正常、始发机场、目的地机场和出发日期.

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.

我想检索给定乘客数量、出发机场和出发日期的所有可能目的地,从而排除目的地机场(请参阅所需的输出 此处).但是,这是不可能的,因为 API 需要一个目的地.解决此问题的最佳方法是什么:

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:

  • 同时向不同的目的地发送多个请求?这会很慢而且很贵(0.03 美元/请求).
  • 其他建议

以下是我的代码:

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();});
});

我错过了什么?有什么建议?是否有不同的 API 可以做到这一点?

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

推荐答案

大多数情况下,您都无法避免在 QPX API 中进行多个查询.如果您想直接使用 Google 提供的 ITA Software 提供的业务"版本,则可能有一个解决方案.它被称为机票购物系统".这也被航空公司和大型旅行社使用,但最有可能是在小预算范围内.

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.

然而,一个想法可能是SkyScanner for Business.我不确定他们的条件.但是,他们根据缓存的航班提供特殊"查询.所以也许一个缺点是它不是实时数据,每天只刷新一次.您可能需要检查一下限制.

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.

可能的查询包括:点击

这篇关于没有目的地的 Google Flights/QPX 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:56