Trip Search
HAFAS provides the TripSearch method to search for a connection from one place to another one.
Request Structure
The request is structured like a usual HAFAS request. Only the request body for the TripSearch part will be explained in this article.
The origin and destination of the trip are described in the depLocL and arrLocL array fields.
I don't know why they are arrays, I've never seen a case where there is more than one entry.
Request Structure: Location Structure
The DB Navigator mobile app always sends the full location object to hafas, but this is not needed.
Example (shortened)
{
"meth": "TripSearch",
"req": {
"arrLocL": [
{
"crd": {
"x": 8663003,
"y": 50106817
},
"extId": "8000105",
"lid": "A=1@O=Frankfurt(Main)Hbf@X=8663785@Y=50107149@U=80@L=8000105@B=1@p=1661198226@",
"name": "Frankfurt(Main)Hbf",
"type": "S"
}
],
"depLocL": [
{
"crd": {
"x": 6959197,
"y": 50942823
},
"extId": "8000207",
"lid": "A=1@O=Köln Hbf@X=6958730@Y=50943029@U=80@L=8000207@B=1@p=1659989485@",
"name": "Köln Hbf",
"type": "S"
}
]
}
}
After some research I found out that this is not needed.
HAFAS also works when just specifying the lid, name or the extId field.
With this it's possible to specify a station just by knowing its exact name or eva id.
Station by its eva id example
{
"meth": "TripSearch",
"req": {
"arrLocL": [
{
// Frankfurt(Main)Hbf
"extId": "8000105",
}
],
"depLocL": [
{
// Köln Hbf
"extId": "8000207",
}
]
}
}
Station by its exact name example
{
"meth": "TripSearch",
"req": {
"arrLocL": [
{
"name": "Frankfurt(Main)Hbf",
}
],
"depLocL": [
{
"name": "Köln Hbf",
}
]
}
}
Request Structure: getPasslist & getPolyline
The request contains 2 boolean fields called getPasslist and getPolyline.
These specify if the response should include the stopL and poly fields on journey objects. I think this is done for performance reasons, however DB Navigator always sets these to true.
Request Structure: Journey Filter
The request contains an array field called jnFltrL.
It only contains one object which allows filtering the types vehicles used in the connection. The bitmask information is documented in HAFAS Bitmasks.