为什么QPX查询结果与Google Flights中的结果不同?

时间:2016-12-03 12:21:54

标签: python google-api google-qpx-express-api

我刚刚开始尝试使用Google的QPX Express API,一种机票搜索API。但是,如此多的查询结果与我在Google Flights中获得的结果不同。

我不确定我错过了什么,但至少it should return the same results since Google Flights use the API internally

例如,这是我在Python中尝试的内容:

import json
import requests

url = "https://www.googleapis.com/qpxExpress/v1/trips/search?key=myAPIKey"
headers = {
    "content-type": "application/json"
}
with open("sample.json") as fp:
    data = json.load(fp)

r = requests.post(url, data=json.dumps(data), headers=headers)

print(r.json()["trip"]["tripOption"][0]["pricing"][0]["saleTotal"])

这应该返回最便宜的机票。但是,这似乎与您在网上从Google Flights上获得的不同。我的JSON文件应该倒入请求的主体中,如下所示:

    {
        "request": {
            "passengers": {
                "adultCount": 1,
                "childCount": 0,
                "infantInLapCount": 0,
                "infantInSeatCount": 0,
                "seniorCount": 0
            },
            "slice": [
                {
                    "origin": "PEK",
                    "destination": "MIL",
                    "date": "2017-01-14",
                    "maxStops": 1
                }
            ],
            "maxPrice": "USD500",
            "saleCountry": "US",
            "refundable": false,
            "solutions": 500
        }
    }

我在Google Flights中输入了相同的输入,但效果不同。

为什么他们会返回不同的结果?我在这里缺少什么?

截至目前,QPX将最便宜的航班返还为239USD,而Google Flights返回241USD。

1 个答案:

答案 0 :(得分:3)

我注意到QPX API和Ita Software Matrix(由Google提供)给出了相同的结果,不包括像Ryanair这样的很多公司。 Google航班包含这些结果。

我向谷歌支持部门询问了这件事。

答案是:

" QPX Express API和Matrix仅包含向ATPCO提交的票价。有许多小型运营商和低成本运营商没有提交。 "

询问Google是否考虑将这些航班添加到其API中,答案是:

" 航空公司决定他们想要参与哪个分销渠道。如果这些航空公司中的任何一家都向ATPCO提交申请,那么我们肯定会感兴趣。 "