渐进接收行程报价、完成状态和取消政策分块。
认证和请求头
| 请求头 | 说明 |
|---|---|
Authorization | Bearer <secret_key>。密钥只能保存在服务器端,不能写入客户端日志。 |
X-Travelandz-Id | <public_key>:<profile_code>,持久化的 profile code 格式为 dp_<12 位字母数字>。 |
Accept | 渐进式 stream 响应使用 application/x-ndjson。 |
Content-Type | 带 JSON body 的请求使用 application/json。 |
请求
使用与非流式行程报价端点相同的 path、query 和 JSON body。
请求参数结构
gdsproviderCurrently
0journeyIdJourney id returned by the journey search.
请求查询参数模式
languagereturnCancellationPolicies请求体结构
passengerspassengers[]type成功响应
每个 NDJSON 行通过 type 区分:带 item 的 itinerary、offers_search_completed 或带 item 数组的 cancellation_policies。
响应体结构 (type=itinerary)
typeitemitemitineraryIndexitemsegmentsitemsegments[]segmentIditemsegments[]departureitemsegments[]departuredepartureAtitemsegments[]departurenameitemsegments[]departurelocationIditemsegments[]departurecountryitemsegments[]departurecountryCodeitemsegments[]arrivalitemsegments[]arrivalarrivalAtitemsegments[]arrivalnameitemsegments[]arrivallocationIditemsegments[]arrivalcountryitemsegments[]arrivalcountryCodeitemsegments[]identifieritemsegments[]transportitemsegments[]durationInMinutesitemsegments[]operatoritemsegments[]operatorcodeitemsegments[]operatornameitemsegments[]operatorimageUrlitemsegments[]serviceitemsegments[]servicenameitemsegments[]serviceimageUrlitemoffersitemoffers[]offerIditemoffers[]partsitemoffers[]parts[]segmentsitemoffers[]parts[]segments[]segmentIditemoffers[]parts[]segments[]amenitiesitemoffers[]parts[]segments[]amenities[]itemoffers[]parts[]flexibilityitemoffers[]parts[]comfortClassitemoffers[]parts[]serviceClassitemoffers[]parts[]conditionsitemoffers[]parts[]conditions[]typeitemoffers[]parts[]conditions[]conditionitemoffers[]parts[]conditions[]noteitemoffers[]parts[]conditions[]conditionKeyitemoffers[]parts[]cancellationPoliciesitemoffers[]parts[]cancellationPolicies[]__typenameitemoffers[]parts[]cancellationPolicies[]__typenametypeitemoffers[]parts[]cancellationPolicies[]descriptionitemoffers[]parts[]cancellationPolicies[]minimum_minutes_before_departureitemoffers[]parts[]cancellationPolicies[]maximum_minutes_before_departureitemoffers[]parts[]cancellationPolicies[]minimum_minutes_after_departureitemoffers[]parts[]cancellationPolicies[]maximum_minutes_after_departureitemoffers[]parts[]cancellationPolicies[]percentageWhen
__typename is CancellationByPercentageitemoffers[]parts[]cancellationPolicies[]chargePercentageWhen
__typename is CancellationByPercentChargeitemoffers[]parts[]cancellationPolicies[]chargeAmountWhen
__typename is CancellationByFixedChargeitemoffers[]parts[]cancellationPolicies[]currencyWhen
__typename is CancellationByFixedChargeitemoffers[]parts[]cancellationPolicies[]perPersonWhen
__typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optionalitemoffers[]parts[]cancellationPolicies[]perLegWhen
__typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optionalitemoffers[]parts[]isRefundableitemoffers[]priceitemoffers[]priceamountitemoffers[]pricecurrencyitemoffers[]createdAtitemoffers[]expiresAt,
响应体结构 (type=offers_search_completed)
type,
响应体结构 (type=cancellation_policies)
typeitemitem[]conditionKeyitem[]policiesitem[]policies[]__typenameitem[]policies[]__typenametypeitem[]policies[]descriptionitem[]policies[]minimum_minutes_before_departureitem[]policies[]maximum_minutes_before_departureitem[]policies[]minimum_minutes_after_departureitem[]policies[]maximum_minutes_after_departureitem[]policies[]percentageWhen
__typename is CancellationByPercentageitem[]policies[]chargePercentageWhen
__typename is CancellationByPercentChargeitem[]policies[]chargeAmountWhen
__typename is CancellationByFixedChargeitem[]policies[]currencyWhen
__typename is CancellationByFixedChargeitem[]policies[]perPersonWhen
__typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optionalitem[]policies[]perLegWhen
__typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optional,
响应体结构 (error=true)
errorcodestatusCode错误
400表示验证失败或存在未知字段。401或403表示 API 凭证无效。- 供应方失败时返回
500 internal_communication_error或unknown_error。 - 流错误对象包含
error: true、业务code和statusCode。
使用说明
使用 type 作为区分字段;并非每行都是行程结构。读取到 offers_search_completed,并单独保存政策分块。
cURL 示例
bash
curl --request POST \
--url "https://api.sandbox.travelandz.com/v1/trains/journeys/0/journey_123/offers/stream?language=en&returnCancellationPolicies=true" \
--header "Authorization: Bearer $TRAVELANDZ_SECRET_KEY" \
--header "X-Travelandz-Id: $TRAVELANDZ_PUBLIC_KEY:$TRAVELANDZ_PROFILE_CODE" \
--header "Accept: application/x-ndjson" \
--data '{"passengers":[{"type":"adult"}]}'