Hafas Bitmasks

These are the bitmasks used in the DB Hafas.

Vehicle SelectionBitmask
All vehicles11111111111111
"ICE trains"10000000001111
"Intercity and Eurocity trains"01000000001111
"Interregio and fast trains"00100000001111
"Regional and local trains"00010000001111
"S-Bahn"00001000001111
"Bus"00000100001111
"Boat"00000010001111
"Underground"00000001001111
"Tram"00000000101111
"Traffic services requiring tel. registration for passengers"00000000011111

Station Search

HAFAS provides an endpoint to search for a place where vehicles can stop. Marudor provides the endpoint HAFAS/StopPlaceSearch/v1 for that.

Example Request

This is an example request recorded with mitmproxy on an Android Virtual Device using DB Navigator 22.06.p02.00.

{
  "auth": {
    "aid": "n91dB8Z77MLdoR0K",
    "type": "AID"
  },
  "client": {
    "id": "DB",
    "name": "DB Navigator",
    "os": "Android 12",
    "res": "1080x2072",
    "type": "AND",
    "ua": "Dalvik/2.1.0 (Linux; U; Android 12; sdk_gphone64_x86_64 Build/SE1A.220203.002.A1)",
    "v": 22060000
  },
  "ext": "DB.R22.04.a",
  "formatted": false,
  "lang": "eng",
  "svcReqL": [
    {
      "cfg": {
        "polyEnc": "GPA"
      },
      "meth": "LocMatch",
      "req": {
        "input": {
          "field": "S",
          "loc": {
            "name": "Köln?"
          },
          "maxLoc": 25
        }
      }
    }
  ],
  "ver": "1.15"
}

Todo

  • Find out unknown words.
    • svcReqL
    • polyEnc

Response (Shortened)

This is the response of the example request shown above.

{
  "cInfo": {
    "code": "OK"
  },
  "ext": "DB.R22.04.a",
  "id": "t8wu5gx2iw4mp64k",
  "lang": "eng",
  "svcResL": [
    {
      "err": "OK",
      "meth": "LocMatch",
      "res": {
        "common": {
          "crdSysL": [
            {
              "dim": 2,
              "id": "standard",
              "index": 0,
              "type": "WGS84"
            }
          ],
          "icoL": [
            {
              "res": "ICE"
            },
            {
              "res": "THA"
            },
            {
              "res": "EC"
            },
            {
              "res": "IC"
            },
            {
              "res": "NJ"
            },
            {
              "res": "DPF"
            },
            {
              "res": "Bus"
            },
            {
              "res": "DPN"
            },
            {
              "res": "RB"
            },
            {
              "res": "RE"
            },
            {
              "res": "S"
            },
            {
              "res": "STR"
            },
            {
              "res": "AST"
            },
            {
              "res": "LT"
            }
          ],
          "layerL": [
            {
              "annoCnt": 0,
              "id": "standard",
              "index": 0,
              "name": "standard"
            }
          ],
          "locL": [],
          "opL": [],
          "polyL": [],
          "prodL": [
            {
              "cls": 1,
              "icoX": 0,
              "name": "ICE"
            },
            {
              "cls": 1,
              "icoX": 1,
              "name": "THA"
            },
            {
              "cls": 2,
              "icoX": 2,
              "name": "EC"
            },
            {
              "cls": 2,
              "icoX": 3,
              "name": "IC"
            },
            {
              "cls": 2,
              "icoX": 4,
              "name": "NJ"
            },
            {
              "cls": 4,
              "icoX": 5,
              "name": "FLX"
            },
            {
              "cls": 4,
              "icoX": 5,
              "name": "MSM"
            },
            {
              "cls": 4,
              "icoX": 5,
              "name": "UEX"
            },
            {
              "cls": 8,
              "icoX": 6,
              "name": "Bus S6",
              "nameS": "S6",
              "prodCtx": {
                "lineId": "3_B2_____S6"
              }
            },
            {
              "cls": 8,
              "icoX": 6,
              "name": "Bus RE1",
              "nameS": "RE1",
              "prodCtx": {
                "lineId": "3_AR_____RE1"
              }
            },
            {
              "cls": 8,
              "icoX": 6,
              "name": "Bus SEV",
              "nameS": "SEV",
              "prodCtx": {
                "lineId": "3_B2_____SEV!!753782!!5721278"
              }
            },
            {
              "cls": 8,
              "icoX": 6,
              "name": "Bus S 11",
              "nameS": "S 11",
              "prodCtx": {
                "lineId": "3_B2_____S11"
              }
            },
            {
              "cls": 8,
              "icoX": 6,
              "name": "BusSEV B",
              "nameS": "SEV B",
              "prodCtx": {
                "lineId": "3_B2_____SEVB!!774312!!5667114"
              }
            },
            {
              "cls": 8,
              "icoX": 7,
              "name": "RB"
            },
            {
              "cls": 8,
              "icoX": 8,
              "name": "RB"
            },
            {
              "cls": 8,
              "icoX": 7,
              "name": "RE"
            },
            {
              "cls": 8,
              "icoX": 9,
              "name": "RE"
            },
            {
              "cls": 8,
              "icoX": 7,
              "name": "TRI"
            },
            {
              "cls": 16,
              "icoX": 10,
              "name": "S 6",
              "nameS": "6",
              "prodCtx": {
                "lineId": "4_800337_6"
              }
            },
            {
              "cls": 16,
              "icoX": 10,
              "name": "S 11",
              "nameS": "11",
              "prodCtx": {
                "lineId": "4_8003S__11"
              }
            },
            {
              "cls": 16,
              "icoX": 10,
              "name": "S 12",
              "nameS": "12",
              "prodCtx": {
                "lineId": "4_8003S__12"
              }
            },
            {
              "cls": 16,
              "icoX": 10,
              "name": "S 19",
              "nameS": "19",
              "prodCtx": {
                "lineId": "4_8003S__19"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 124",
              "nameS": "124",
              "prodCtx": {
                "lineId": "5_vrs001_124"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 132",
              "nameS": "132",
              "prodCtx": {
                "lineId": "5_vrs001_132"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 133",
              "nameS": "133",
              "prodCtx": {
                "lineId": "5_vrs001_133"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 171",
              "nameS": "171",
              "prodCtx": {
                "lineId": "5_vrs001_171"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 172",
              "nameS": "172",
              "prodCtx": {
                "lineId": "5_vrs001_172"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 173",
              "nameS": "173",
              "prodCtx": {
                "lineId": "5_vrs001_173"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 250",
              "nameS": "250",
              "prodCtx": {
                "lineId": "5_vrs003_250"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 260",
              "nameS": "260",
              "prodCtx": {
                "lineId": "5_vrs016_260"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 978",
              "nameS": "978",
              "prodCtx": {
                "lineId": "5_vrs017_978"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus N26",
              "nameS": "N26",
              "prodCtx": {
                "lineId": "5_vrs016_N26"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus SB40",
              "nameS": "SB40",
              "prodCtx": {
                "lineId": "5_vrs014_SB40"
              }
            },
            {
              "cls": 256,
              "icoX": 11,
              "name": "STR 5",
              "nameS": "5",
              "prodCtx": {
                "lineId": "8_vrs001_5"
              }
            },
            {
              "cls": 256,
              "icoX": 11,
              "name": "STR E",
              "nameS": "E",
              "prodCtx": {
                "lineId": "8_vrs001_E"
              }
            },
            {
              "cls": 256,
              "icoX": 11,
              "name": "STR 16",
              "nameS": "16",
              "prodCtx": {
                "lineId": "8_vrs001_16"
              }
            },
            {
              "cls": 256,
              "icoX": 11,
              "name": "STR 18",
              "nameS": "18",
              "prodCtx": {
                "lineId": "8_vrs001_18"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 103",
              "nameS": "103",
              "prodCtx": {
                "lineId": "5_vrs001_103"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 104",
              "nameS": "104",
              "prodCtx": {
                "lineId": "5_vrs001_104"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 150",
              "nameS": "150",
              "prodCtx": {
                "lineId": "5_vrs001_150"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 153",
              "nameS": "153",
              "prodCtx": {
                "lineId": "5_vrs001_153"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 179",
              "nameS": "179",
              "prodCtx": {
                "lineId": "5_vrs001_179"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 196",
              "nameS": "196",
              "prodCtx": {
                "lineId": "5_vrs001_196"
              }
            },
            {
              "cls": 256,
              "icoX": 11,
              "name": "STR 1",
              "nameS": "1",
              "prodCtx": {
                "lineId": "8_vrs001_1"
              }
            },
            {
              "cls": 256,
              "icoX": 11,
              "name": "STR 3",
              "nameS": "3",
              "prodCtx": {
                "lineId": "8_vrs001_3"
              }
            },
            {
              "cls": 256,
              "icoX": 11,
              "name": "STR 4",
              "nameS": "4",
              "prodCtx": {
                "lineId": "8_vrs001_4"
              }
            },
            {
              "cls": 256,
              "icoX": 11,
              "name": "STR 9",
              "nameS": "9",
              "prodCtx": {
                "lineId": "8_vrs001_9"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 161",
              "nameS": "161",
              "prodCtx": {
                "lineId": "5_vrs001_161"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 423",
              "nameS": "423",
              "prodCtx": {
                "lineId": "5_vrs014_423"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus SB60",
              "nameS": "SB60",
              "prodCtx": {
                "lineId": "5_vrs006_SB60"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 127",
              "nameS": "127",
              "prodCtx": {
                "lineId": "5_vrs001_127"
              }
            },
            {
              "cls": 256,
              "icoX": 11,
              "name": "STR 12",
              "nameS": "12",
              "prodCtx": {
                "lineId": "8_vrs001_12"
              }
            },
            {
              "cls": 256,
              "icoX": 11,
              "name": "STR 15",
              "nameS": "15",
              "prodCtx": {
                "lineId": "8_vrs001_15"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 151",
              "nameS": "151",
              "prodCtx": {
                "lineId": "5_vrs001_151"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 152",
              "nameS": "152",
              "prodCtx": {
                "lineId": "5_vrs001_152"
              }
            },
            {
              "cls": 256,
              "icoX": 11,
              "name": "STR 13",
              "nameS": "13",
              "prodCtx": {
                "lineId": "8_vrs001_13"
              }
            },
            {
              "cls": 8,
              "icoX": 6,
              "name": "Bus SEV",
              "nameS": "SEV",
              "prodCtx": {
                "lineId": "3_B2_____SEV!!769509!!5668075"
              }
            },
            {
              "cls": 8,
              "icoX": 6,
              "name": "BusSEV A",
              "nameS": "SEV A",
              "prodCtx": {
                "lineId": "3_B2_____SEVA!!769509!!5668075"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 141",
              "nameS": "141",
              "prodCtx": {
                "lineId": "5_vrs001_141"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 142",
              "nameS": "142",
              "prodCtx": {
                "lineId": "5_vrs001_142"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 143",
              "nameS": "143",
              "prodCtx": {
                "lineId": "5_vrs001_143"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 159",
              "nameS": "159",
              "prodCtx": {
                "lineId": "5_vrs001_159"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 160",
              "nameS": "160",
              "prodCtx": {
                "lineId": "5_vrs001_160"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 162",
              "nameS": "162",
              "prodCtx": {
                "lineId": "5_vrs001_162"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 165",
              "nameS": "165",
              "prodCtx": {
                "lineId": "5_vrs001_165"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 166",
              "nameS": "166",
              "prodCtx": {
                "lineId": "5_vrs001_166"
              }
            },
            {
              "cls": 512,
              "icoX": 12,
              "name": "AST 185",
              "nameS": "185",
              "prodCtx": {
                "lineId": "9_vrs001_185"
              }
            },
            {
              "cls": 512,
              "icoX": 12,
              "name": "AST 188",
              "nameS": "188",
              "prodCtx": {
                "lineId": "9_vrs001_188"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 155",
              "nameS": "155",
              "prodCtx": {
                "lineId": "5_vrs001_155"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 156",
              "nameS": "156",
              "prodCtx": {
                "lineId": "5_vrs001_156"
              }
            },
            {
              "cls": 8,
              "icoX": 6,
              "name": "Bus SEV",
              "nameS": "SEV",
              "prodCtx": {
                "lineId": "3_NX_____SEV!!771821!!5665379"
              }
            },
            {
              "cls": 32,
              "icoX": 13,
              "name": "LT SEV",
              "nameS": "SEV",
              "prodCtx": {
                "lineId": "5_NX_____SEV"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 120",
              "nameS": "120",
              "prodCtx": {
                "lineId": "5_vrs001_120"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 121",
              "nameS": "121",
              "prodCtx": {
                "lineId": "5_vrs001_121"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 122",
              "nameS": "122",
              "prodCtx": {
                "lineId": "5_vrs001_122"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 123",
              "nameS": "123",
              "prodCtx": {
                "lineId": "5_vrs001_123"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 125",
              "nameS": "125",
              "prodCtx": {
                "lineId": "5_vrs001_125"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 126",
              "nameS": "126",
              "prodCtx": {
                "lineId": "5_vrs001_126"
              }
            },
            {
              "cls": 512,
              "icoX": 12,
              "name": "AST 181",
              "nameS": "181",
              "prodCtx": {
                "lineId": "9_vrs001_181"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 140",
              "nameS": "140",
              "prodCtx": {
                "lineId": "5_vrs001_140"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 147",
              "nameS": "147",
              "prodCtx": {
                "lineId": "5_vrs001_147"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 961",
              "nameS": "961",
              "prodCtx": {
                "lineId": "5_vrs017_961"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 965",
              "nameS": "965",
              "prodCtx": {
                "lineId": "5_vrs017_965"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 972",
              "nameS": "972",
              "prodCtx": {
                "lineId": "5_vrs017_972"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus SB91",
              "nameS": "SB91",
              "prodCtx": {
                "lineId": "5_vrs017_SB91"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 139",
              "nameS": "139",
              "prodCtx": {
                "lineId": "5_vrs001_139"
              }
            },
            {
              "cls": 512,
              "icoX": 12,
              "name": "AST 180",
              "nameS": "180",
              "prodCtx": {
                "lineId": "9_vrs001_180"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 136",
              "nameS": "136",
              "prodCtx": {
                "lineId": "5_vrs001_136"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 144",
              "nameS": "144",
              "prodCtx": {
                "lineId": "5_vrs001_144"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 145",
              "nameS": "145",
              "prodCtx": {
                "lineId": "5_vrs001_145"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 148",
              "nameS": "148",
              "prodCtx": {
                "lineId": "5_vrs001_148"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 149",
              "nameS": "149",
              "prodCtx": {
                "lineId": "5_vrs001_149"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 949",
              "nameS": "949",
              "prodCtx": {
                "lineId": "5_vrs017_949"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 967",
              "nameS": "967",
              "prodCtx": {
                "lineId": "5_vrs017_967"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 163",
              "nameS": "163",
              "prodCtx": {
                "lineId": "5_vrs008_163"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 164",
              "nameS": "164",
              "prodCtx": {
                "lineId": "5_vrs001_164"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 167",
              "nameS": "167",
              "prodCtx": {
                "lineId": "5_vrs001_167"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 505",
              "nameS": "505",
              "prodCtx": {
                "lineId": "5_vrs008_505"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 885",
              "nameS": "885",
              "prodCtx": {
                "lineId": "5_vrr088_885"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 980",
              "nameS": "980",
              "prodCtx": {
                "lineId": "5_vrs017_980"
              }
            },
            {
              "cls": 32,
              "icoX": 6,
              "name": "Bus 885E",
              "nameS": "885E",
              "prodCtx": {
                "lineId": "5_vrr088_885E"
              }
            }
          ],
          "remL": []
        },
        "match": {
          "field": "S",
          "locL": [
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6967206,
                "y": 50941312
              },
              "extId": "8096022",
              "icoX": 0,
              "lid": "A=1@O=KÖLN@X=6967206@Y=50941312@U=80@L=8096022@B=1@p=1659382252@",
              "meta": true,
              "name": "KÖLN",
              "pCls": 319,
              "pRefL": [
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
                18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
                34, 35, 36
              ],
              "state": "F",
              "type": "S",
              "wt": 30129
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6959197,
                "y": 50942823,
                "z": 0
              },
              "extId": "8000207",
              "icoX": 0,
              "lid": "A=1@O=Köln Hbf@X=6958730@Y=50943029@U=80@L=8000207@B=1@p=1659382252@",
              "name": "Köln Hbf",
              "pCls": 319,
              "pRefL": [
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
                18, 19, 20, 21, 26, 27, 33, 34, 35, 36
              ],
              "state": "F",
              "type": "S",
              "wt": 30129
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6974578,
                "y": 50940989,
                "z": 0
              },
              "extId": "8003368",
              "icoX": 0,
              "lid": "A=1@O=Köln Messe/Deutz@X=6975000@Y=50940872@U=80@L=8003368@B=1@p=1659382252@",
              "name": "Köln Messe/Deutz",
              "pCls": 319,
              "pRefL": [
                0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19,
                20, 21, 37, 38, 39, 40, 41, 42, 28, 29, 31, 43, 44, 45, 46, 34
              ],
              "state": "F",
              "type": "S",
              "wt": 25875
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 7119259,
                "y": 50878909,
                "z": 0
              },
              "extId": "8003330",
              "icoX": 0,
              "lid": "A=1@O=Köln/Bonn Flughafen@X=7119304@Y=50878900@U=80@L=8003330@B=1@p=1659382252@",
              "name": "Köln/Bonn Flughafen",
              "pCls": 57,
              "pRefL": [0, 10, 13, 14, 15, 21, 47, 48, 49],
              "state": "F",
              "type": "S",
              "wt": 9160
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6952698,
                "y": 50949124,
                "z": 0
              },
              "extId": "8003392",
              "icoX": 6,
              "lid": "A=1@O=Köln Hansaring@X=6952563@Y=50949133@U=80@L=8003392@B=1@p=1659382252@",
              "name": "Köln Hansaring",
              "pCls": 312,
              "pRefL": [10, 11, 14, 18, 19, 20, 21, 50, 51, 52],
              "state": "F",
              "type": "S",
              "wt": 8578
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 7013069,
                "y": 50957637,
                "z": 0
              },
              "extId": "8000209",
              "icoX": 6,
              "lid": "A=1@O=Köln-Mülheim@X=7013294@Y=50957987@U=80@L=8000209@B=1@p=1659382252@",
              "name": "Köln-Mülheim",
              "pCls": 312,
              "pRefL": [8, 9, 10, 13, 15, 17, 18, 19, 39, 53, 54, 40, 55, 36],
              "state": "F",
              "type": "S",
              "wt": 8578
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6917244,
                "y": 50951605,
                "z": 0
              },
              "extId": "8000208",
              "icoX": 0,
              "lid": "A=1@O=Köln-Ehrenfeld@X=6917280@Y=50951533@U=80@L=8000208@B=1@p=1659382252@",
              "name": "Köln-Ehrenfeld",
              "pCls": 317,
              "pRefL": [0, 5, 56, 57, 14, 15, 16, 17, 20, 21, 58, 59, 60],
              "state": "F",
              "type": "S",
              "wt": 8295
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6996754,
                "y": 50935910,
                "z": 0
              },
              "extId": "8003320",
              "icoX": 8,
              "lid": "A=1@O=Köln Trimbornstr@X=6996736@Y=50935856@U=80@L=8003320@B=1@p=1659382252@",
              "name": "Köln Trimbornstr",
              "pCls": 312,
              "pRefL": [14, 20, 21, 61],
              "state": "F",
              "type": "S",
              "wt": 7928
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 7065989,
                "y": 50880105,
                "z": 0
              },
              "extId": "8004869",
              "icoX": 6,
              "lid": "A=1@O=Köln-Porz(Rhein)@X=7064721@Y=50882910@U=80@L=8004869@B=1@p=1659382252@",
              "name": "Köln-Porz(Rhein)",
              "pCls": 824,
              "pRefL": [10, 14, 16, 20, 53, 54, 62, 47, 63, 64, 65, 66, 67],
              "state": "F",
              "type": "S",
              "wt": 6038
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 7051157,
                "y": 50915361,
                "z": 0
              },
              "extId": "8003358",
              "icoX": 6,
              "lid": "A=1@O=Köln Frankfurter Straße@X=7051264@Y=50915217@U=80@L=8003358@B=1@p=1659382252@",
              "name": "Köln Frankfurter Straße",
              "pCls": 56,
              "pRefL": [10, 14, 21, 53, 54],
              "state": "F",
              "type": "S",
              "wt": 5994
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 7001986,
                "y": 50990025,
                "z": 0
              },
              "extId": "8003310",
              "icoX": 6,
              "lid": "A=1@O=Köln-Stammheim@X=7002093@Y=50990070@U=80@L=8003310@B=1@p=1659382252@",
              "name": "Köln-Stammheim",
              "pCls": 56,
              "pRefL": [8, 10, 18, 53, 54, 40, 68, 69],
              "state": "F",
              "type": "S",
              "wt": 5994
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6938486,
                "y": 50927002,
                "z": 0
              },
              "extId": "8003361",
              "icoX": 0,
              "lid": "A=1@O=Köln Süd@X=6938063@Y=50927298@U=80@L=8003361@B=1@p=1659382252@",
              "name": "Köln Süd",
              "pCls": 303,
              "pRefL": [0, 3, 5, 70, 13, 14, 15, 16, 17, 59, 71, 46, 34],
              "state": "F",
              "type": "S",
              "wt": 5913
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6933892,
                "y": 50943650,
                "z": 0
              },
              "extId": "8003363",
              "icoX": 6,
              "lid": "A=1@O=Köln West@X=6934387@Y=50943668@U=80@L=8003363@B=1@p=1659382252@",
              "name": "Köln West",
              "pCls": 296,
              "pRefL": [70, 13, 14, 16, 26, 27, 71, 44, 45, 33, 35, 36],
              "state": "F",
              "type": "S",
              "wt": 5384
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6897953,
                "y": 51021038,
                "z": 0
              },
              "extId": "8003365",
              "icoX": 6,
              "lid": "A=1@O=Köln-Chorweiler@X=6897828@Y=51021128@U=80@L=8003365@B=1@p=1659382252@",
              "name": "Köln-Chorweiler",
              "pCls": 824,
              "pRefL": [11, 18, 19, 72, 73, 74, 75, 76, 77, 52, 78],
              "state": "F",
              "type": "S",
              "wt": 4945
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6941416,
                "y": 50968568,
                "z": 0
              },
              "extId": "8003360",
              "icoX": 6,
              "lid": "A=1@O=Köln Geldernstr./Parkgürtel@X=6941416@Y=50968550@U=80@L=8003360@B=1@p=1659382252@",
              "name": "Köln Geldernstr./Parkgürtel",
              "pCls": 312,
              "pRefL": [11, 18, 19, 73, 50, 79, 80, 55],
              "state": "F",
              "type": "S",
              "wt": 4902
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6814956,
                "y": 50940872,
                "z": 0
              },
              "extId": "8003383",
              "icoX": 6,
              "lid": "A=1@O=Köln-Weiden West@X=6815136@Y=50940899@U=80@L=8003383@B=1@p=1659382252@",
              "name": "Köln-Weiden West",
              "pCls": 312,
              "pRefL": [56, 20, 21, 81, 82, 83, 84, 43],
              "state": "F",
              "type": "S",
              "wt": 4902
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6881413,
                "y": 51037569,
                "z": 0
              },
              "extId": "8079140",
              "icoX": 6,
              "lid": "A=1@O=Köln-Blumenberg@X=6881917@Y=51037416@U=80@L=8079140@B=1@p=1659382252@",
              "name": "Köln-Blumenberg",
              "pCls": 568,
              "pRefL": [11, 18, 19, 72, 78],
              "state": "F",
              "type": "S",
              "wt": 4296
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6901801,
                "y": 50997846,
                "z": 0
              },
              "extId": "8003371",
              "icoX": 6,
              "lid": "A=1@O=Köln-Longerich@X=6901558@Y=50997738@U=80@L=8003371@B=1@p=1659382252@",
              "name": "Köln-Longerich",
              "pCls": 568,
              "pRefL": [11, 18, 19, 73, 76, 50, 85, 86],
              "state": "F",
              "type": "S",
              "wt": 4296
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 7004359,
                "y": 50953484,
                "z": 0
              },
              "extId": "8003364",
              "icoX": 6,
              "lid": "A=1@O=Köln-Buchforst@X=7004323@Y=50953484@U=80@L=8003364@B=1@p=1659382252@",
              "name": "Köln-Buchforst",
              "pCls": 312,
              "pRefL": [8, 10, 18, 19, 61, 25],
              "state": "F",
              "type": "S",
              "wt": 4252
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6834606,
                "y": 50942921,
                "z": 0
              },
              "extId": "8003732",
              "icoX": 6,
              "lid": "A=1@O=Köln-Lövenich@X=6834436@Y=50942930@U=80@L=8003732@B=1@p=1659382252@",
              "name": "Köln-Lövenich",
              "pCls": 56,
              "pRefL": [56, 20, 21, 87, 58, 60, 88, 89, 90, 91, 26, 92, 93],
              "state": "F",
              "type": "S",
              "wt": 4252
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6888173,
                "y": 50948423,
                "z": 0
              },
              "extId": "8003375",
              "icoX": 6,
              "lid": "A=1@O=Köln-Müngersdorf Technologiepark@X=6888200@Y=50948396@U=80@L=8003375@B=1@p=1659382252@",
              "name": "Köln-Müngersdorf Technologiepark",
              "pCls": 56,
              "pRefL": [56, 20, 21, 85, 79, 88],
              "state": "F",
              "type": "S",
              "wt": 4252
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6921829,
                "y": 50984470,
                "z": 0
              },
              "extId": "8003372",
              "icoX": 6,
              "lid": "A=1@O=Köln-Nippes@X=6941605@Y=50958662@U=80@L=8003372@B=1@p=1659382252@",
              "name": "Köln-Nippes",
              "pCls": 56,
              "pRefL": [10, 11, 18, 19, 50, 59],
              "state": "F",
              "type": "S",
              "wt": 4252
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 7079239,
                "y": 50858126,
                "z": 0
              },
              "extId": "8004873",
              "icoX": 6,
              "lid": "A=1@O=Köln-Porz-Wahn@X=7079266@Y=50858135@U=80@L=8004873@B=1@p=1659382252@",
              "name": "Köln-Porz-Wahn",
              "pCls": 56,
              "pRefL": [10, 20, 21, 62, 63, 94, 95, 96, 97],
              "state": "F",
              "type": "S",
              "wt": 4252
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6893486,
                "y": 51014817,
                "z": 0
              },
              "extId": "8003362",
              "icoX": 6,
              "lid": "A=1@O=Köln Volkhovener Weg@X=6893243@Y=51014251@U=80@L=8003362@B=1@p=1659382252@",
              "name": "Köln Volkhovener Weg",
              "pCls": 56,
              "pRefL": [11, 18, 19, 73, 77],
              "state": "F",
              "type": "S",
              "wt": 4252
            },
            {
              "crd": {
                "crdSysX": 0,
                "layerX": 0,
                "type": "WGS84",
                "x": 6851920,
                "y": 51052356,
                "z": 0
              },
              "extId": "8003373",
              "icoX": 6,
              "lid": "A=1@O=Köln-Worringen@X=6851722@Y=51052374@U=80@L=8003373@B=1@p=1659382252@",
              "name": "Köln-Worringen",
              "pCls": 56,
              "pRefL": [10, 11, 18, 19, 72, 75, 98, 99, 100, 84],
              "state": "F",
              "type": "S",
              "wt": 4252
            }
          ],
          "state": "L"
        }
      }
    }
  ],
  "ver": "1.15"
}

Days of Operation

As described in the HAFAS Raw data file format documentation, the days of operation of a service are at first a bit field with the length of the timetable period. To shorten this, 4 bits are combined in one hexadecimal digit, which are in the field sDaysB.

Please note that the following information is only confirmed to be valid for DB HAFAS, but may work for other HAFAS instances.

The timetable period, represented as begin and end date, is given in the two fields fpB ("Fahrplanbeginn") and fpE ("Fahrplanende").

For example, when a train runs Monday to Friday every week in the timetable period starting at 2021-12-12 (a sunday), the beginning of the field sDaysB would look as following:

7CF9F3E7...

Converting each hex digit separately back to binary digits, it looks like this:

0111 1100 1111 1001 1111 0011 1110 0111 ...

From this, you can read out each operation day:

SunMonTueWed
0111
ThuFriSatSun
1100
MonTueWedThu
1111
...
...

Furthermore, the Days of Operation can also be found as human-readable text in the optional field sDaysR. In the example above, it would be just "Mo - Fr". For more complicated Days of Operation, this text also gets more complicated, obviously. Thus,

{
  "sDaysB": "00F1E3E7CF9F3E7CF80000001F3E7C000367C01F3A7C7800000000000001F3E7C00000000000000E000000000000"
}

results in runs 25., 26. Aug, 24. until 26. Oct 2022.

When looking at sDaysB, you can see that even before August 25th this train operates, but in the text only the Days of Operation in the future are displayed.

In the following (shortened) response you can see where all fields are located:

JSON response
{
  "svcResL": [
    {
      "res": {
        "outConL": [
          {
            "sDays": {
              // human-readable version operation dates (only contains future days)
              "sDaysR": "runs 25., 26. Aug, 24. until 26. Oct 2022 ",
              // bit field
              "sDaysB": "00F1E3E7CF9F3E7CF80000001F3E7C000367C01F3A7C7800000000000001F3E7C00000000000000E000000000000"
            }
          }
        ],
        // begin of planning period in YYYYMMDD
        "fpB": "20211212",
        // end of planning period in YYYYMMDD
        "fpE": "20221210"
      }
    }
  ]
}

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.

Reduction Card

HAFAS TripSearch provides an option to provide a reduction card for a traveller which reduces the price of a ticket.

CardHAFAS integer
BahnCard 25 1st Class1
BahnCard 25 2nd Class2
BahnCard 50 1st Class3
BahnCard 50 2nd Class4
BahnCard 100 1st Class16
BahnCard 100 2nd Class17
SH-Card14
VORTEILScard (w/ RAILPLUS) (AT)9
General-Abonnement (CH)15
HalbtaxAbo (w/ RAILPLUS) (CH)10
HalbtaxAbo (w/o RAILPLUS) (CH)11
40 % (w/ RAILPLUS) (NL)12
40 % (w/o RAILPLUS) (NL)13