使用场景

用 Google Flights 数据跟踪航线机票价格

以 JSON 获取某条航线和日期的航班选项:航空公司、时间、经停、时长和价格。定时运行即可跟踪票价走势,及时发现降价。

预付费,无订阅REST 或 MCP一个密钥搞定模型、数据和智能体
Google Flightslovelyjsonitems[0]"route": "LAX-JFK""airline": "Delta""departure": "2026-11-04 08:15""stops": 0"duration": "5h 20m""price": "289"

航线票价每天都在波动,靠手动查询意味着每天早上打开同一个搜索,还得指望自己记得上周的数字。如果你在管理差旅、做特价提醒,或者规划自己的行程,需要的是价格历史,而不是某一时刻的快照。Lovely Router 替你搜索 Google Flights。发送航线和日期,以 JSON 返回航班选项,按搜索次数从预付费余额中计费。用一个 API 密钥,就能从定时任务、笔记本或 AI 智能体中调用。

交给你的 AI 智能体

把这段提示词复制到 Claude Code、Cursor、Codex 或任何编程智能体中。它会告诉智能体文档在哪里,以及如何使用你的 API 密钥。

用 Google Flights 数据跟踪航线机票价格. Use the Lovely Router data tools: each returns JSON and is billed per result.

- Docs (read first): https://lovelyrouter.com/docs/tools/find.md and https://lovelyrouter.com/docs/tools/run.md
- Plan first: POST https://lovelyrouter.com/v1/tools/suggest with `{"task": "<my task in plain words>"}` (free). It returns the tools to run in order, each with an example `input`, the `input_required` fields, an estimated cost and a ready-made `run` request. Replace the example values with my task's; if a field is unclear, read the tool with GET https://lovelyrouter.com/v1/tools/<id>. To browse instead, POST https://lovelyrouter.com/v1/tools/discover searches the catalog.
- Show me the plan and its estimated cost (`total_est_cost_usd`) before running anything large.
- Run: POST https://lovelyrouter.com/v1/tools/<id>/run with `{"input": {...}, "max_results": N}`. A 200 has the finished run with `items`; a 202 means it is still running, so poll the `poll` path until `status` is `succeeded`, `failed`, `timed_out` or `stopped`.
- Only delivered results are billed. Keep max_results small on the first run, check the output, then scale up.
- If you support MCP, connect https://lovelyrouter.com/mcp instead (Streamable HTTP, same key; https://lovelyrouter.com/docs/tools/mcp.md) and use suggest_tools, get_tool and run_tool.
- Auth: read my API key from the LOVELY_API_KEY environment variable and send it as `Authorization: Bearer $LOVELY_API_KEY`. Never print or commit the key. If it is not set, ask me to create one at https://lovelyrouter.com/app/keys.
- Billing is prepaid: every call is charged to my balance, so test with a small request before running anything large.
- Every docs page is plain Markdown; the full index is https://lovelyrouter.com/llms.txt.

My task: <the inputs (links, keywords or accounts) and how many results you need>
01

工作原理

010203
  1. 列出航线和日期

    把每次搜索写成出发地和目的地的机场代码(IATA)加出发日期,往返行程再加返程日期。单程则不要填返程日期。

  2. 运行工具

    把搜索连同 max_results 发送到 POST /v1/tools/google-flights/run。运行会从你的余额中预留它的最高费用,并以 JSON 返回航班选项。

  3. 记录最低票价

    按航线和日期保存最便宜的选项,并附上时间戳。与之前的运行对比,价格低于目标时发出提醒。

02

一次请求获取机票价格

搜索 Google Flights在 searches 中接受一组搜索。一次搜索就是一组航线和日期,一次运行最多覆盖 50 次搜索:

curl https://lovelyrouter.com/v1/tools/google-flights/run \
  -H "Authorization: Bearer $LOVELY_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "input": {
      "searches": [{"origin": "LAX", "destination": "JFK", "departureDate": "2026-11-04", "returnDate": "2026-11-09"}]
    },
    "max_results": 1
  }'

运行超过 60 秒仍未结束时会返回 202;轮询方法见运行工具。可选参数可以缩小搜索范围:adults、currency、maxStops、airlines 和 cabinClass。

03

每次搜索返回什么

字段组你能获得的内容
航空公司每个航班选项的航空公司
时间起飞和到达时间
经停经停次数
时长总旅行时间
价格票价,使用你指定的币种

你在 currency 中传入的币种代码会用于返回的价格。没有传入有效代码时,价格以 USD 返回。

04

实用配方

记录单条航线的每日票价。

每天早上运行同一个搜索,把最低价写入表格。三周之后,你就能看出临近出发日期时票价是涨还是跌。

灵活日期的特价提醒。

在一次运行中发送同一航线、相隔一周的多个出发日期,选出最便宜的一天,价格低于目标时给自己发消息。

直飞与经停对比。

用不同的 maxStops 把同一条航线运行两次,看看直飞比一次经停贵多少。

为团体出行报价。

把 adults 设为团队人数,并用 airlines 筛选对比几家航空公司,让差旅团队拿到一张可用于报价的表。

对比舱位。

用不同的 cabinClass 搜索相同日期,向主管展示团队最常飞的航线升舱要多花多少钱。

更想直接用自然语言提问?连接 MCP 服务器,然后对 Claude Code 或 Cursor 说:"搜索 11 月每个周五从 LAX 到 JFK、周二返回的航班,给我每周最便宜的选项。把 max_results 设为 5。"

06

费用说明

按搜索付费:启动运行时会预留它的最高费用,即每次调用费加上每次搜索的费用乘以 max_results,结束后按实际返回的结果结算,预留的剩余部分退回你的余额。失败或超时的运行只为已交付的搜索付费,在开始时就被拒绝的运行不收费。

每天跟踪 10 条航线,就按每天 10 次搜索计费。没有订阅,也没有每月最低消费:最低充值 $5,工具和模型共用一个余额。上方卡片显示的是当前价格;价格页面列出了所有工具。

07

常见问题

?
怎么搜索单程航班?+

搜索中不要填 returnDate。往返行程则需要填写。

机场和日期使用什么格式?+

机场使用 IATA 代码,例如 LAX 和 JFK。日期格式为 YYYY-MM-DD。

能获取欧元价格吗?+

在 currency 中传入三位字母代码,例如 EUR,返回的价格就会使用该币种。格式不正确的值会回退为 USD。

一次运行最多能处理多少次搜索?+

每次运行最多 50 次搜索。关注列表更长时,可以启动多次运行。

能按航空公司或经停次数筛选吗?+

可以。airlines 接受航空公司 IATA 代码或联盟名称,maxStops 设置最多经停次数。另外还有 cabinClass 和 adults。

需要订阅吗?+

不需要。你向预付费余额充值,每次运行从中扣费。失败的运行只为已交付的结果付费,不会自动续费。

想规划的不只是机票?请看旅行与房地产数据和其余的工具目录。

一个预付费密钥,搞定模型、数据和智能体

无需订阅。充值后按需使用,每笔费用都能在日志中查看。