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": []
    }
  }
}