GET/v1/flights/airports
API 控制台
试一试
向沙箱 API 发送真实请求并查看响应。
凭证
登录后即可从已保存的 API 密钥中选择,无需手动粘贴。
查询参数
4 个字段搜索文本
用于匹配机场名称、城市或 IATA 代码的自由文本查询。
纬度
基于半径搜索机场时中心点的纬度。
经度
基于半径搜索机场时中心点的经度。
半径(公里)
围绕所提供坐标的搜索半径(公里)。
cURL 请求
bash
curl -X GET 'https://api.sandbox.travelandz.com/v1/flights/airports?queryString=Madrid' \
-H 'Authorization: Bearer YOUR_SECRET_KEY' \
-H 'X-Travelandz-Id: YOUR_PUBLIC_KEY:YOUR_PROFILE_CODE'请填写凭证以发送请求。
响应
点击「试一试!」发送请求,响应将显示在此处。
通过自由文本或附近坐标搜索机场元数据,用于自动补全和基于位置的航班搜索。
接口
| 方法 | 路径 | 认证 |
|---|---|---|
GET | /v1/flights/airports | 需要 API key |
| Header | 说明 |
|---|---|
Authorization | Bearer <secret_key>. The secret is shown only once when the credential is created. |
X-Travelandz-Id | <public_key>:<profile_code>. The profile_code is the dp_-prefixed Developer Profile code shown in your dashboard. This binds the request to a profile and credential. |
Content-Type | Use application/json for requests with a body. |
请求参数结构
latRequired when
queryString is not providedlngRequired when
queryString is not providedradiusRequired when
queryString is not providedqueryStringAlternative to coordinates
请求体
不需要请求体。
成功响应
返回 matching airports and location metadata.
响应体结构
airportsairports[]nameairports[]city_nameairports[]time_zoneairports[]longitudeairports[]latitudeairports[]iata_country_codeairports[]iata_codeairports[]iata_city_codeairports[]typeairports[]airportNameairports[]distanceFromPointliveModeTrue when the request is served by the live Travelandz environment. This value comes from Travelandz, not the provider payload.
集成说明
queryString can be used for text search. When using geographic search, send lat, lng and optional radius; radius defaults to 30 kilometers.
Query examples
Text search: ?queryString=Barcelona
Coordinate search: ?lng=2.080877&lat=41.297273&radius=50
示例
bash
curl "https://api.sandbox.travelandz.com/v1/flights/airports?queryString=Madrid" \
-H "Authorization: Bearer $TRAVELANDZ_SECRET_KEY" \
-H "X-Travelandz-Id: $TRAVELANDZ_PUBLIC_KEY:$TRAVELANDZ_PROFILE_CODE"响应
| 状态码 | 说明 |
|---|---|
200 | Airports retrieved successfully. |
400 | 请求无效:payload 不合法。 |
401 | 未授权:凭证无效或缺失。 |
403 | 禁止访问:凭证无效。 |
500 | 服务器内部错误 |
200 响应体
媒体类型:application/json
json
{
"airports": [
{
"name": "Barcelona",
"city_name": "Barcelona",
"time_zone": "Europe/Madrid",
"longitude": 2.080877,
"latitude": 41.297273,
"iata_country_code": "ES",
"iata_code": "BCN",
"iata_city_code": "BCN",
"type": "airport",
"airportName": "Barcelona-El Prat Josep Tarradellas Airport"
},
{
"name": "Barcelona",
"city_name": "Barcelona",
"time_zone": "America/Caracas",
"longitude": -64.684271,
"latitude": 10.103767,
"iata_country_code": "VE",
"iata_code": "BLA",
"iata_city_code": "BLA",
"type": "airport",
"airportName": "General Jose Antonio Anzoategui International Airport"
}
],
"liveMode": false
}