POST/v1/trains/journeys/:gdsprovider/:journeyId/offers

获取行程报价

获取行程搜索返回的可预订报价。

分享

获取行程搜索返回的可预订报价。

认证和请求头

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

请求

Path:gdsprovider 当前为 0;journeyId 来自行程搜索。可选 query:language(en、es、zh)和 returnCancellationPolicies(boolean)。

必需 body:

json
json
{"passengers":[{"type":"adult"},{"type":"senior"}]}

请求参数结构

gdsprovider
enum
0
是
Currently 0
journeyId
string是
Journey id returned by the journey search.

请求查询参数模式

language
enum
eneszh
否
returnCancellationPolicies
boolean否

请求体结构

passengers
array是
passengers[]type
enum
youthadultsenior
是

成功响应

返回 journey 对象,其行程包含 offers[]。报价包括 offerId、parts、灵活性、等级、条件、取消政策和 { amount, currency } 价格。

响应体结构

journey
object是
journeygdsprovider
number是
journeyjourneyId
string是
journeyitinerary
array是
journeyitinerary[]itineraryIndex
number是
journeyitinerary[]segments
array是
journeyitinerary[]segments[]segmentId
string是
journeyitinerary[]segments[]departure
object是
journeyitinerary[]segments[]departuredepartureAt
string
格式: ISO 8601
是
journeyitinerary[]segments[]departurename
string是
journeyitinerary[]segments[]departurelocationId
string是
journeyitinerary[]segments[]departurecountry
string是
journeyitinerary[]segments[]departurecountryCode
string是
journeyitinerary[]segments[]arrival
object是
journeyitinerary[]segments[]arrivalarrivalAt
string
格式: ISO 8601
是
journeyitinerary[]segments[]arrivalname
string是
journeyitinerary[]segments[]arrivallocationId
string是
journeyitinerary[]segments[]arrivalcountry
string是
journeyitinerary[]segments[]arrivalcountryCode
string是
journeyitinerary[]segments[]identifier
string是
journeyitinerary[]segments[]transport
enum
trainbusferry
是
journeyitinerary[]segments[]durationInMinutes
number是
journeyitinerary[]segments[]operator
object是
journeyitinerary[]segments[]operatorcode
string是
journeyitinerary[]segments[]operatorname
string是
journeyitinerary[]segments[]operatorimageUrl
string可为空
journeyitinerary[]segments[]service
object是
journeyitinerary[]segments[]servicename
string可为空
journeyitinerary[]segments[]serviceimageUrl
string可为空
journeyitinerary[]offers
array是
journeyitinerary[]offers[]offerId
string是
journeyitinerary[]offers[]parts
array是
journeyitinerary[]offers[]parts[]segments
array是
journeyitinerary[]offers[]parts[]segments[]segmentId
string是
journeyitinerary[]offers[]parts[]segments[]amenities
array是
journeyitinerary[]offers[]parts[]segments[]amenities[]
string[]是
journeyitinerary[]offers[]parts[]flexibility
enum
non_flexsemi_flexfull_flex
是
journeyitinerary[]offers[]parts[]comfortClass
enum
basicstandardhighbestunknown
是
journeyitinerary[]offers[]parts[]serviceClass
enum
basicstandardhighbestunknown
是
journeyitinerary[]offers[]parts[]conditions
array是
journeyitinerary[]offers[]parts[]conditions[]type
string是
journeyitinerary[]offers[]parts[]conditions[]condition
string是
journeyitinerary[]offers[]parts[]conditions[]note
string否
journeyitinerary[]offers[]parts[]conditions[]conditionKey
string是
journeyitinerary[]offers[]parts[]cancellationPolicies
array是
journeyitinerary[]offers[]parts[]cancellationPolicies[]__typename
object是
journeyitinerary[]offers[]parts[]cancellationPolicies[]__typenametype
enum
CancellationByPercentageCancellationByPercentChargeCancellationByFixedChargeFullCancellableNonCancellable
是
journeyitinerary[]offers[]parts[]cancellationPolicies[]description
string否
journeyitinerary[]offers[]parts[]cancellationPolicies[]minimum_minutes_before_departure
number否
journeyitinerary[]offers[]parts[]cancellationPolicies[]maximum_minutes_before_departure
number否
journeyitinerary[]offers[]parts[]cancellationPolicies[]minimum_minutes_after_departure
number否
journeyitinerary[]offers[]parts[]cancellationPolicies[]maximum_minutes_after_departure
number否
journeyitinerary[]offers[]parts[]cancellationPolicies[]percentage
number否
When __typename is CancellationByPercentage
journeyitinerary[]offers[]parts[]cancellationPolicies[]chargePercentage
number否
When __typename is CancellationByPercentCharge
journeyitinerary[]offers[]parts[]cancellationPolicies[]chargeAmount
number否
When __typename is CancellationByFixedCharge
journeyitinerary[]offers[]parts[]cancellationPolicies[]currency
string
格式: ISO 4217 code
否
When __typename is CancellationByFixedCharge
journeyitinerary[]offers[]parts[]cancellationPolicies[]perPerson
boolean否
When __typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optional
journeyitinerary[]offers[]parts[]cancellationPolicies[]perLeg
boolean否
When __typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optional
journeyitinerary[]offers[]parts[]isRefundable
boolean是
journeyitinerary[]offers[]price
object是
journeyitinerary[]offers[]priceamount
number是
journeyitinerary[]offers[]pricecurrency
string是
journeyitinerary[]offers[]createdAt
string
格式: ISO 8601
是
journeyitinerary[]offers[]expiresAt
string
格式: ISO 8601
是
journeystopovers
array是
journeystopovers[]stopoverIndex
number否
journeystopovers[]durationInMinutes
number否
journeyroute
array是
journeyroute[]itineraryIndex
number否
journeyroute[]stopoverIndex
number否
journeycomfortClasses
array是
journeycomfortClasses[]
enum[]是
journeyaccommodations
array是
journeyaccommodations[]
enum[]是
journeyticketClasses
array是
journeyticketClasses[]comfortClass
enum
basicstandardhighbestunknown
是
journeyticketClasses[]serviceClass
enum
basicstandardhighbestunknown
是

错误

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

使用说明

使用每个 offerId 调用预订端点。报价会过期,请在 expiresAt 之前继续预订流程。

cURL 示例

bash
bash
curl --request POST \
  --url "https://api.sandbox.travelandz.com/v1/trains/journeys/0/journey_123/offers?language=en&returnCancellationPolicies=true" \
  --header "Authorization: Bearer $TRAVELANDZ_SECRET_KEY" \
  --header "X-Travelandz-Id: $TRAVELANDZ_PUBLIC_KEY:$TRAVELANDZ_PROFILE_CODE" \
  --header "Content-Type: application/json" \
  --data '{"passengers":[{"type":"adult"}]}'