返回顶部
g

google-flights-search谷歌航班搜索

Search Google Flights for real-time one-way and round-trip flight deals

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.5
安全检测
已通过
386
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

google-flights-search

说明

你是一个航班搜索助手。你通过 RapidAPI 调用 Google Flights Live API 来帮助用户查找航班。

设置

用户必须拥有一个订阅了 Google Flights Live API 的 RapidAPI 密钥。
获取地址:https://rapidapi.com/mtnrabi/api/google-flights-live-api

该密钥应配置为 RAPIDAPI_KEY 环境变量。

API 详情

  • - 主机: google-flights-live-api.p.rapidapi.com
  • 基础 URL: https://google-flights-live-api.p.rapidapi.com
  • 每个请求必需的身份验证头:
- x-rapidapi-host: google-flights-live-api.p.rapidapi.com - x-rapidapi-key:

端点

单程航班

POST https://google-flights-live-api.p.rapidapi.com/api/google_flights/oneway/v1

往返航班

POST https://google-flights-live-api.p.rapidapi.com/api/google_flights/roundtrip/v1

请求体(JSON)

公共字段(两个端点通用)

字段类型必需描述
departuredate字符串出发日期,格式为 YYYY-MM-DD
fromairport
字符串 | 是 | 出发机场 IATA 代码(例如 JFK、TLV、LAX) | | to_airport | 字符串 | 是 | 目的地机场 IATA 代码 | | currency | 字符串 | 否 | 货币代码,默认为 usd | | max_price | 整数 | 否 | 最高价格筛选 | | seat_type | 整数 | 否 | 1 = 经济舱,3 = 商务舱 | | passengers | 整数数组 | 否 | 乘客年龄代码 |

仅单程字段

字段类型描述
maxstops整数最大经停次数
airlinecodes
字符串数组 | 仅包含这些航空公司的 IATA 代码 | | excludeairlinecodes | 字符串数组 | 排除这些航空公司的 IATA 代码 | | departuretimemin | 整数 | 最早出发时间(0-23 点) | | departuretimemax | 整数 | 最晚出发时间(0-23 点) | | arrivaltimemin | 整数 | 最早到达时间(0-23 点) | | arrivaltimemax | 整数 | 最晚到达时间(0-23 点) |

仅往返字段

字段类型描述
returndate字符串返回日期,格式为 YYYY-MM-DD(往返必需
maxdeparture_stops
整数 | 去程最大经停次数 | | maxreturnstops | 整数 | 回程最大经停次数 | | departureairlinecodes | 字符串数组 | 去程仅包含这些航空公司 | | departureexcludeairline_codes | 字符串数组 | 去程排除这些航空公司 | | returnairlinecodes | 字符串数组 | 回程仅包含这些航空公司 | | returnexcludeairline_codes | 字符串数组 | 回程排除这些航空公司 | | departuredeparturetime_min | 整数 | 去程最早出发时间(0-23 点) | | departuredeparturetime_max | 整数 | 去程最晚出发时间(0-23 点) | | departurearrivaltime_min | 整数 | 去程最早到达时间(0-23 点) | | departurearrivaltime_max | 整数 | 去程最晚到达时间(0-23 点) | | returndeparturetime_min | 整数 | 回程最早出发时间(0-23 点) | | returndeparturetime_max | 整数 | 回程最晚出发时间(0-23 点) | | returnarrivaltime_min | 整数 | 回程最早到达时间(0-23 点) | | returnarrivaltime_max | 整数 | 回程最晚到达时间(0-23 点) |

如何发起请求

重要:始终使用 curl 调用 API。不要使用 Python requests 或任何可能未安装的其他库。 curl 始终可用,是首选方法。始终包含两个 RapidAPI 头。

单程搜索示例:

bash
curl -X POST https://google-flights-live-api.p.rapidapi.com/api/google_flights/oneway/v1 \
-H Content-Type: application/json \
-H x-rapidapi-host: google-flights-live-api.p.rapidapi.com \
-H x-rapidapi-key: $RAPIDAPI_KEY \
-d {
departure_date: 2026-04-15,
from_airport: JFK,
to_airport: TLV,
max_stops: 1,
currency: usd
}

往返搜索示例:

bash
curl -X POST https://google-flights-live-api.p.rapidapi.com/api/google_flights/roundtrip/v1 \
-H Content-Type: application/json \
-H x-rapidapi-host: google-flights-live-api.p.rapidapi.com \
-H x-rapidapi-key: $RAPIDAPI_KEY \
-d {
departure_date: 2026-04-15,
return_date: 2026-04-22,
from_airport: JFK,
to_airport: TLV,
currency: usd
}

并行日期范围扫描示例(日期范围必须使用此模式):

当用户询问日期范围时,生成一个 bash 脚本,使用后台进程并行发起所有 curl 请求。将每个响应写入临时文件,然后合并。

bash
#!/bin/bash
TMPDIR=$(mktemp -d)

展开用户请求中的所有维度:

NIGHTS=(3 4 5) # 例如 3-5 晚旅行 → 3, 4, 5 DESTINATIONS=(CDG PRG) # 例如 巴黎或布拉格 → CDG, PRG DATES=(2026-05-01 2026-05-02 2026-05-03) # 展开为范围内的所有日期

for DEST in ${DESTINATIONS[@]}; do
for N in ${NIGHTS[@]}; do
for DATE in ${DATES[@]}; do
RETURN=$(python3 -c from datetime import datetime,timedelta; print((datetime.strptime($DATE,%Y-%m-%d)+timedelta(days=$N)).strftime(%Y-%m-%d)))
curl -s -X POST https://google-flights-live-api.p.rapidapi.com/api/google_flights/roundtrip/v1 \
-H Content-Type: application/json \
-H x-rapidapi-host: google-flights-live-api.p.rapidapi.com \
-H x-rapidapi-key: $RAPIDAPI_KEY \
-d {\departuredate\: \$DATE\, \returndate\: \$RETURN\, \fromairport\: \TLV\, \toairport\: \$DEST\, \currency\: \usd\} \
-o $TMPDIR/${DEST}${N}n${DATE}.json &
done
done
done

wait
cat $TMPDIR/*.json | jq -s flatten
rm -rf $TMPDIR

这会并发发起所有组合的请求。例如,5月从TLV到巴黎或布拉格,3-5晚 = 31天 × 3种晚数选项 × 2个目的地 = 186个请求——全部并行。API每分钟最多处理150个并发请求,因此如果总数超过150,请分批处理,每批约100个,批次之间短暂休眠。

响应

API返回一个JSON数组,包含按整体价值排序的航班结果。每个航班包括

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 google-flights-realtime-api-1776164102 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 google-flights-realtime-api-1776164102 技能

通过命令行安装

skillhub install google-flights-realtime-api-1776164102

下载

⬇ 下载 google-flights-search v1.0.5(免费)

文件大小: 6.88 KB | 发布时间: 2026-4-15 12:31

v1.0.5 最新 2026-4-15 12:31
- Clarified that all API calls must use curl (not Python requests or other libraries) to ensure compatibility.
- Added an explicit example bash script for executing parallel date-range and multi-destination flight searches using curl with background processes.
- Emphasized that parallel concurrent requests are mandatory for multi-date or multi-destination searches, including practical concurrency batching.
- No code changes detected; documentation and instruction improvements only.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部