GET/v1/trains/locations?keyword={keyword}&language={language}

搜索火车地点

按关键词搜索车站和火车地点。

分享

按关键词搜索车站和火车地点。

认证和请求头

请求头说明
AuthorizationBearer <secret_key>。密钥只能保存在服务器端,不能写入客户端日志。
X-Travelandz-Id<public_key>:<profile_code>,持久化的 profile code 格式为 dp_<12 位字母数字>。
Content-Type带 JSON body 的请求使用 application/json。

请求

Query:keyword 必填且不能为空。language 可选,支持 en、es 或 zh。

请求参数结构

keyword
string是
Required search text; it cannot be empty.
language
enum
eneszh
否

成功响应

返回 locations[],包含 id、名称、国家、国家代码、坐标和语言。

响应体结构

locations
array是
locations[]id
string是
locations[]name
string是
locations[]countryCode
string
格式: 2-letter country code
是
locations[]country
string是
locations[]latitude
number是
locations[]longitude
number是
locations[]language
enum
eneszh
是

错误

  • 400 表示验证失败或存在未知字段。
  • 401 或 403 表示 API 凭证无效。
  • 供应方失败时返回 500 internal_communication_error 或 unknown_error。

使用说明

在行程搜索中使用返回的地点 id 作为 origin 和 destination。

cURL 示例

bash
bash
curl --request GET \
  --url "https://api.sandbox.travelandz.com/v1/trains/locations?keyword=Paris&language=en" \
  --header "Authorization: Bearer $TRAVELANDZ_SECRET_KEY" \
  --header "X-Travelandz-Id: $TRAVELANDZ_PUBLIC_KEY:$TRAVELANDZ_PROFILE_CODE"