Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么QPX查询结果与Google Flights中的不同?_Python_Google Api_Google Qpx Express Api - Fatal编程技术网

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

Python 为什么QPX查询结果与Google Flights中的不同?,python,google-api,google-qpx-express-api,Python,Google Api,Google Qpx Express Api,我刚开始尝试谷歌的QPXExpress API,一种机票搜索API。然而,如此多的查询结果与我在Google Flights中得到的结果不同 我不确定我错过了什么,但至少 例如,以下是我在Python中尝试的内容: import json import requests url = "https://www.googleapis.com/qpxExpress/v1/trips/search?key=myAPIKey" headers = { "content-type": "appli

我刚开始尝试谷歌的QPXExpress API,一种机票搜索API。然而,如此多的查询结果与我在Google Flights中得到的结果不同

我不确定我错过了什么,但至少

例如,以下是我在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"])
这应该是最便宜的机票。然而,这似乎不同于你可以在网上从谷歌航班上得到的。我的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返回最便宜的航班为239美元,而谷歌航班返回241美元

我注意到QPXAPI和Ita软件矩阵(由谷歌提供)给出了相同的结果,不包括很多像瑞安航空这样的公司。谷歌航班包括这些结果

我询问了谷歌的支持

答案是:

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

问谷歌是否考虑将这些航班添加到他们的API中,答案是:

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