Public Transit API Developer's Guide

Transit Routing Examples

This section provides examples of Transit Routing requests.

Request

The code block below demonstrates the sample request, specifying that the response data are to be delivered in XML.

https://cit.transit.api.here.com/metarouter/rest/routeservice/v2/route
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&routing=all
&graph=0
&startX=-74.04716491699219
&startY=40.74413568925235
&destX=-74.03789520263672
&destY=40.73906330729812
&time=2017-04-11T08:00:00
&forward=1
&details=0

Here is the same request indicating that the response data are to be delivered in JSON.

https://cit.transit.api.here.com/metarouter/rest/routeservice/v2/route.json
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&routing=all
&graph=0
&startX=-74.04716491699219
&startY=40.74413568925235
&destX=-74.03789520263672
&destY=40.73906330729812
&time=2017-04-11T14:21:24
&forward=1
&details=0

Response

The sample response in XML format is as follows:

<Res serviceUrl="http://ip-10-127-182-237.eu-west-1.compute.internal:8080/hafasproxy/G1C">
  <Connections context="e92b9490-face-46d1-9ca3-c863cd1eaa46">
    <Connection id="C-0" duration="PT22M" transfers="0">
      <Dep time="2017-04-11T14:30:00">
      <Addr x="-74.047157" y="40.744138"/>
      </Dep>
      <Arr time="2017-04-11T14:52:00">
        <Addr x="-74.037881" y="40.739059"/>
      </Arr>
      <Sections>
        <Sec>
          <Dep time="2017-04-11T14:30:00">
            <Addr x="-74.047157" y="40.744138"/>
          </Dep>
          <Walk duration="PT7M" distance="328"/>
          <Arr time="2017-04-11T14:37:00">
            <Stn id="416612698#100" name="Palisade Ave at Hutton St" x="-74.045261" y="40.742439"/>
          </Arr>
        </Sec>
        <Sec>
          <Dep time="2017-04-11T14:37:00">
            <Stn id="416612698#100" name="Palisade Ave at Hutton St" x="-74.045261" y="40.742439"/>
            <Line dir="87 Hoboken-Path Via Journal SQ-Exact Fare" code="5" name="87">
              <At id="operator">2PDNJB00</At>
              <At id="category">Bus</At>
            </Line>
            <Freq min="10" max="13"/>
          </Dep>
          <Arr time="2017-04-11T14:43:00">
            <Stn id="416602498#100" name="Paterson Ave at Harrison St" x="-74.041971" y="40.738376"/>
          </Arr>
        </Sec>
        <Sec>
          <Dep time="2017-04-11T14:43:00">
            <Stn id="416602498#100" name="Paterson Ave at Harrison St" x="-74.041971" y="40.738376"/>
          </Dep>
          <Walk duration="PT9M" distance="481"/>
          <Arr time="2017-04-11T14:52:00">
            <Addr x="-74.037881" y="40.739059"/>
          </Arr>
        </Sec>
      </Sections>
    </Connection>
    <Connection duration="PT0H25M46S" id="C-1" transfers="0">
      <Dep time="2017-04-11T14:21:24">
        <Addr x="-74.0472367" y="40.7441631"/>
      </Dep>
      <Arr time="2017-04-11T14:47:10">
        <Addr x="-74.038121" y="40.7391024"/>
      </Arr>
      <Sections>
        <Sec>
          <Dep time="2017-04-11T14:21:24">
            <Addr x="-74.0472367" y="40.7441631"/>
          </Dep>
          <Walk distance="1516" duration="PT0H25M46S"/>
          <Arr time="2017-04-11T14:47:10">
            <Addr x="-74.038121" y="40.7391024"/>
          </Arr>
        </Sec>
      </Sections>
    </Connection>
    <Operators>
      <Op code="2PDNJB00" name="NJ TRANSIT BUS" type="TT"/>
    </Operators>
  </Connections>
</Res>

The sample response in JSON format is as follows:

{
  "Res": {
    "@serviceUrl": "http://ip-10-127-182-237.eu-west-1.compute.internal:8080/hafasproxy/G1C",
    "Connections": {
      "@context": "83af9c41-10d1-4e89-a728-c5d13dde0c94",
      "Connection": [
        {
          "@duration": "PT22M",
          "@id": "C-0",
          "@transfers": "0",
          "Arr": {
            "@time": "2017-04-11T14:52:00",
            "Addr": {
              "@x": "-74.037881",
              "@y": "40.739059"
            }
          },
          "Dep": {
            "@time": "2017-04-11T14:30:00",
            "Addr": {
              "@x": "-74.047157",
              "@y": "40.744138"
            }
          },
          "Sections": {
            "Sec": [
              {
                "Arr": {
                  "@time": "2017-04-11T14:37:00",
                  "Stn": {
                    "@id": "416612698#100",
                    "@name": "Palisade Ave at Hutton St",
                    "@x": "-74.045261",
                    "@y": "40.742439"
                  }
                },
                "Dep": {
                  "@time": "2017-04-11T14:30:00",
                  "Addr": {
                    "@x": "-74.047157",
                    "@y": "40.744138"
                  }
                },
                "Walk": {
                  "@distance": "328",
                  "@duration": "PT7M"
                }
              },
              {
                "Arr": {
                  "@time": "2017-04-11T14:43:00",
                  "Stn": {
                    "@id": "416602498#100",
                    "@name": "Paterson Ave at Harrison St",
                    "@x": "-74.041971",
                    "@y": "40.738376"
                  }
                },
                "Dep": {
                  "@time": "2017-04-11T14:37:00",
                  "Freq": {
                    "@max": "13",
                    "@min": "10"
                  },
                  "Line": {
                    "@code": "5",
                    "@dir": "87 Hoboken-Path Via Journal SQ-Exact Fare",
                    "@name": "87",
                    "At": [
                      {
                        "$": "2PDNJB00",
                        "@id": "operator"
                      },
                      {
                        "$": "Bus",
                        "@id": "category"
                      }
                    ]
                  },
                  "Stn": {
                    "@id": "416612698#100",
                    "@name": "Palisade Ave at Hutton St",
                    "@x": "-74.045261",
                    "@y": "40.742439"
                  }
                }
              },
              {
                "Arr": {
                  "@time": "2017-04-11T14:52:00",
                  "Addr": {
                    "@x": "-74.037881",
                    "@y": "40.739059"
                  }
                },
                "Dep": {
                  "@time": "2017-04-11T14:43:00",
                  "Stn": {
                    "@id": "416602498#100",
                    "@name": "Paterson Ave at Harrison St",
                    "@x": "-74.041971",
                    "@y": "40.738376"
                  }
                },
                "Walk": {
                  "@distance": "481",
                  "@duration": "PT9M"
                }
              }
            ]
          }
        },
        {
          "@duration": "PT0H25M46S",
          "@id": "C-1",
          "@transfers": "0",
          "Arr": {
            "@time": "2017-04-11T14:47:10",
            "Addr": {
              "@x": "-74.038121",
              "@y": "40.7391024"
            }
          },
          "Dep": {
            "@time": "2017-04-11T14:21:24",
            "Addr": {
              "@x": "-74.0472367",
              "@y": "40.7441631"
            }
          },
          "Sections": {
            "Sec": [
              {
                "Arr": {
                  "@time": "2017-04-11T14:47:10",
                  "Addr": {
                    "@x": "-74.038121",
                    "@y": "40.7391024"
                  }
                },
                "Dep": {
                  "@time": "2017-04-11T14:21:24",
                  "Addr": {
                    "@x": "-74.0472367",
                    "@y": "40.7441631"
                  }
                },
                "Walk": {
                  "@distance": "1516",
                  "@duration": "PT0H25M46S"
                }
              }
            ]
          }
        }
      ],
      "Operators": {
        "Op": [
          {
            "@code": "2PDNJB00",
            "@name": "NJ TRANSIT BUS",
            "@type": "TT"
          }
        ]
      }
    }
  }
}

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.