需经批准
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。