API Hop

文件目錄

API Hop 文件

Google Flights 介面參考

搜尋 Google Flights 航班、機場建議與機票優惠。

並行上限

AI 與 Data 分別共用帳戶層級的並行名額,預設 5 AI / 2 Data,訂閱方案可調整上限。介面個別設定仍受類別總上限約束。達到任一上限回傳 HTTP 429;非同步任務執行結束前占用名額。

GET /v1/google-flights/search
預設並行上限: 2
GET /v1/google-flights/autocomplete
預設並行上限: 2
GET /v1/google-flights/deals
預設並行上限: 2

搜尋 Google Flights 航班、機場建議與機票優惠。

驗證與計費

預設每次成功請求 $0.0003(300 credits)。 使用 API Hop API Key;可用性取決於已啟用閘道與金鑰權限。成功請求價格以目前目錄與帳戶為準,帳戶專屬價格優先。成功的空結果也會計費,失敗會釋放預留額度。逾時為 60 秒,不自動重試或分頁,結算失敗不會重複呼叫上游。

http
Authorization: Bearer YOUR_API_KEY

Google Flights: 搜尋航班

GET https://api.apihop.ai/v1/google-flights/search

請求參數

欄位類型限制範例
departure_idstring出發機場或城市識別碼 (departure_id); departure_id: optional; ^(?:[A-Z]{3}|/[mg]/[A-Za-z0-9_]+)(?:,(?:[A-Z]{3}|/[mg]/[A-Za-z0-9_]+))*$JFK
arrival_idstring目的地機場、城市或區域識別碼 (arrival_id); arrival_id: optional; ^(?:[A-Z]{3}|/[mg]/[A-Za-z0-9_]+)(?:,(?:[A-Z]{3}|/[mg]/[A-Za-z0-9_]+))*$LAX
outbound_datestring旅行日期(YYYY-MM-DD)或介面支援的日期範圍 (outbound_date); outbound_date: optional; ^[0-9]{4}-[0-9]{2}-[0-9]{2}$2026-12-12
return_datestring旅行日期(YYYY-MM-DD)或介面支援的日期範圍 (return_date); return_date: optional; ^[0-9]{4}-[0-9]{2}-[0-9]{2}$-
adultsinteger成人人數 (adults); adults: optional; min: 1; max: 91
childreninteger兒童人數 (children); children: optional; min: 0; max: 80
infants_in_seatinteger嬰兒人數 (infants_in_seat); infants_in_seat: optional; min: 0; max: 80
infants_on_lapinteger懷抱嬰兒人數 (infants_on_lap); infants_on_lap: optional; min: 0; max: 80
travel_classstring艙等 (travel_class); travel_class: optional; economy, premium_economy, business, firsteconomy
sort_bystring排序; sort_by: optional; top_flights, price, departure_time, arrival_time, duration, emissionstop_flights
stopsinteger航班或目的地篩選 (stops); stops: optional; min: 0; max: 30
include_airlinesstring航空公司或聯盟篩選 (include_airlines); include_airlines: optional; UTF-8 bytes: 1000; ^(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD)(?:,(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD))*$-
exclude_airlinesstring航空公司或聯盟篩選 (exclude_airlines); exclude_airlines: optional; UTF-8 bytes: 1000; ^(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD)(?:,(?:[A-Z][A-Z0-9]|[0-9][A-Z]|STAR_ALLIANCE|SKYTEAM|ONEWORLD))*$-
bagsinteger航班或目的地篩選 (bags); bags: optional; min: 0; max: 90
max_priceinteger最高價格 (max_price); max_price: optional; min: 1; max: 21474836471
outbound_timesstring航班或目的地篩選 (outbound_times); outbound_times: optional; UTF-8 bytes: 11; ^(?:[0-9]|1[0-9]|2[0-3])(?:,(?:[0-9]|1[0-9]|2[0-3])){1,3}$-
return_timesstring航班或目的地篩選 (return_times); return_times: optional; UTF-8 bytes: 11; ^(?:[0-9]|1[0-9]|2[0-3])(?:,(?:[0-9]|1[0-9]|2[0-3])){1,3}$-
emissionsinteger航班或目的地篩選 (emissions); emissions: optional; 11
exclude_connsstring航班或目的地篩選 (exclude_conns); exclude_conns: optional; UTF-8 bytes: 1000; ^[A-Z]{3}(?:,[A-Z]{3})*$-
max_durationinteger旅行時長篩選 (max_duration); max_duration: optional; min: 1; max: 21474836471
show_hiddenboolean航班或目的地篩選 (show_hidden); show_hidden: optionaltrue
exclude_basicboolean航班或目的地篩選 (exclude_basic); exclude_basic: optionaltrue
typeinteger航班或目的地篩選 (type); type: optional; 1, 2, 31
multi_city_jsonstring行程 JSON (multi_city_json); multi_city_json: optional; UTF-8 bytes: 16384-
layover_durationstring旅行時長篩選 (layover_duration); layover_duration: optional; UTF-8 bytes: 21; ^[0-9]{1,10},[0-9]{1,10}$-
selected_flights_jsonstring行程 JSON (selected_flights_json); selected_flights_json: optional; UTF-8 bytes: 16384-
departure_tokenstring從最新回應複製的選擇權杖 (departure_token); departure_token: optional; UTF-8 bytes: 32768-
booking_tokenstring從最新回應複製的選擇權杖 (booking_token); booking_token: optional; UTF-8 bytes: 32768-
deep_searchboolean航班或目的地篩選 (deep_search); deep_search: optionaltrue
currencystring貨幣代碼 (currency); currency: optional; ALL, DZD, ARS, AMD, AWG, AUD, AZN, BSD, BHD, BYN, BMD, BAM, BRL, GBP, BGN, XPF, CAD, CLP, CNY, COP, CRC, CUP, CZK, DKK, DOP, EGP, EUR, GEL, HKD, HUF, ISK, INR, IDR, IRR, ILS, JMD, JPY, JOD, KZT, KWD, LBP, MKD, MYR, MXN, MDL, MAD, TWD, NZD, NOK, OMR, PKR, PAB, PEN, PHP, PLN, QAR, RON, RUB, SAR, RSD, SGD, ZAR, KRW, SEK, CHF, THB, TRY, USD, UAH, AED, VND; ^[A-Z]{3}$USD
countrystring國家或站點代碼 (country); country: optional; ^[A-Za-z]{2}$-
languagestring語言; language: optional-
limitinteger結果上限; limit: optional; min: 1; max: 1001
devicestring裝置; device: optional; desktop, mobile, tabletdesktop
zero_traceboolean不封存回應產物; zero_trace: optionaltrue

驗證規則

僅接受查詢參數,不接受本文。拒絕未知、重複、空白或無效值。僅支援 JSON 回應,不自動分頁或重試。規則中的 AND 表示同時提供,OR 表示任一,XOR 表示二選一,NOT 表示不得提供,=> 表示需要。

  • GET query only; body = null; response = JSON; html, output, json_restrictor, no_cache: NOT supported
  • string: UTF-8 bytes <= maxLength (default 8192); boolean = true OR false; integer: safe integer
  • language: /^[A-Za-z]{2,3}(?:[-_][A-Za-z]{2,4})?$/
  • adults (default 1) + children + infants_in_seat + infants_on_lap <= 9; infants_on_lap <= adults
  • bags <= adults + children + infants_in_seat
  • departure_id AND arrival_id AND outbound_date: required unless selected_flights_json OR multi_city_json supplies the itinerary
  • Dates: valid YYYY-MM-DD; return_date >= outbound_date; type = 1 requires return_date; type = 2 excludes return_date; type = 3 requires multi_city_json
  • multi_city_json: JSON array of 2..5 ordered legs with departure_id, arrival_id, date and optional times
  • selected_flights_json: native JSON object of outbound flight segments and optional return segments; each segment has flight_number, departure_id, arrival_id, date; the data service validates the segment structure
  • NOT (departure_token AND booking_token); tokens require original itinerary parameters
  • outbound_times, return_times: 2 OR 4 hours (0..23); layover_duration: ordered min,max minutes
  • exclude_basic = true => country = us (default) AND travel_class = economy (default)
  • Tokens: copy the exact token from a fresh response; do not invent or reuse expired tokens; each page or token lookup is a separate billable successful request

範例

bash
curl --get "https://api.apihop.ai/v1/google-flights/search" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --data-urlencode "arrival_id=LAX" \
  --data-urlencode "currency=USD" \
  --data-urlencode "departure_id=JFK" \
  --data-urlencode "outbound_date=2026-12-12"

Google Flights: 查詢機場建議

GET https://api.apihop.ai/v1/google-flights/autocomplete

請求參數

欄位類型限制範例
querystring搜尋詞; query: REQUIREDNew York
countrystring國家或站點代碼 (country); country: optional; ^[A-Za-z]{2}$-
languagestring語言; language: optional-
limitinteger結果上限; limit: optional; min: 1; max: 1001
devicestring裝置; device: optional; desktop, mobile, tabletdesktop
zero_traceboolean不封存回應產物; zero_trace: optionaltrue
exclude_regionsboolean航班或目的地篩選 (exclude_regions); exclude_regions: optionaltrue

驗證規則

僅接受查詢參數,不接受本文。拒絕未知、重複、空白或無效值。僅支援 JSON 回應,不自動分頁或重試。規則中的 AND 表示同時提供,OR 表示任一,XOR 表示二選一,NOT 表示不得提供,=> 表示需要。

  • GET query only; body = null; response = JSON; html, output, json_restrictor, no_cache: NOT supported
  • string: UTF-8 bytes <= maxLength (default 8192); boolean = true OR false; integer: safe integer
  • language: /^[A-Za-z]{2,3}(?:[-_][A-Za-z]{2,4})?$/

範例

bash
curl --get "https://api.apihop.ai/v1/google-flights/autocomplete" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --data-urlencode "query=New York"

Google Flights: 查詢機票優惠

GET https://api.apihop.ai/v1/google-flights/deals

請求參數

欄位類型限制範例
querystring搜尋詞; query: optionalWeek long trip to a city with great food
departure_idstring出發機場或城市識別碼 (departure_id); departure_id: REQUIRED; ^(?:[A-Z]{3}&#124;/[mg]/[A-Za-z0-9_]+)(?:,(?:[A-Z]{3}&#124;/[mg]/[A-Za-z0-9_]+))*$JFK
adultsinteger成人人數 (adults); adults: optional; min: 1; max: 91
outbound_datestring旅行日期(YYYY-MM-DD)或介面支援的日期範圍 (outbound_date); outbound_date: optional; UTF-8 bytes: 21-
return_datestring旅行日期(YYYY-MM-DD)或介面支援的日期範圍 (return_date); return_date: optional; UTF-8 bytes: 21-
travel_durationinteger旅行時長篩選 (travel_duration); travel_duration: optional; min: 1; max: 31
trip_lengthstring旅行時長篩選 (trip_length); trip_length: optional; UTF-8 bytes: 21; ^[0-9]{1,10}(?:,[0-9]{1,10})?$-
childreninteger兒童人數 (children); children: optional; min: 0; max: 80
infants_in_seatinteger嬰兒人數 (infants_in_seat); infants_in_seat: optional; min: 0; max: 80
infants_on_lapinteger懷抱嬰兒人數 (infants_on_lap); infants_on_lap: optional; min: 0; max: 80
travel_classstring艙等 (travel_class); travel_class: optional; economy, premium_economy, business, firsteconomy
typeinteger航班或目的地篩選 (type); type: optional; 1, 21
stopsinteger航班或目的地篩選 (stops); stops: optional; min: 0; max: 30
include_airlinesstring航空公司或聯盟篩選 (include_airlines); include_airlines: optional; UTF-8 bytes: 1000; ^(?:[A-Z][A-Z0-9]&#124;[0-9][A-Z]&#124;STAR_ALLIANCE&#124;SKYTEAM&#124;ONEWORLD)(?:,(?:[A-Z][A-Z0-9]&#124;[0-9][A-Z]&#124;STAR_ALLIANCE&#124;SKYTEAM&#124;ONEWORLD))*$-
exclude_airlinesstring航空公司或聯盟篩選 (exclude_airlines); exclude_airlines: optional; UTF-8 bytes: 1000; ^(?:[A-Z][A-Z0-9]&#124;[0-9][A-Z]&#124;STAR_ALLIANCE&#124;SKYTEAM&#124;ONEWORLD)(?:,(?:[A-Z][A-Z0-9]&#124;[0-9][A-Z]&#124;STAR_ALLIANCE&#124;SKYTEAM&#124;ONEWORLD))*$-
max_priceinteger最高價格 (max_price); max_price: optional; min: 1; max: 21474836471
max_durationinteger旅行時長篩選 (max_duration); max_duration: optional; min: 1; max: 21474836471
currencystring貨幣代碼 (currency); currency: optional; ALL, DZD, ARS, AMD, AWG, AUD, AZN, BSD, BHD, BYN, BMD, BAM, BRL, GBP, BGN, XPF, CAD, CLP, CNY, COP, CRC, CUP, CZK, DKK, DOP, EGP, EUR, GEL, HKD, HUF, ISK, INR, IDR, IRR, ILS, JMD, JPY, JOD, KZT, KWD, LBP, MKD, MYR, MXN, MDL, MAD, TWD, NZD, NOK, OMR, PKR, PAB, PEN, PHP, PLN, QAR, RON, RUB, SAR, RSD, SGD, ZAR, KRW, SEK, CHF, THB, TRY, USD, UAH, AED, VND; ^[A-Z]{3}$ALL
countrystring國家或站點代碼 (country); country: optional; ^[A-Za-z]{2}$-
languagestring語言; language: optional-
limitinteger結果上限; limit: optional; min: 1; max: 10010
devicestring裝置; device: optional; desktop, mobile, tabletdesktop
zero_traceboolean不封存回應產物; zero_trace: optionaltrue

驗證規則

僅接受查詢參數,不接受本文。拒絕未知、重複、空白或無效值。僅支援 JSON 回應,不自動分頁或重試。規則中的 AND 表示同時提供,OR 表示任一,XOR 表示二選一,NOT 表示不得提供,=> 表示需要。

  • GET query only; body = null; response = JSON; html, output, json_restrictor, no_cache: NOT supported
  • string: UTF-8 bytes <= maxLength (default 8192); boolean = true OR false; integer: safe integer
  • language: /^[A-Za-z]{2,3}(?:[-_][A-Za-z]{2,4})?$/
  • adults (default 1) + children + infants_in_seat + infants_on_lap <= 9; infants_on_lap <= adults
  • outbound_date, return_date: valid YYYY-MM-DD or ordered YYYY-MM-DD,YYYY-MM-DD window; return dates cannot precede departure dates
  • type = 2 => NOT return_date; flexible return windows require flexible departure windows
  • travel_duration: flexible round-trip duration; cannot combine with exact dates
  • trip_length: positive days or ordered min,max; requires flexible departure dates; query => NOT travel_duration

範例

bash
curl --get "https://api.apihop.ai/v1/google-flights/deals" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --data-urlencode "departure_id=JFK" \
  --data-urlencode "limit=10" \
  --data-urlencode "query=Week long trip to a city with great food"

回應與錯誤

保留原生 JSON 與數字精確度。以下是空成功結果範例。HTTP 400 輸入無效;401 需驗證;402 餘額不足;403 無權限或未開放;405 方法不支援;429 限流;5xx 服務錯誤。請保留 X-Request-Id。

json
{
  "success": true,
  "request_id": "example-request",
  "data": {
    "format": "json",
    "content": {
      "results": []
    }
  }
}