POST/v1/trains/journeys/stream

Stream train journeys

Receive each matching train journey progressively as NDJSON.

Share

Receive each matching train journey progressively as NDJSON.

Authentication and headers

HeaderDescription
AuthorizationBearer <secret_key>. Keep the secret on the server and never write it to client logs.
X-Travelandz-Id<public_key>:<profile_code>, where the persisted profile code has the form dp_<12 alphanumeric>.
Acceptapplication/x-ndjson for progressive stream responses.
Content-Typeapplication/json for requests with a JSON body.

Request

Uses the same JSON body as POST /v1/trains/journeys.

Request Body Schema

origin
stringYes
Location id returned by /locations.
destination
stringYes
Location id returned by /locations.
date
string
Format: YYYY-MM-DD
Yes
passengers
arrayYes
passengers[]type
enum
youthadultsenior
Yes
youth = 0–27 years, adult = 28–59 years, senior = 60+ years.

Success response

The response is application/x-ndjson. Each non-error line is a complete journey object without a wrapper.

Response Body Schema

gdsprovider
numberYes
journeyId
stringYes
itinerary
arrayYes
itinerary[]itineraryIndex
numberYes
itinerary[]segments
arrayYes
itinerary[]segments[]segmentId
stringYes
itinerary[]segments[]departure
objectYes
itinerary[]segments[]departuredepartureAt
string
Format: ISO 8601
Yes
itinerary[]segments[]departurename
stringYes
itinerary[]segments[]departurelocationId
stringYes
itinerary[]segments[]departurecountry
stringYes
itinerary[]segments[]departurecountryCode
stringYes
itinerary[]segments[]arrival
objectYes
itinerary[]segments[]arrivalarrivalAt
string
Format: ISO 8601
Yes
itinerary[]segments[]arrivalname
stringYes
itinerary[]segments[]arrivallocationId
stringYes
itinerary[]segments[]arrivalcountry
stringYes
itinerary[]segments[]arrivalcountryCode
stringYes
itinerary[]segments[]identifier
stringYes
itinerary[]segments[]transport
enum
trainbusferry
Yes
itinerary[]segments[]durationInMinutes
numberYes
itinerary[]segments[]operator
objectYes
itinerary[]segments[]operatorcode
stringYes
itinerary[]segments[]operatorname
stringYes
itinerary[]segments[]operatorimageUrl
stringNullable
itinerary[]segments[]service
objectYes
itinerary[]segments[]servicename
stringNullable
itinerary[]segments[]serviceimageUrl
stringNullable
stopovers
arrayYes
stopovers[]stopoverIndex
numberNo
stopovers[]durationInMinutes
numberNo
route
arrayYes
route[]itineraryIndex
numberNo
route[]stopoverIndex
numberNo
comfortClasses
arrayYes
comfortClasses[]
enum[]Yes
accommodations
arrayYes
accommodations[]
enum[]Yes
ticketClasses
arrayYes
ticketClasses[]comfortClass
enum
basicstandardhighbestunknown
Yes
ticketClasses[]serviceClass
enum
basicstandardhighbestunknown
Yes

Errors

  • 400 for validation or unknown fields.
  • 401 or 403 for invalid API credentials.
  • 500 internal_communication_error or unknown_error for provider failures.
  • A stream error line can include error: true, code: zero_journeys_found, and statusCode: 404.

Usage notes

Read the response line by line and call JSON.parse for each line. Do not parse the stream as one JSON document.

cURL example

bash
bash
curl --request POST \
  --url "https://api.sandbox.travelandz.com/v1/trains/journeys/stream" \
  --header "Authorization: Bearer $TRAVELANDZ_SECRET_KEY" \
  --header "X-Travelandz-Id: $TRAVELANDZ_PUBLIC_KEY:$TRAVELANDZ_PROFILE_CODE" \
  --header "Accept: application/x-ndjson" \
  --data '{"origin":"originId","destination":"destinationId","date":"2026-08-20","passengers":[{"type":"adult"}]}'