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

Obtener ofertas en stream

Recibe progresivamente ofertas por itinerario, finalización y políticas de cancelación.

Compartir

Recibe progresivamente ofertas por itinerario, finalización y políticas de cancelación.

Autenticación y headers

HeaderDescripción
AuthorizationBearer <secret_key>. Conserva el secret en el servidor y nunca lo escribas en logs del cliente.
X-Travelandz-Id<public_key>:<profile_code>, donde el profile code persistido tiene el formato dp_<12 alfanuméricos>.
Acceptapplication/x-ndjson para respuestas progresivas en stream.
Content-Typeapplication/json para peticiones con body JSON.

Petición

Usa el mismo path, query y body JSON que el endpoint de ofertas sin stream.

Schema de parámetros

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

Schema de query params

language
enum
eneszh
No
returnCancellationPolicies
booleanNo

Schema del body

passengers
array
passengers[]type
enum
youthadultsenior

Respuesta exitosa

Cada línea NDJSON se discrimina por type: itinerary con un item, offers_search_completed o cancellation_policies con un array item.

Schema de respuesta (type=itinerary)

type
enum
itinerary
item
object
itemitineraryIndex
number
itemsegments
array
itemsegments[]segmentId
string
itemsegments[]departure
object
itemsegments[]departuredepartureAt
string
Formato: ISO 8601
itemsegments[]departurename
string
itemsegments[]departurelocationId
string
itemsegments[]departurecountry
string
itemsegments[]departurecountryCode
string
itemsegments[]arrival
object
itemsegments[]arrivalarrivalAt
string
Formato: ISO 8601
itemsegments[]arrivalname
string
itemsegments[]arrivallocationId
string
itemsegments[]arrivalcountry
string
itemsegments[]arrivalcountryCode
string
itemsegments[]identifier
string
itemsegments[]transport
enum
trainbusferry
itemsegments[]durationInMinutes
number
itemsegments[]operator
object
itemsegments[]operatorcode
string
itemsegments[]operatorname
string
itemsegments[]operatorimageUrl
stringNullable
itemsegments[]service
object
itemsegments[]servicename
stringNullable
itemsegments[]serviceimageUrl
stringNullable
itemoffers
array
itemoffers[]offerId
string
itemoffers[]parts
array
itemoffers[]parts[]segments
array
itemoffers[]parts[]segments[]segmentId
string
itemoffers[]parts[]segments[]amenities
array
itemoffers[]parts[]segments[]amenities[]
string[]
itemoffers[]parts[]flexibility
enum
non_flexsemi_flexfull_flex
itemoffers[]parts[]comfortClass
enum
basicstandardhighbestunknown
itemoffers[]parts[]serviceClass
enum
basicstandardhighbestunknown
itemoffers[]parts[]conditions
array
itemoffers[]parts[]conditions[]type
string
itemoffers[]parts[]conditions[]condition
string
itemoffers[]parts[]conditions[]note
stringNo
itemoffers[]parts[]conditions[]conditionKey
string
itemoffers[]parts[]cancellationPolicies
array
itemoffers[]parts[]cancellationPolicies[]__typename
object
itemoffers[]parts[]cancellationPolicies[]__typenametype
enum
CancellationByPercentageCancellationByPercentChargeCancellationByFixedChargeFullCancellableNonCancellable
itemoffers[]parts[]cancellationPolicies[]description
stringNo
itemoffers[]parts[]cancellationPolicies[]minimum_minutes_before_departure
numberNo
itemoffers[]parts[]cancellationPolicies[]maximum_minutes_before_departure
numberNo
itemoffers[]parts[]cancellationPolicies[]minimum_minutes_after_departure
numberNo
itemoffers[]parts[]cancellationPolicies[]maximum_minutes_after_departure
numberNo
itemoffers[]parts[]cancellationPolicies[]percentage
numberNo
When __typename is CancellationByPercentage
itemoffers[]parts[]cancellationPolicies[]chargePercentage
numberNo
When __typename is CancellationByPercentCharge
itemoffers[]parts[]cancellationPolicies[]chargeAmount
numberNo
When __typename is CancellationByFixedCharge
itemoffers[]parts[]cancellationPolicies[]currency
string
Formato: ISO 4217 code
No
When __typename is CancellationByFixedCharge
itemoffers[]parts[]cancellationPolicies[]perPerson
booleanNo
When __typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optional
itemoffers[]parts[]cancellationPolicies[]perLeg
booleanNo
When __typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optional
itemoffers[]parts[]isRefundable
boolean
itemoffers[]price
object
itemoffers[]priceamount
number
itemoffers[]pricecurrency
string
itemoffers[]createdAt
string
Formato: ISO 8601
itemoffers[]expiresAt
string
Formato: ISO 8601

,

Schema de respuesta (type=offers_search_completed)

type
enum
offers_search_completed

,

Schema de respuesta (type=cancellation_policies)

type
enum
cancellation_policies
item
array
item[]conditionKey
string
item[]policies
array
item[]policies[]__typename
object
item[]policies[]__typenametype
enum
CancellationByPercentageCancellationByPercentChargeCancellationByFixedChargeFullCancellableNonCancellable
item[]policies[]description
stringNo
item[]policies[]minimum_minutes_before_departure
numberNo
item[]policies[]maximum_minutes_before_departure
numberNo
item[]policies[]minimum_minutes_after_departure
numberNo
item[]policies[]maximum_minutes_after_departure
numberNo
item[]policies[]percentage
numberNo
When __typename is CancellationByPercentage
item[]policies[]chargePercentage
numberNo
When __typename is CancellationByPercentCharge
item[]policies[]chargeAmount
numberNo
When __typename is CancellationByFixedCharge
item[]policies[]currency
string
Formato: ISO 4217 code
No
When __typename is CancellationByFixedCharge
item[]policies[]perPerson
booleanNo
When __typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optional
item[]policies[]perLeg
booleanNo
When __typename is CancellationByPercentCharge or CancellationByFixedCharge. Is optional

,

Schema de respuesta (error=true)

error
boolean
code
string
statusCode
number

Errores

  • 400 por validación o campos desconocidos.
  • 401 o 403 por credenciales API inválidas.
  • 500 internal_communication_error o unknown_error por fallos del proveedor.
  • Los errores del stream usan un objeto con error: true, un code de negocio y statusCode.

Notas de uso

Usa type como discriminador; no todas las líneas tienen forma de itinerario. Consume hasta offers_search_completed y conserva las políticas por separado.

Ejemplo cURL

bash
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"}]}'