適用旅行社與 OTA 的機票預訂 API
透過單一 REST API,搜尋、報價並預訂來自 GDS、NDC 與廉價航空來源的機票。供應商允許時可先保留票價、稍後付款,隨即出票;航空公司允許時可取消或退票。先申請免費的 Sandbox 金鑰;旅行社通過核准後即可使用 Live 金鑰。
文件僅提供英文版本。
- Base URL
https://api.fx-port.com/api/v1- 端點
- 16
- 格式
- 採用 HTTPS 的 JSON 格式,並提供 OpenAPI 3.1 檔案
- 程式碼範例
- 9 種語言
逐一呼叫看機票 API
看著請求被建立並送出,再看回應送達。這些流程取材自真實情境,從尋找票價到取消與退款,每個請求與回應都是文件中的範例,本頁不會呼叫 API。主控台下方以文字列出相同的流程。每個請求都是一條 cURL 指令,其程式碼分頁提供9 種語言。
2 個請求:查詢機場, 搜尋機票。
示範流程:內容主體取自文件中的範例,日期已順延以確保晚於今天,時間僅供示意。本頁不會送出任何請求。
查詢機場,再搜尋票價
先從不需要金鑰的機場查詢開始,再搜尋單程航線。回應會依供應商分組方案,並為每家供應商提供各自的 searchId,報價時需要帶入。主控台顯示的是截短的副本:實際回應大得多,因此請傳送 Accept-Encoding: gzip(curl 加上 --compressed 會自動處理)。
查詢機場
GET /flights/airports不需要金鑰。傳入使用者輸入的文字,並以所選紀錄的ap代碼作為出發地或目的地。請求 GET /flights/airports curl 'https://api.fx-port.com/api/v1/flights/airports?query=ALG&locale=en'回應 200 OK · 140 ms · 2.7 KB 200 OK Content-Type: application/json [ { "id": "ALG", "displayname": "Houari Boumediene, Algiers, Algeria, (ALG)", "loctype": "ap", "cid": 3, "rid": 480, "ctid": 10465, "lat": 36.6985, "lng": 3.20672, "cc": "DZ", "country": "Algeria", "rc": "AL", "cityname": "Algiers, Algeria", "timezone": "Africa/Algiers", "utc": "+01:00", "airportname": "Houari Boumediene", "ap": "ALG", "apicode": "ALG", "box_maxX": 3.26672, "box_maxY": 36.7335, "box_minX": 3.1467199999999997, "box_minY": 36.663500000000006, "cityonly": "Algiers", // ... // ... 1 more "entityKey": "place:Houari_Boumediene_Airport", "indexId": "176626", "isMetroOnly": false, "kayakId": "ALG", "kayakType": "ap", "locationname": "Algiers, Algeria", "name": "Houari Boumediene", "objectID": "P189646", "placeID": "176626", "ptid": "AALG", "region": "Algiers", "searchFormPrimary": "ALG", "searchFormSecondary": "Algiers, Algeria", "secondary": "Algiers, Algeria", "shortdisplayname": "Algiers, Algeria (ALG)", "smartyDisplay": "Houari Boumediene, Algiers, Algeria, (ALG)" }, { "id": "AHO", "displayname": "Alghero-Fertilia, Alghero, Sardinia, Italy, (AHO)", "loctype": "ap", "cid": 118, "rid": 1673, "ctid": 32049, "lat": 40.63213, "lng": 8.29077, "cc": "IT", "country": "Italy", "rc": "SA", "cityname": "Alghero, Sardinia, Italy", "timezone": "Europe/Rome", // ... 27 more } ]搜尋機票
POST /get_flights接受航線、日期、艙等與乘客。請保留方案所屬供應商項目的searchId,連同方案的id:報價時需要這一組。請求 POST /get_flights curl https://api.fx-port.com/api/v1/get_flights \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "origin": "ALG", "destination": "CDG", "departure_date": "2027-01-13", "cabin_class": "economy", "passengers": { "adults": 1 } }'回應 200 OK · 2.33 s · 695 KB 200 OK Content-Type: application/json Cache-Control: private, no-store X-Environment: sandbox ratelimit-limit: 6000 ratelimit-policy: 6000;w=60 x-fx-limit-class: flight_search { "environment": "sandbox", "success": true, "requestId": "54139f32", "searchType": "ONE_WAY", "flexible": false, "processingTime": 2.243, "suppliers": [ { "success": true, "searchId": "fs_e1853430-16e2-4bcb-8f11-4f7bfbc33602", "supportHold": true, "supportVoid": true, "voidDeadline": "2026-11-30T23:00:00Z", "filtersApplied": {}, "warnings": [], "meta": { "supplierId": "amadeus_aqc_dz_1", "technologyType": "amadeus_aqc", "supplierName": "Amadeus Algeria", "processingTime": 2.174, "supplierCurrency": "DZD", "agencyCurrency": "DZD" }, "results": { "totalOffers": 66, "supplierCurrency": "DZD", "agencyCurrency": "DZD", "offers": [ { "id": "fx_offer_b1c2a850", // ... 16 more } ] } }, { "success": true, "searchId": "fs_dfx_a3aeaa36-74ad-424b-b88d-e6bdc9a4ba94", "supportHold": false, "supportVoid": false, "voidDeadline": null, "filtersApplied": {}, "warnings": [], "meta": { // ... 6 more }, "results": { // ... 4 more }, "exchangeRate": 250 } ], "summary": { "totalSuppliers": 2, "successfulSuppliers": 2, "failedSuppliers": 0, "totalOffers": 158 } }範例已截短以便顯示. 完整回應的大小(依文件所載): 695 KB (26.0 KB gzip)
- PASS 狀態碼為 200
- PASS $.success 等於 true
- PASS $.suppliers 有 2 個項目
- PASS $.suppliers[0].results.offers[0].id 存在
保留票價,再支付款項
在涵蓋阿爾及利亞的航線上,Sandbox 支援保留。先不付款保留座位,確認訂單仍可付款,再付款並出票。保留與否取決於供應商、航空公司與票價,因此請先在已報價的方案上讀取 supportHold。
保留預訂
POST /flights/book_flight搭配設為hold的booking_type,會建立尚未出票也未收費的訂位。其狀態為pending,付款狀態為awaiting_payment。請求 POST /flights/book_flight curl https://api.fx-port.com/api/v1/flights/book_flight \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "search_id": "fs_85ac5f12-7456-4edf-a2fb-1d51239d278b", "offer_id": "fx_offer_9de60e2a", "booking_type": "hold", "send_email": false, "passengers": [ { "type": "adult", "gender": "MALE", "first_name": "James", "last_name": "Smith", "date_of_birth": "1988-07-14", "identity_documents": [ { "type": "passport", "number": "A12345678", "issuing_country": "DZ", "expiry_date": "2031-05-17" } ] } ], "contact_details": { "email": "[email protected]", "phone_number": "+15555550123" } }'回應 200 OK · 2.71 s · 4.2 KB 200 OK { "environment": "sandbox", "success": true, "requestId": "66e4b1a8", "searchId": "fs_85ac5f12-7456-4edf-a2fb-1d51239d278b", "offerId": "fx_offer_9de60e2a", "processingTime": 2.6235511302948, "booking": { "reference": "eJzTd9ePNA9wdA0FAAs8AmE", "status": "pending", // ... 9 more }, "supplier": { // ... 4 more }, // ... 3 more "documents": [], // ... 6 more "services": [], // ... 3 more "balanceDebited": false, "transactionCreated": false, "payoutCreated": false }- PASS 狀態碼為 200
- PASS $.booking.type 等於 hold
- PASS $.booking.status 等於 pending
- PASS $.payment.status 等於 awaiting_payment
- PASS $.balanceDebited 等於 false
確認報價
POST /flights/get_order_quote會傳回保留訂單目前的價格,以及說明是否仍可付款的canPay。此步驟為選用。請求 POST /flights/get_order_quote curl https://api.fx-port.com/api/v1/flights/get_order_quote \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "order_id": "eJzTd9ePNA9wdA0FAAs8AmE" }'回應 200 OK · 224 ms · 776 B 200 OK { "environment": "sandbox", "success": true, "requestId": "469d8803", "orderId": "eJzTd9ePNA9wdA0FAAs8AmE", "processingTime": 0.134, "orderQuote": { "orderId": "eJzTd9ePNA9wdA0FAAs8AmE", "bookingReference": "Y7PAEU", "status": "awaiting_payment", // ... 2 more "liveMode": false }, "supplier": { "id": "amadeus_aqc_dz_1", // ... 2 more }, "agency": { "currency": "DZD" }, "meta": { // ... 3 more } }- PASS 狀態碼為 200
- PASS $.orderQuote.status 等於 awaiting_payment
- PASS $.orderQuote.paymentStatus.canPay 等於 true
付款並出票
POST /flights/pay_order會從旅行社餘額扣除b2bPrice並出票;在 Sandbox 中不會有實際金流。唯有付款成功才算確認出票。請求 POST /flights/pay_order curl https://api.fx-port.com/api/v1/flights/pay_order \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "order_id": "eJzTd9ePNA9wdA0FAAs8AmE", "payment_type": "balance" }'回應 200 OK · 3.07 s · 4.6 KB 200 OK { "environment": "sandbox", "success": true, "paymentSucceeded": true, "requestId": "1ad06b56", "orderId": "eJzTd9ePNA9wdA0FAAs8AmE", "processingTime": 2.981, "paymentDetails": { "paymentId": null, // ... 6 more }, "booking": { // ... 11 more }, "supplier": { // ... 4 more }, "agency": { "currency": "DZD" }, // ... 9 more "services": [], // ... 4 more }- PASS 狀態碼為 200
- PASS $.paymentSucceeded 等於 true
- PASS $.booking.status 等於 confirmed
- PASS $.payment.status 等於 paid
重複付款
對已出票的訂單再次付款,會被供應商拒絕。回應為
200,且success為false,因此在採信狀態前請先讀取success。重試付款前,請先讀取預訂。請求 POST /flights/pay_order curl https://api.fx-port.com/api/v1/flights/pay_order \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "order_id": "eJzTd9ePNA9wdA0FAAs8AmE", "payment_type": "balance" }'回應 200 OK · 889 ms · 1.0 KB 200 OK { "environment": "sandbox", "paymentSucceeded": false, "requestId": "a63285ae", "orderId": "eJzTd9ePNA9wdA0FAAs8AmE", "processingTime": 0.799, "error": { // ... 4 more }, "supplier": { // ... 3 more }, "agency": { "currency": "DZD" }, "meta": { // ... 6 more }, "success": false, "errors": [ // ... 1 more ], "request_id": "a63285ae" }- PASS 狀態碼為 200
- PASS $.success 等於 false
- PASS $.paymentSucceeded 等於 false
讀取預訂與機票
付款之後,以預訂為準。先以 PNR 讀取預訂,再取得機票 PDF(可能需要一點時間才會產生),最後取得電子機票號碼。不會有任何回呼通知您,需要由您主動查詢。
讀取預訂
POST /flights/get_booking接受 PNR、供應商訂單 ID 或 FX-Port ID,並傳回狀態、價格、機票號碼與 PDF 連結。請求 POST /flights/get_booking curl https://api.fx-port.com/api/v1/flights/get_booking \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "booking_id": "Y7PAEU" }'回應 200 OK · 362 ms · 2.1 KB 200 OK { "environment": "sandbox", "success": true, "requestId": "0c2b315c", "processingTime": 0.272, "booking": { "id": "711371c3-00aa-4be2-b790-9f0ca2ccfdb7", "booking_id": "Y7PAEU", "amadeus_id": "eJzTd9ePNA9wdA0FAAs8AmE", "status": "confirmed", "created_at": "2026-11-30T15:26:14.871035+00:00", "paid_at": "2026-11-30T15:26:21.961664+00:00", "updated_at": "2026-11-30T15:26:21.998944+00:00", "total_price": 4930.37, "agency_commission": 4.93, "currency": "DZD", "departure_airport": "ALG", "arrival_airport": "ORN", "departure_date": "2027-01-20T19:45:00", "arrival_date": "2027-01-20T20:45:00", "return_departure_date": null, // ... 33 more } }- PASS 狀態碼為 200
- PASS $.booking.status 等於 confirmed
- PASS $.booking.ticket_number 存在
機票尚未備妥
PDF 仍在產生時,
POST /flights/get_ticket會回應ticket_ready為 false。請稍候片刻再查詢。請求 POST /flights/get_ticket curl https://api.fx-port.com/api/v1/flights/get_ticket \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "booking_id": "Y7PAEU" }'回應 200 OK · 160 ms · 169 B 200 OK { "environment": "sandbox", "success": true, "requestId": "76be69dc", "ticket_ready": false, "booking_id": "Y7PAEU", "message": "Ticket is not ready yet. Please retry in a moment." }- PASS 狀態碼為 200
- PASS $.ticket_ready 等於 false
機票已備妥
下一次呼叫會傳回
ticket_ready為 true,以及機票 PDF 的下載連結。請求 POST /flights/get_ticket curl https://api.fx-port.com/api/v1/flights/get_ticket \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "booking_id": "Y7PAEU" }'回應 200 OK · 190 ms · 371 B 200 OK { "environment": "sandbox", "success": true, "requestId": "71fdaeb7", "ticket_ready": true, "booking_id": "Y7PAEU", "download_url": "https://s3.example.com/flight-bookings/Y7PAEU-JAMES-SMITH.pdf", "download_url_with_price": "https://s3.example.com/flight-bookings/Y7PAEU-JAMES-SMITH.pdf", "download_url_no_price": "https://s3.example.com/flight-bookings/Y7PAEU-JAMES-SMITH-no-price.pdf" }- PASS 狀態碼為 200
- PASS $.ticket_ready 等於 true
- PASS $.download_url 存在
取得機票號碼
POST /flights/get_ticket_number會傳回電子機票號碼,若尚未儲存則向供應商查詢。保留訂位在付款前沒有機票號碼。請求 POST /flights/get_ticket_number curl https://api.fx-port.com/api/v1/flights/get_ticket_number \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "booking_id": "Y7PAEU" }'回應 200 OK · 210 ms · 2.0 KB 200 OK { "environment": "sandbox", "success": true, "requestId": "a8e2164f", "ticket_available": true, "ticket_number": "124-2446977397", "booking_id": "Y7PAEU", "supplier_order_id": "eJzTd9ePNA9wdA0FAAs8AmE", "booking_response": { "booking": { "pnr": "Y7PAEU", "type": "instant", // ... 9 more }, "supplier": { // ... 4 more }, // ... "payment": { // ... 5 more }, // ... 4 more } }範例已截短以便顯示
- PASS 狀態碼為 200
- PASS $.ticket_available 等於 true
- PASS $.ticket_number 存在
先報價退款,再取消已出票訂單
對於支援退款報價的供應商所開立的已出票訂單,API 會在取消前先報價退款金額。請向客戶顯示金額後再確認:取消無法復原,退款將存入您的 FX-Port 餘額。尚未付款的保留訂位則以另一個呼叫取消。
報價退款
POST /flights/cancel_quote向供應商查詢取消可退多少款項。此時尚未取消任何訂單,報價會過期,且許多票價因航空公司不允許取消而被拒絕。請求 POST /flights/cancel_quote curl https://api.fx-port.com/api/v1/flights/cancel_quote \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "order_id": "ord_0000BC0VDONwA54LrfoCkm" }'回應 200 OK · 218 ms · 910 B 200 OK { "environment": "sandbox", "success": true, "requestId": "2cb63f69", "orderId": "ord_0000BC0VDONwA54LrfoCkm", "processingTime": 0.128, "cancellation": { "cancellationId": "ore_0000BC0VG9WBaFAZ83u3yy", "orderId": "ord_0000BC0VDONwA54LrfoCkm", // ... 7 more }, "supplier": { // ... 3 more }, "agency": { "currency": "DZD" }, "exchangeRate": { // ... 4 more }, "meta": { // ... 3 more } }- PASS 狀態碼為 200
- PASS $.cancellation.status 等於 pending
- PASS $.meta.canConfirm 等於 true
確認取消
帶入報價的
cancellation_id呼叫POST /flights/confirm_cancel,會永久取消訂單,並將退款存入您的 FX-Port 餘額。請求 POST /flights/confirm_cancel curl https://api.fx-port.com/api/v1/flights/confirm_cancel \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "cancellation_id": "ore_0000BC0VG9WBaFAZ83u3yy", "order_id": "ord_0000BC0VDONwA54LrfoCkm" }'回應 200 OK · 335 ms · 1.1 KB 200 OK { "environment": "sandbox", "success": true, "requestId": "64666d3c", "orderId": "ord_0000BC0VDONwA54LrfoCkm", "processingTime": 0.245, "confirmation": { "cancellationId": "ore_0000BC0VG9WBaFAZ83u3yy", // ... 8 more }, "supplier": { // ... 3 more }, "agency": { "currency": "DZD" }, "exchangeRate": { // ... 4 more }, "meta": { // ... 2 more }, // ... 1 more }- PASS 狀態碼為 200
- PASS $.confirmation.status 等於 confirmed
- PASS $.confirmation.refund.refundAmount 存在
重複確認
確認已取消的訂單,會回應
200,其中success為false,代碼為already_cancelled。請同時讀取狀態與success,切勿盲目重複呼叫。請求 POST /flights/confirm_cancel curl https://api.fx-port.com/api/v1/flights/confirm_cancel \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "cancellation_id": "ore_0000BC0VG9WBaFAZ83u3yy", "order_id": "ord_0000BC0VDONwA54LrfoCkm" }'回應 200 OK · 216 ms · 1.2 KB 200 OK { "environment": "sandbox", "requestId": "c2eb0461", "orderId": "ord_0000BC0VDONwA54LrfoCkm", "cancellationId": "ore_0000BC0VG9WBaFAZ83u3yy", "processingTime": 0.126, "error": { "message": "This order has already been cancelled.", "code": "already_cancelled", "type": "invalid_state_error", // ... 2 more }, "supplier": { // ... 3 more }, "meta": { // ... 2 more }, "success": false, "errors": [ // ... 1 more ], "request_id": "c2eb0461" }- PASS 狀態碼為 200
- PASS $.success 等於 false
- PASS 錯誤碼為 already_cancelled
刻意失敗的呼叫
每個失敗都使用相同的內容結構,errors 的第一個項目帶有穩定的 code。這些呼叫都是刻意失敗,每個原因不同,應對方式也不同。
方案尚未報價
預訂從未報價的方案,會被
404與offer_not_priced拒絕。請先呼叫price_flight。請求 POST /flights/book_flight curl https://api.fx-port.com/api/v1/flights/book_flight \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "search_id": "fs_dfx_88eb64c9-6c36-47e6-bdaa-9ad3c1377ac4", "offer_id": "fx_offer_b7a95439", "booking_type": "issue", "send_email": false, "passengers": [ { "type": "adult", "gender": "MALE", "first_name": "James", "last_name": "Smith", "date_of_birth": "1990-02-13", "identity_documents": [ { "type": "passport", "number": "A12345678", "issuing_country": "DZ", "expiry_date": "2031-05-17" } ] } ], "contact_details": { "email": "[email protected]", "phone_number": "+15555550123" } }'回應 404 Not Found · 110 ms · 618 B 404 Not Found { "environment": "sandbox", "detail": { "error": "offer_not_priced", "message": "Priced offer 'fx_offer_b7a95439' not found in cache. Please price the offer first before booking.", "code": "OFFER_NOT_PRICED" }, "success": false, "errors": [ { "code": "offer_not_priced", "type": "not_found", "title": "Offer not priced", "message": "Priced offer 'fx_offer_b7a95439' not found in cache. Please price the offer first before booking.", "field": null, // ... 2 more } ], "meta": { "request_id": "req_8f3a61c2d9e4", "status": 404 }, "request_id": "req_8f3a61c2d9e4" }- PASS 狀態碼為 404
- PASS 錯誤碼為 offer_not_priced
- PASS $.errors[0].type 等於 not_found
以唯讀金鑰進行寫入
對
book_flight使用唯讀金鑰,會被403與read_write_permission_required拒絕。請改用讀寫金鑰。請求 POST /flights/book_flight curl https://api.fx-port.com/api/v1/flights/book_flight \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "search_id": "fs_dfx_88eb64c9-6c36-47e6-bdaa-9ad3c1377ac4", "offer_id": "fx_offer_b7a95439", "booking_type": "issue", "send_email": false, "passengers": [ { "type": "adult", "gender": "MALE", "first_name": "James", "last_name": "Smith", "date_of_birth": "1990-02-13", "identity_documents": [ { "type": "passport", "number": "A12345678", "issuing_country": "DZ", "expiry_date": "2031-05-17" } ] } ], "contact_details": { "email": "[email protected]", "phone_number": "+15555550123" } }'回應 403 Forbidden · 85 ms · 558 B 403 Forbidden { "environment": "sandbox", "detail": { "error": "read_write_permission_required", "message": "This endpoint requires an API key with read_write permission." }, "success": false, "errors": [ { "code": "read_write_permission_required", "type": "permission_error", "title": "Read write permission required", "message": "This endpoint requires an API key with read_write permission.", "field": null, "details": {}, "documentation_url": "https://fx-port.com/docs/errors#read_write_permission_required" } ], "meta": { "request_id": "req_8f3a61c2d9e4", "status": 403 }, "request_id": "req_8f3a61c2d9e4" }- PASS 狀態碼為 403
- PASS 錯誤碼為 read_write_permission_required
- PASS $.errors[0].type 等於 permission_error
重複預訂
再次送出相同的預訂,會被
409與duplicate_booking拒絕,回應中會列出第一筆預訂的 PNR。這只是安全機制:重複呼叫前請先讀取預訂。請求 POST /flights/book_flight curl https://api.fx-port.com/api/v1/flights/book_flight \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "search_id": "fs_dfx_88eb64c9-6c36-47e6-bdaa-9ad3c1377ac4", "offer_id": "fx_offer_b7a95439", "booking_type": "issue", "send_email": false, "passengers": [ { "type": "adult", "gender": "MALE", "first_name": "James", "last_name": "Smith", "date_of_birth": "1990-02-13", "identity_documents": [ { "type": "passport", "number": "A12345678", "issuing_country": "DZ", "expiry_date": "2031-05-17" } ] } ], "contact_details": { "email": "[email protected]", "phone_number": "+15555550123" } }'回應 409 Conflict · 120 ms · 667 B 409 Conflict { "environment": "sandbox", "detail": { "error": "duplicate_booking", "message": "This offer has already been booked successfully (PNR: BOKT52). Duplicate submissions are not allowed.", "code": "OFFER_ALREADY_BOOKED", "pnr": "BOKT52" }, "success": false, "errors": [ { "code": "duplicate_booking", "type": "conflict", "title": "Duplicate booking", "message": "This offer has already been booked successfully (PNR: BOKT52). Duplicate submissions are not allowed.", // ... 3 more } ], "meta": { "request_id": "req_8f3a61c2d9e4", "status": 409 }, "request_id": "req_8f3a61c2d9e4" }- PASS 狀態碼為 409
- PASS 錯誤碼為 duplicate_booking
- PASS $.errors[0].details.pnr 等於 BOKT52
沒有供應商回應
當所有供應商都失敗時,搜尋會回應
503與all_suppliers_failed,details會說明每家供應商的原因。請以退避方式重試。請求 POST /get_flights curl https://api.fx-port.com/api/v1/get_flights \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "origin": "ALG", "destination": "CDG", "departure_date": "2027-01-13", "cabin_class": "economy", "passengers": { "adults": 1 } }'回應 503 Service Unavailable · 120 ms · 829 B 503 Service Unavailable { "environment": "sandbox", "detail": { "error": "all_suppliers_failed", "message": "No supplier returned results. See supplierErrors for details.", "supplierErrors": [ // ... 1 more ] }, "success": false, "errors": [ { "code": "all_suppliers_failed", "type": "supplier_error", "title": "All suppliers failed", // ... 4 more } ], "meta": { "request_id": "req_8f3a61c2d9e4", "status": 503 }, "request_id": "req_8f3a61c2d9e4" }- PASS 狀態碼為 503
- PASS 錯誤碼為 all_suppliers_failed
- PASS $.errors[0].type 等於 supplier_error
同時呼叫過多
同一類呼叫同時過多,會得到
429與concurrency_limit_exceeded,並附上說明需等待多久的Retry-After標頭。這些上限目前僅計數、尚未強制執行,因此這是需要預先準備的回應。請求 POST /get_flights curl https://api.fx-port.com/api/v1/get_flights \ -H "Authorization: Bearer fxp_test_YOUR_KEY" \ -H "Content-Type: application/json" \ -H "Accept: text/event-stream" \ -d '{ "origin": "ALG", "destination": "CDG", "departure_date": "2027-01-13", "cabin_class": "economy", "passengers": { "adults": 1 } }'回應 429 Too Many Requests · 110 ms · 1.1 KB 429 Too Many Requests Retry-After: 5 { "environment": "sandbox", "detail": { "error": "concurrency_limit_exceeded", "message": "At most 4 streaming searches can run at the same time for one API key; wait for one to finish (or use the JSON response) and retry.", "retry_after": 5, "errors": [ // ... 1 more ], "meta": { "request_id": "req_8f3a61c2d9e4", // ... 2 more } }, "success": false, "errors": [ // ... 1 more ], "meta": { "request_id": "req_8f3a61c2d9e4", "status": 429 }, "request_id": "req_8f3a61c2d9e4" }- PASS 狀態碼為 429
- PASS 錯誤碼為 concurrency_limit_exceeded
- PASS 標頭 Retry-After 存在
所有機票端點與所需金鑰
全部 16 個端點共用同一個 Base URL。每一列都連結到對應的參考頁面,其中有請求欄位、回應、錯誤,以及9 種語言的範例。
| 端點 | 用途 | 金鑰 |
|---|---|---|
GET /api/v1/flights/airports | 為搜尋的出發地與目的地提供機場和城市自動完成。不需要金鑰。 | 無需金鑰 |
GET /api/v1/flights/top-airports | 最常被搜尋的機場,可作為空白搜尋框的初始建議。不需要金鑰。 | 無需金鑰 |
POST /api/v1/get_flights | 同時搜尋所有相容的供應商,並依供應商分組讀取方案。可要求串流,以伺服器傳送事件接收。 | 唯讀 |
POST /api/v1/flights/flexible_search | 價格日曆:從您指定日期的前三天到後三天,每天的最低票價。僅支援彈性日期的供應商會回應。 | 唯讀 |
POST /api/v1/flights/price_flight | 向供應商確認單一方案目前的票價與條件。預訂前必須執行,且不會保留任何訂位。 | 唯讀 |
POST /api/v1/flights/book_flight | 預訂已報價的方案:立即出票,或先保留訂位,稍後再付款。 | 讀寫 |
POST /api/v1/flights/get_booking | 以 PNR、供應商訂單 ID 或 FX-Port ID 讀取預訂:狀態、價格、機票號碼與 PDF 連結。 | 唯讀 |
POST /api/v1/flights/get_ticket | 機票 PDF 的下載連結,或保留訂位的憑證。可重複呼叫直到準備就緒。 | 唯讀 |
POST /api/v1/flights/get_ticket_number | 預訂的電子機票號碼,若尚未儲存則向供應商查詢。 | 唯讀 |
POST /api/v1/flights/get_order_quote | 保留訂單目前的價格與狀態,以及是否仍可付款。付款前可選擇性呼叫。 | 唯讀 |
POST /api/v1/flights/pay_order | 從旅行社餘額支付保留訂單並出票。 | 讀寫 |
POST /api/v1/flights/cancel_order | 取消保留中且尚未付款的訂位並釋出 PNR。這不是退款。 | 讀寫 |
POST /api/v1/flights/cancel_quote | 針對支援退款報價的供應商,查詢取消已出票訂單可退多少款項。此時尚未取消任何訂單。 | 唯讀 |
POST /api/v1/flights/confirm_cancel | 確認已報價的取消。此操作無法復原,退款將存入您的 FX-Port 餘額。 | 讀寫 |
POST /api/v1/flights/get_acd_documents | ACD 預訂需要哪些文件、哪些旅客已有護照存檔,以及是否可以上傳。 | 唯讀 |
POST /api/v1/flights/upload_acd_documents | 以 multipart 上傳方式新增或取代 ACD 預訂的護照影本,每位旅客一個檔案。 | 讀寫 |
機場查詢不需要金鑰。標示為讀寫的端點會建立、支付或取消資料,唯讀金鑰在此會被拒絕。
所有端點的 API 參考機票 API 文件快速入門:搜尋、報價與預訂
機票搜尋支援的條件
搜尋支援單程、來回、開口與多城市行程,可指定艙等,乘客組合涵蓋成人、長者、青年、兒童與嬰兒(有座位或坐在大人腿上)。篩選條件包括直飛、航空公司允許與排除清單、可退票票價,以及含託運行李。各供應商對篩選條件的執行嚴格程度不一,請檢查回傳的方案。
已報價方案與已出票預訂的樣貌
預訂需要先取得已報價的方案,價格可能與搜尋結果不同。以下是 price_flight 的回應,以及立即出票的 book_flight 呼叫回應,兩者都是與文件完全一致的範例。
POST /flights/price_flight:方案的最新狀態,含完整價格區塊。請求
curl https://api.fx-port.com/api/v1/flights/price_flight \
-H "Authorization: Bearer fxp_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"search_id": "fs_dfx_a3aeaa36-74ad-424b-b88d-e6bdc9a4ba94",
"offer_id": "fx_offer_89d6592c"
}'回應: 200 OK
{
"environment": "sandbox",
"success": true,
"requestId": "76f8fc58",
"offerId": "fx_offer_89d6592c",
"offerType": "priced",
"processingTime": 0.177,
"supplierCurrency": "USD",
"agencyCurrency": "DZD",
"results": {
"totalOffers": 1,
"supplierCurrency": "USD",
"agencyCurrency": "DZD",
"offers": [
{
"id": "fx_offer_89d6592c",
"type": "flight_offer",
"supplier": {
// ... 3 more
},
"source": "duffel",
"bookableSeats": null,
"supportHold": false,
"supportVoid": false,
"voidDeadline": null,
"filtersApplied": {},
"warnings": [],
"instantTicketingRequired": false,
"pricing": {
"supplierCurrency": "USD",
"agencyCurrency": "DZD",
"basePrice": 16975,
"taxesAndFees": 5366.8,
"agencyCommission": 22.35,
"finalPrice": 22364.15,
"b2bPrice": 22341.8,
"additionalServices": []
},
// ... 6 more
}
]
},
"exchangeRate": 250
}POST /flights/book_flight,booking_type 設為 issue:訂單、其 PNR 與付款狀態。請求
curl https://api.fx-port.com/api/v1/flights/book_flight \
-H "Authorization: Bearer fxp_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"search_id": "fs_dfx_88eb64c9-6c36-47e6-bdaa-9ad3c1377ac4",
"offer_id": "fx_offer_b7a95439",
"booking_type": "issue",
"send_email": false,
"passengers": [
{
"type": "adult",
"gender": "MALE",
"first_name": "James",
"last_name": "Smith",
"date_of_birth": "1990-02-13",
"identity_documents": [
{
"type": "passport",
"number": "A12345678",
"issuing_country": "DZ",
"expiry_date": "2031-05-17"
}
]
}
],
"contact_details": {
"email": "[email protected]",
"phone_number": "+15555550123"
}
}'回應: 200 OK
{
"environment": "sandbox",
"success": true,
"requestId": "7b166b31",
"searchId": "fs_dfx_88eb64c9-6c36-47e6-bdaa-9ad3c1377ac4",
"offerId": "fx_offer_b7a95439",
"processingTime": 0.4079086780548096,
"booking": {
"reference": "ord_0000BC0UuqWJKkrDO331Xc",
"status": "confirmed",
"pnr": "BOKT52",
"type": "instant",
"createdAt": "2026-11-30T14:24:41.453265Z",
"cancelledAt": null,
// ... 5 more
},
"supplier": {
// ... 4 more
},
"agency": {
"currency": "DZD"
},
"pricing": {
"supplierCurrency": "USD",
"agencyCurrency": "DZD",
"basePrice": 16342.51,
"taxesAndFees": 5216.69,
"agencyCommission": 21.56,
"finalPrice": 21580.76,
"b2bPrice": 21559.2,
"additionalServices": []
},
"payment": {
"status": "paid",
// ... 4 more
},
// ... 7 more
"services": [],
"exchangeRate": 250,
// ... 2 more
"balanceDebited": false,
"transactionCreated": false,
"payoutCreated": false
}| 欄位 | 內容說明 |
|---|---|
basePrice | 航空公司的基本票價,未含稅費,以旅行社幣別計價。 |
taxesAndFees | 稅金加上平台端費用,不含您的佣金。 |
agencyCommission | 旅行社在這筆銷售中賺取的佣金。 |
finalPrice | 旅客實付金額:基本票價加稅費,再加上您的佣金。 |
b2bPrice | 旅行社餘額實際扣款金額:最終價格減去您的佣金。 |
依已報價方案選擇保留或出票
報價時會重新評估
supportHold與supportVoid。僅當supportHold為 true 時才能以hold預訂;否則 API 會以hold_not_supported拒絕該呼叫。退票與改票條件僅供參考
方案上的退票與改票條件僅供參考,可能與實際收費不同。請告知旅客機票可付費退票或改票,不要提供確切金額。
金額以旅行社幣別顯示
無論供應商以何種幣別收費,每筆金額都已換算為旅行社的幣別。供應商幣別與匯率都在回應中,方便您稽核,請勿重複換算。
報價後請盡快預訂
已報價的方案只會保留一段有限的時間,供應商也可能更早撤回方案。報價後請盡快預訂;若 API 回應方案已過期,請重新搜尋。
為正式環境而建:金鑰、錯誤、重試與限制
這些是機票串接在第一週就會遇到的規則:如何驗證身分、失敗長什麼樣子、哪些操作可以安全重複,以及呼叫的速度上限。
金鑰與環境
請將金鑰以 Bearer 權杖的形式放在 Authorization 標頭中傳送。Sandbox 金鑰以 fxp_test_ 開頭,Live 金鑰以 fxp_live_ 開頭,兩者共用同一個 Base URL:由金鑰決定環境,且每個 JSON 回應都會在 environment 中重複標示。請將金鑰保管在您的伺服器上,因為此 API 不適合從瀏覽器呼叫;機票 PDF 連結請視同機密,因為不需要金鑰就能開啟。
唯讀與讀寫金鑰
唯讀金鑰可搜尋、報價,以及讀取預訂與機票。預訂、付款與取消需要讀寫金鑰,唯讀金鑰嘗試這些操作會被 read_write_permission_required 拒絕。您可以將金鑰鎖定在一份 IP 位址清單內,來自其他位址的請求會被 ip_not_allowed 拒絕。
可據以分流處理的錯誤
所有失敗都使用相同的內容結構:一個 errors 陣列,其第一個項目帶有穩定的 code、告訴您該如何因應的 type,以及出錯的 field。請依據錯誤碼處理,不要依據訊息。請求本身的錯誤會以 400 回傳,例如機場代碼不是三個字母時的 invalid_airport_code,以及出發日期早於昨天時的 date_in_past。共用的錯誤目錄在機票、飯店、eSIM 與帳號中共列出 180 個錯誤碼。少數預訂後的呼叫(pay_order、get_order_quote、cancel_quote 與 confirm_cancel)在供應商拒絕時,會回應 200 且 success 為 false,因此兩者都要讀取。
重試時避免重複預訂
沒有 Idempotency-Key 標頭。搜尋與報價可以安全地重複呼叫;book_flight、pay_order、cancel_order 與 confirm_cancel 則不行。若回應始終沒有送達,請先以 get_booking 讀取預訂,再重新送出呼叫。同一個方案若再次預訂,會被 409 與 duplicate_booking 拒絕,這只是安全機制,不能取代上述檢查。
沒有 Webhook:請輪詢預訂
FX-Port 不會呼叫您的網址。預訂之後,請輪詢 get_booking 以取得狀態與機票連結,間隔不要短於數秒。get_ticket 與 get_ticket_number 可能回應尚未備妥:請稍候片刻再查詢。
串流搜尋結果
加上 stream=true,搜尋就會以伺服器傳送事件回應:最快的供應商一回應,第一批方案便隨即送達,其餘則依供應商陸續送出。於 2026年11月1日 在 Sandbox 實測,JSON 搜尋耗時 2.7 到 8 秒,串流的第一批方案則在 1.5 到 2.6 秒後送達。串流不經壓縮,因此適合使用者正在觀看的搜尋頁面;其他情況請使用搭配 gzip 的 JSON。
串流中的四個事件,依送達順序排列。實際傳輸時,每個事件還有一行 id:,從 0 開始為事件編號,而方案透過 offers_chunk 與 supplier_result 事件傳送:此節錄兩者都省略了。supplier_complete 事件會統計一個結果集的方案數量,complete: false 表示該供應商還有下一批結果,因此 summary 為它統計的方案數可能更多。
text/event-stream
event: start
data: {"environment":"sandbox","type":"start","requestId":"d36b6918","searchType":"ONE WAY","flexible":false,"timestamp":"2026-11-30T15:22:57.762071","expectedSuppliers":["amadeus_aqc_dz_1","duffel_1"],"search_type":"ONE_WAY"}
event: supplier_complete
data: {"type":"supplier_complete","supplierId":"amadeus_aqc_dz_1","totalOffers":68,"hasFlexPrices":false,"flexPricesCount":0,"complete":false,"timestamp":"2026-11-30T15:22:59.819079"}
event: summary
data: {"type":"summary","requestId":"d36b6918","success":true,"processingTime":2.581,"summary":{"totalSuppliers":2,"successfulSuppliers":2,"failedSuppliers":0,"totalOffers":162},"successfulSuppliers":[{"supplierId":"duffel_1","offersCount":92,"processingTime":1.381},{"supplierId":"amadeus_aqc_dz_1","offersCount":70,"processingTime":2.516}],"failures":null,"timestamp":"2026-11-30T15:23:00.286463"}
event: done
data: {"type":"done","requestId":"d36b6918","timestamp":"2026-11-30T15:23:00.286605"}速率限制
限制依每把金鑰、每分鐘計算,搜尋以及同時進行中的呼叫,上限更為嚴格。每個回應上的 ratelimit-limit 與 ratelimit-remaining 標頭會顯示適用於您的限制,請務必讀取。收到 429 時,請等待 Retry-After 指定的時間,再以指數退避搭配抖動重試。
| 呼叫類型 | 每分鐘 | 突發 | 同時進行數 |
|---|---|---|---|
| 機票搜尋 | 300 | 60 | 12 |
| 報價 | 3,000 | 450 | 48 |
| 預訂呼叫 | 600 | 100 | 20 |
| 讀取預訂或機票 | 1,200 | 200 | 16 |
| ACD 護照上傳 | 30 | 10 | 3 |
目前這些上限處於觀察模式:僅計數而不強制執行,因此尚不會因此拒絕任何請求,變更日誌會公告開始強制執行的日期。請將這些數字視為目前的政策,而非承諾。Sandbox 金鑰的上限低於 Live 金鑰,因此請排程執行負載測試,不要在迴圈中連續進行。
名稱與版本
請求欄位使用 snake_case。searchId 等較早的寫法仍然有效,回應會附上 warnings 項目,說明應改用的寫法;加上 ?naming=snake 也會讓回應中的鍵使用 snake_case。版本是路徑的一部分,即 /api/v1:破壞性變更會以新的前綴發布,新增性變更則不會。
誰在使用機票 API 開發
所有人使用的端點都相同,差別在於各自倚重的端點不同。
旅行社
旅行社會在客戶考慮時保留票價(供應商允許時),客戶確認後再付款,並在每筆銷售中保有自己的佣金。佣金會出現在每個價格區塊中,
commission_override可為單筆預訂設定佣金,agent_id則用您自己的業務員 ID 標記預訂。線上旅行社
OTA 通常先建好搜尋頁面。供應商一回應就串流顯示方案;供應商支援彈性日期搜尋時,顯示價格日曆;結帳前再重新報價一次,因為搜尋到預訂之間票價可能變動。
旅遊平台與技術團隊
平台會把機票整合進自己的產品與工具。OpenAPI 檔案、Postman 集合,以及供 AI 助理閱讀的純文字文件都公開提供,新進同事或程式輔助工具因此能直接依據真實的規格開始,而不必憑空猜測。
文件、OpenAPI 與程式碼範例
參考文件與上方主控台出自同一份 API 描述,因此您看到的範例,就是可以直接複製的範例。
OpenAPI 3.1
單一檔案描述了所有端點,您可以據此產生用戶端、匯入 API 工具,或交給程式輔助工具使用。
Postman 集合
機票集合將全部 16 個端點分資料夾整理,會為下一個請求儲存
search_id與offer_id,且不含任何金鑰,請自行加入您的金鑰。9 種語言的程式碼範例
端點頁面會以下列語言呈現每個請求,內容與 OpenAPI 檔案出自同一份描述:cURL、Node.js、Python、PHP、Go、Java、C#、Swift 與 Kotlin。護照的 multipart 上傳範例,只會出現在能建立 multipart 內容的語言中。
供 AI 工具使用的純文字
llms.txt與llms-full.txt以文字建立文件索引並匯出文件;任何文件頁面只要在網址後加上.md,就能取得 Markdown 版本。
從 Sandbox 環境開始
今天就能跑完整個流程。Sandbox 可自助使用且免費,使用 Sandbox 金鑰的任何操作都不會動用您的實際餘額。
建立帳號
註冊 FX-Port 帳號。Sandbox 金鑰免費提供,Sandbox 中的預訂不會產生任何實際費用。
建立 Sandbox 金鑰
在儀表板的 API 頁面建立以
fxp_test_開頭的金鑰。唯讀金鑰可搜尋與讀取資料;讀寫金鑰還能建立測試預訂。送出第一個請求
所有請求共用同一個 Base URL,金鑰以 Bearer 權杖的形式放在
Authorization標頭中。快速入門會帶您完成第一次呼叫。準備好後切換到 Live
改用
fxp_live_金鑰即可。旅行社通過核准後,Live 才能使用;在此之前 API 會回應403 agency_not_active。實際預訂從已儲值的餘額中扣款。
以 cURL 進行的第一次機票搜尋。文件支援的每種語言都有相同的呼叫範例。
cURL
curl https://api.fx-port.com/api/v1/get_flights \
-H "Authorization: Bearer fxp_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"origin": "ALG",
"destination": "CDG",
"departure_date": "2027-01-13",
"cabin_class": "economy",
"passengers": {
"adults": 1
}
}'Sandbox 連接的對象
Sandbox 使用一家全球供應商的測試系統(可立即出票),以及一家涵蓋阿爾及利亞相關航線的供應商的測試系統,後者也支援保留、當日作廢與彈性日期。使用全球供應商時,一次搜尋只能預訂一次,因此預訂第二個方案前請重新搜尋。測試系統可能短暫中斷,部分航線在 Sandbox 失敗,但在 Live 可以正常運作。測試期間請將 send_email 設為 false,以免確認信寄到您輸入的信箱。
切換到 Live 環境
旅行社通過核准後,Live 金鑰才能使用。在此之前它會被 agency_not_active 拒絕,而您的 Sandbox 金鑰仍可繼續使用。Live 預訂從已儲值的旅行社餘額扣款。切換時程式碼不必更改,只要換金鑰,因為兩個環境共用同一個 Base URL。切換前,請先對照 Sandbox 指南中的測試檢查清單。
目前尚無法自助的項目
公平的比較不只要看功能,也要看缺口。以下是仍須由人工處理,或不在公開 API 中的機票作業。
作廢、改票與重新開票
已出票機票的作廢、改票與重新開票,由 FX-Port 團隊依需求處理;涵蓋阿爾及利亞相關航線的已出票機票退款也是如此。自助取消涵蓋保留中的訂位,以及支援退款報價的供應商所開立的已出票訂單(需航空公司允許取消)。
座位、餐點與加購行李
方案可列出加購託運行李的價格,但為預訂加購行李、座位或餐點並不屬於公開 API。
ACD 票價的護照影本
涵蓋阿爾及利亞相關航線的部分票價屬於 ACD 票價。它們照常預訂,之後每位旅客需補上一份護照影本,並以
upload_acd_documents上傳完成。
Live 預訂需要以上任一項目嗎?請從儀表板的預訂頁面送出需求,或寫信至 [email protected] 並附上訂單 ID。
機票 API 常見問題
FX-Port 機票 API 是什麼?適合誰使用?
這是一個 REST API,讓旅行社、OTA 或旅遊平台只需一次串接,就能搜尋、報價並預訂機票。搜尋涵蓋 GDS、NDC 與廉價航空來源,預訂可以先保留,也可以立即出票,機票連結與號碼只需再呼叫一次即可取得。請求與回應皆為透過 HTTPS 傳輸的 JSON,每個端點都有 OpenAPI 檔案說明。
如何取得 Sandbox 金鑰?需要付費嗎?
建立 FX-Port 帳號,開啟儀表板的 API 頁面並建立金鑰即可。Sandbox 金鑰免費且可自助申請:從第一天起,您就能在供應商的測試系統上搜尋、報價、預訂與取消,不會有實際金流。Sandbox 與 Live 使用相同的 Base URL,因此您在這裡撰寫的程式碼,之後就能直接用於正式環境。
使用 Live 金鑰前需要具備什麼條件?
您的旅行社必須通過核准。在此之前,Live 金鑰會被拒絕,而您的 Sandbox 金鑰仍可繼續使用。Live 預訂從已儲值的旅行社餘額扣款,且您可以將任何金鑰限制在一份 IP 位址清單內。切換時只需更換金鑰:兩個環境共用同一個 Base URL,每個回應也都會註明它來自哪個環境。
搜尋涵蓋哪些供應商與航線?
搜尋會送往所有已啟用且能服務該航線的供應商,並把每家供應商的方案放在各自的項目中,因此 GDS、NDC 與廉價航空來源的內容可以並列。已啟用哪些供應商取決於您的金鑰,供應商端點會列出它們,請讀取清單而不要寫死在程式碼中。Sandbox 有一家全球供應商,以及一家涵蓋阿爾及利亞相關航線的供應商。
價格以哪種幣別顯示?佣金如何運作?
無論供應商以何種幣別收費,價格都會以旅行社的幣別傳回,並同時附上供應商幣別與匯率。每個價格區塊都有基本票價、稅金與費用、旅行社佣金,以及旅客實付的最終價格。從您的餘額扣除的金額,是最終價格減去您的佣金,而且您可以逐筆預訂設定佣金。
可以先保留票價,之後再付款嗎?
可以,但需供應商支援。請先為方案報價並讀取其保留旗標:只有已報價且標示支援保留的方案,才能以保留方式預訂。唯有付款成功才算確認出票,因為航空公司可能提前釋出訂位,所以請儘速付款。若放棄保留,請取消它以釋出訂位。在 Sandbox 中,涵蓋阿爾及利亞的航線可以進行保留。
機票會立即出票嗎?能透過 API 取消或退票嗎?
預訂時將預訂類型設為出票,機票便會在預訂過程中一併開立;PDF 連結與電子機票號碼則由各自的呼叫取得。保留中的訂位可透過 API 取消,由於尚未付款,因此沒有退款。支援退款報價的供應商所開立的已出票訂單,可以報價並取消,航空公司允許時,退款會存入您的 FX-Port 餘額。作廢、改票與其他退款,則由 FX-Port 團隊處理。
呼叫失敗時會怎樣?有 Webhook 嗎?
所有失敗都使用同一種內容結構,並帶有穩定的錯誤碼,因此請依據錯誤碼處理,而不是依據訊息。搜尋與報價可以安全地重複呼叫,送出過多請求時請退避後重試。預訂、付款與取消則不同:由於沒有冪等鍵,重複呼叫前請先讀取預訂。沒有 Webhook,請以輪詢預訂的方式取得變動。
機票搜尋有多快?結果可以串流嗎?
於 2026年11月1日 在 Sandbox 實測,JSON 搜尋耗時 2.7 到 8 秒,因為它要等最慢的供應商。串流在 1.5 到 2.6 秒後傳回第一批方案,並依供應商陸續送出。使用者正在觀看的搜尋頁面請用串流;批次作業、快取與價格比較則使用搭配 gzip 壓縮的 JSON。
開始前需要準備什麼?第一次串接要多久?
一把 Sandbox 金鑰和任何 HTTP 用戶端即可。快速入門約十分鐘就能完成搜尋、報價、預訂與回讀。文件另提供 OpenAPI 檔案、Postman 集合、9 種語言的程式碼範例,以及供 AI 助理使用的純文字匯出檔。真正比較花時間的,是您自己的結帳流程、錯誤處理與重試機制。