2016-12-03 78 views
4

我剛開始嘗試使用Google的QPX Express API,一種機票搜索API。但是,如此多的查詢結果與我在Google Flights中獲得的結果有所不同。爲什麼QPX查詢結果與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 
     } 
    } 

我在同一個輸入到谷歌輸入航班,但結果卻是不同的。

爲什麼他們返回不同的結果?我在這裏錯過了什麼?


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

回答

3

我注意到QPX API和Ita Software Matrix(Google)給出了相同的結果,不包括很多像Ryanair這樣的公司。 Google航班包含這些結果。

我向Google支持部門詢問了這件事。

答案是:

QPX快遞API和Matrix只包括與ATPCO申請的票價有一些小的運營商和低成本航空公司不提交的。」

問谷歌,如果他們認爲這些航班添加到他們的API的答案是:

航空公司確定他們想要參與其中的分銷渠道如果這些航空公司的所有人都將向ATPCO提交文件,那麼我們肯定會對此感興趣。

相關問題