获取行程搜索返回的可预订报价。
认证和请求头
| 请求头 | 说明 |
|---|---|
Authorization | Bearer <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
{"passengers":[{"type":"adult"},{"type":"senior"}]}请求参数结构
gdsproviderCurrently
0journeyIdJourney id returned by the journey search.
请求查询参数模式
languagereturnCancellationPolicies请求体结构
passengerspassengers[]type成功响应
返回 journey 对象,其行程包含 offers[]。报价包括 offerId、parts、灵活性、等级、条件、取消政策和 { amount, currency } 价格。
响应体结构
journeyjourneygdsproviderjourneyjourneyIdjourneyitineraryjourneyitinerary[]itineraryIndexjourneyitinerary[]segmentsjourneyitinerary[]segments[]segmentIdjourneyitinerary[]segments[]departurejourneyitinerary[]segments[]departuredepartureAtjourneyitinerary[]segments[]departurenamejourneyitinerary[]segments[]departurelocationIdjourneyitinerary[]segments[]departurecountryjourneyitinerary[]segments[]departurecountryCodejourneyitinerary[]segments[]arrivaljourneyitinerary[]segments[]arrivalarrivalAtjourneyitinerary[]segments[]arrivalnamejourneyitinerary[]segments[]arrivallocationIdjourneyitinerary[]segments[]arrivalcountryjourneyitinerary[]segments[]arrivalcountryCodejourneyitinerary[]segments[]identifierjourneyitinerary[]segments[]transportjourneyitinerary[]segments[]durationInMinutesjourneyitinerary[]segments[]operatorjourneyitinerary[]segments[]operatorcodejourneyitinerary[]segments[]operatornamejourneyitinerary[]segments[]operatorimageUrljourneyitinerary[]segments[]servicejourneyitinerary[]segments[]servicenamejourneyitinerary[]segments[]serviceimageUrljourneyitinerary[]offersjourneyitinerary[]offers[]offerIdjourneyitinerary[]offers[]partsjourneyitinerary[]offers[]parts[]segmentsjourneyitinerary[]offers[]parts[]segments[]segmentIdjourneyitinerary[]offers[]parts[]segments[]amenitiesjourneyitinerary[]offers[]parts[]segments[]amenities[]journeyitinerary[]offers[]parts[]flexibilityjourneyitinerary[]offers[]parts[]comfortClassjourneyitinerary[]offers[]parts[]serviceClassjourneyitinerary[]offers[]parts[]conditionsjourneyitinerary[]offers[]parts[]conditions[]typejourneyitinerary[]offers[]parts[]conditions[]conditionjourneyitinerary[]offers[]parts[]conditions[]notejourneyitinerary[]offers[]parts[]conditions[]conditionKeyjourneyitinerary[]offers[]parts[]cancellationPoliciesjourneyitinerary[]offers[]parts[]cancellationPolicies[]__typenamejourneyitinerary[]offers[]parts[]cancellationPolicies[]__typenametypejourneyitinerary[]offers[]parts[]cancellationPolicies[]descriptionjourneyitinerary[]offers[]parts[]cancellationPolicies[]minimum_minutes_before_departurejourneyitinerary[]offers[]parts[]cancellationPolicies[]maximum_minutes_before_departurejourneyitinerary[]offers[]parts[]cancellationPolicies[]minimum_minutes_after_departurejourneyitinerary[]offers[]parts[]cancellationPolicies[]maximum_minutes_after_departurejourneyitinerary[]offers[]parts[]cancellationPolicies[]percentageWhen
__typename is CancellationByPercentagejourneyitinerary[]offers[]parts[]cancellationPolicies[]chargePercentageWhen
__typename is CancellationByPercentChargejourneyitinerary[]offers[]parts[]cancellationPolicies[]chargeAmountWhen
__typename is CancellationByFixedChargejourneyitinerary[]offers[]parts[]cancellationPolicies[]currencyWhen
__typename is CancellationByFixedChargejourneyitinerary[]offers[]parts[]cancellationPolicies[]perPersonWhen
__typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optionaljourneyitinerary[]offers[]parts[]cancellationPolicies[]perLegWhen
__typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optionaljourneyitinerary[]offers[]parts[]isRefundablejourneyitinerary[]offers[]pricejourneyitinerary[]offers[]priceamountjourneyitinerary[]offers[]pricecurrencyjourneyitinerary[]offers[]createdAtjourneyitinerary[]offers[]expiresAtjourneystopoversjourneystopovers[]stopoverIndexjourneystopovers[]durationInMinutesjourneyroutejourneyroute[]itineraryIndexjourneyroute[]stopoverIndexjourneycomfortClassesjourneycomfortClasses[]journeyaccommodationsjourneyaccommodations[]journeyticketClassesjourneyticketClasses[]comfortClassjourneyticketClasses[]serviceClass错误
400表示验证失败或存在未知字段。401或403表示 API 凭证无效。- 供应方失败时返回
500 internal_communication_error或unknown_error。 - 找不到报价时返回
404 zero_journeys_found。
使用说明
使用每个 offerId 调用预订端点。报价会过期,请在 expiresAt 之前继续预订流程。
cURL 示例
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"}]}'