Skip to content

Location & trip requests

These methods build TRIAS XML, POST it to your endpoint, parse the response, and return normalized results plus the raw parsed tree.

Search by name, restrict result types, and limit how many matches are returned:

const locations = await client.locationInformation({
locationName: "Karlsruhe Hauptbahnhof",
types: ["stop"],
numberOfResults: 5,
});
console.log(locations.results);

You can also pass locationRef instead of or together with locationName. Optional fields include includePtModes, continueAt, and numberOfResults.

Response shape: status, results (array of normalized locations with type, optional coordinates, raw), and raw (full parsed document).

Provide origin and destination as structured LocationRef values, and either a departure or arrival time:

const trips = await client.trip({
origin: {
type: "stopPoint",
ref: "de:08212:90",
name: "Karlsruhe Hauptbahnhof",
},
destination: {
type: "stopPoint",
ref: "de:08212:1011",
name: "KA Marktplatz (Pyramide U)",
},
departureTime: "2026-03-20T21:10:00+01:00",
numberOfResults: 3,
includeIntermediateStops: true,
});

LocationRef supports stopPoint, stopPlace, address, poi, locality, and geo (with latitude / longitude). Optional trip fields include via, arrivalTime, includeFares, includeOperatingDays, interchangeLimit, ignoreRealtimeData, and immediateTripStart.

Response shape: status, trips (normalized legs, stop calls, timing), and raw.

Useful for debugging, signing, or sending through another transport:

  • buildLocationInformationRequest(request, requestTimestamp?)
  • buildTripRequest(request, requestTimestamp?)

Both return a complete service-request XML string. requestTimestamp is optional (Date or ISO string).

raw(xml) posts arbitrary XML, returns { status, parsed, xml }, and applies the same HTTP and parse error handling as the high-level methods.