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 当前为 0journeyId 来自行程搜索。可选 query:languageeneszh)和 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 表示验证失败或存在未知字段。
  • 401403 表示 API 凭证无效。
  • 供应方失败时返回 500 internal_communication_errorunknown_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"}]}'