Duffel Flights
Search, book, and manage flights across 300+ airlines via the Duffel API.
Setup
Set DUFFEL_TOKEN env var with your Duffel API access token.
Get one at https://app.duffel.com → Developers → Access Tokens.
Test tokens (prefix duffel_test_) use sandbox data with unlimited balance.
Commands
Search flights
CODEBLOCK0
Options: --cabin economy|premium_economy|business|first, --nonstop, --adults N, --children N, --infants N, --sort price|duration, --max-results N, INLINECODE9
Results are numbered. Use the number with other commands.
View offer details
python scripts/duffel.py offer 3
Shows segments, baggage, fare conditions (refund/change), available extras.
Book a flight
python scripts/duffel.py book 3 --pax "RIBEIRO/FABIO MR 1977-01-31 fabio@ribei.ro +13059159687 BR m"
Pax format:
LAST/FIRST TITLE DOB EMAIL PHONE NATIONALITY GENDER
- - TITLE: MR, MRS, MS, MISS, DR
- GENDER: m or f
- Multiple passengers: repeat
--pax "..." for each
Payment uses Duffel account balance. Top up at https://app.duffel.com.
Check order status
CODEBLOCK3
Cancel order
CODEBLOCK4
Seat map
CODEBLOCK5
Airport/city lookup
CODEBLOCK6
Typical workflow
- 1.
search → browse numbered results - INLINECODE13 → check details, baggage, conditions
- INLINECODE14 → get PNR
- INLINECODE15 → verify booking
- INLINECODE16 → if needed
Notes
- - Offers expire (usually ~20 min). Re-search if expired.
- Test mode: unlimited balance, bookings on "Duffel Airways" (fake airline).
- Production: real airlines, real tickets. Balance must be funded.
- All commands support
--json for raw API output. - Last search saved to
/tmp/duffel-last-search.json for index reference. - For API details, see
references/api-guide.md and references/booking-flow.md.
Duffel 航班
通过 Duffel API 搜索、预订和管理超过300家航空公司的航班。
设置
将 DUFFEL_TOKEN 环境变量设置为您的 Duffel API 访问令牌。
在 https://app.duffel.com → 开发者 → 访问令牌 处获取。
测试令牌(前缀 duffeltest)使用余额无限的沙盒数据。
命令
搜索航班
bash
python scripts/duffel.py search --from MIA --to LHR --date 2026-04-15
python scripts/duffel.py search --from MIA --to CDG --date 2026-03-15 --return-date 2026-03-22 --cabin business
python scripts/duffel.py search --from JFK --to LAX --date 2026-05-01 --nonstop --adults 2
选项:--cabin economy|premium_economy|business|first、--nonstop、--adults N、--children N、--infants N、--sort price|duration、--max-results N、--json
结果带有编号。在其他命令中使用编号。
查看报价详情
bash
python scripts/duffel.py offer 3
显示航段、行李、票价条件(退改签)、可用附加服务。
预订航班
bash
python scripts/duffel.py book 3 --pax RIBEIRO/FABIO MR 1977-01-31 fabio@ribei.ro +13059159687 BR m
乘客格式:姓氏/名字 称谓 出生日期 邮箱 电话 国籍 性别
- - 称谓:MR、MRS、MS、MISS、DR
- 性别:m 或 f
- 多名乘客:为每位乘客重复 --pax ...
支付使用 Duffel 账户余额。在 https://app.duffel.com 充值。
查看订单状态
bash
python scripts/duffel.py order ord_0000XXXXX
取消订单
bash
python scripts/duffel.py cancel ord_0000XXXXX # 报价(显示退款金额)
python scripts/duffel.py cancel ord_0000XXXXX --confirm # 执行取消
座位图
bash
python scripts/duffel.py seatmap 3
机场/城市查询
bash
python scripts/duffel.py places new york
典型工作流程
- 1. search → 浏览编号结果
- offer N → 查看详情、行李、条件
- book N --pax ... → 获取 PNR
- order → 验证预订
- cancel → 如需取消
注意事项
- - 报价会过期(通常约20分钟)。过期后需重新搜索。
- 测试模式:余额无限,预订在Duffel Airways(虚拟航空公司)。
- 生产环境:真实航空公司,真实机票。必须充值余额。
- 所有命令支持 --json 获取原始 API 输出。
- 上次搜索结果保存至 /tmp/duffel-last-search.json 供索引参考。
- 有关 API 详情,请参阅 references/api-guide.md 和 references/booking-flow.md。