Skip to content

Instantly share code, notes, and snippets.

@noerw
Last active June 2, 2021 07:49
Show Gist options
  • Save noerw/03af8b9b954aa090722b9f89151b75fc to your computer and use it in GitHub Desktop.
Save noerw/03af8b9b954aa090722b9f89151b75fc to your computer and use it in GitHub Desktop.
curl https://apitest.vrsinfo.de:4443/trias -H 'Content-Type: text/xml' -d @trias-stop.xml -v
const trias = require("trias-client");
async function vrs () {
const client = trias.getClient({
url: 'https://apitest.vrsinfo.de:4443',
//requestorRef: "ecolibro",
})
const stopsResult = await client.getStops({
name: "Neumarkt",
//name: "Hauptbahnhof, Dresden",
})
console.log(stopsResult)
const stopsResult2 = await client.getStops({
//name: "Dresden Lugaer Platz",
name: "Köln Hauptbahnhof",
})
console.log(stopsResult2)
const { journeys } = await client.getJourneys({
origin: stopsResult.stops[0].id,
destination: stopsResult2.stops[0].id,
})
console.log(JSON.stringify(journeys[0].tickets, null, 2))
console.log(JSON.stringify(journeys[1].tickets, null, 2))
//const departuresResult = await client.getDepartures({
// id: stopsResult.stops[0].id
//})
//console.log(departuresResult)
}
async function dresden () {
const client = trias.getClient({
url: 'http://efa.vvo-online.de:8080/std3/trias',
requestorRef: "OpenService",
headers: { 'Content-Type': 'text/xml' },
})
const stopsResult = await client.getStops({
name: "Dresden Lugaer Platz",
//name: "Hauptbahnhof, Dresden",
})
const stopsResult2 = await client.getStops({
//name: "Dresden Lugaer Platz",
name: "Dresden Wiener Platz",
})
console.log(stopsResult2)
const { journeys } = await client.getJourneys({
origin: stopsResult.stops[0].id,
destination: stopsResult2.stops[0].id,
})
console.log(JSON.stringify(journeys[0].tickets, null, 2))
console.log(JSON.stringify(journeys[1].tickets, null, 2))
//const departuresResult = await client.getDepartures({
// id: stopsResult.stops[0].id
//})
//console.log(departuresResult)
}
(async () => {
try {
//await dresden()
await vrs()
} catch (err) {
console.error(err)
}
})()
<?xml version="1.0" encoding="UTF-8" ?>
<Trias version="1.2" xmlns="http://www.vdv.de/trias" xmlns:siri="http://www.siri.org.uk/siri" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://raw.githubusercontent.com/VDVde/TRIAS/v1.2/Trias.xsd">
<ServiceRequest>
<siri:RequestTimestamp>2021-06-02T09:44:35+02:00</siri:RequestTimestamp>
<siri:RequestorRef>foobar</siri:RequestorRef>
<RequestPayload>
<LocationInformationRequest>
<InitialInput>
<LocationName>Neumarkt</LocationName>
</InitialInput>
<Restrictions>
<Type>stop</Type>
<NumberOfResults>10</NumberOfResults>
</Restrictions>
</LocationInformationRequest>
</RequestPayload>
</ServiceRequest>
</Trias>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment