Skip to content

Generic API

Every TRIAS 1.2 service request name can be invoked with a plain object body that mirrors the XML structure you want under that request element. Subscription requests use the same idea with subscribe.

const rawResponse = await client.request("StopEventRequest", {
Location: {
LocationRef: {
StopPointRef: "de:08212:90",
LocationName: {
Text: "Karlsruhe Hauptbahnhof",
Language: "de",
},
},
DepArrTime: "2026-03-20T21:10:00+01:00",
},
});
console.log(rawResponse.parsed);

Return type: RawTriasResponse with status, parsed (typed as unknown unless you pass a generic), and xml (response body string).

await client.subscribe("TripMonitoringSubscriptionRequest", {
/* subscription body */
});

requestGeneric accepts { requestName, body } and delegates to request:

await client.requestGeneric({
requestName: "FacilityRequest",
body: { /* ... */ },
});
  • buildGenericServiceRequest(requestName, body, requestTimestamp?): ServiceRequest envelope
  • buildGenericSubscriptionRequest(requestName, body, requestTimestamp?): SubscriptionRequest envelope

Import these from trias-js to drive UI, validation, or exhaustiveness checks:

  • TRIAS_SERVICE_REQUESTS: all supported service request names (includes LocationInformationRequest, TripRequest, StopEventRequest, etc.)
  • TRIAS_SUBSCRIPTION_REQUESTS: subscription request names
  • TRIAS_VERSIONS: currently ["1.2"]

TypeScript types TriasServiceRequestName and TriasSubscriptionRequestName match those arrays.