須經核准
API 金鑰將在審核後核發。請透過開發者入口網站申請;核准時將依預估用量設定配額。
基底 URL
驗證
每次請求都須在 X-API-Key 標頭中傳送您的金鑰:
X-API-Key: <YOUR_API_KEY>金鑰的作用範圍限於您的組織,且僅會在建立時顯示一次。若金鑰外洩,請在儀表板進行輪替,原有密鑰將立即失效。
範例 — 搜尋路線
請求
curl -X POST 'https://api.allflyghts.com/api/search/routes' \
-H 'X-API-Key: $ALLFLYGHTS_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"legs": [
{
"from": { "cityId": 48217 },
"to": { "cityId": 12845, "fromDate": "2026-04-25", "toDate": "2026-05-02" }
}
]
}'回應 — 200 OK
{
"searchId": "s_20260425_48217_12845",
"flights": [
{
"id": "r001",
"segments": [
{
"departure": { "iata": "BUD", "city": "Budapest" },
"arrival": { "iata": "STN", "city": "London" },
"options": [{ "airline": { "name": "Ryanair", "iata": "FR" } }]
}
],
"departureAirportDistance": 117,
"destinationAirportDistance": 35
}
]
}錯誤格式
錯誤會傳回 JSON 本文,其中包含 error 訊息及供程式處理的固定 code:
{
"error": "City ID 99999 not found",
"code": "CITY_NOT_FOUND"
}常見代碼包括 INVALID_REQUEST、CITY_NOT_FOUND、RATE_LIMITED 與 INTERNAL_ERROR。超過速率限制時會以 HTTP 429 回應。