GuidesAPI Reference
Guides

Get started with the Fleet Optimization Package

This section provides information on the minimum setup required to quickly begin using the Fleet Optimization Package. For more detailed information on HERE account setup, project creation, service linking, app registration, and authentication, see the Identity & Access Management Developer Guide.

Get a HERE account

Obtain access to the HERE platform through your organization administrator's invitation or contact us to get started.

  • If your company has already established a HERE platform organization, contact your organization admin who can invite you to join the organization.
  • If your company hasn’t established a HERE platform organization yet, contact us.

Get an API key

To get an API key, follow these steps:

  1. Sign up for the Fleet Optimization Package on the listing page on HERE Marketplace using your HERE account. You will be prompted to Sign In or Sign Up in case you don't yet have an account.
  2. Review the terms and conditions and process your free subscription. You will be prompted to select an existing App, or create a new App and App ID.
  3. Go to platform.here.com, and select the Access Manager from the Launcher.
  4. Select the Apps tab, and from the table, select the App you either selected or created in Marketplace. The Credentials tab is displayed. Here you can view and copy the API key.
  5. You can either use the API key that was generated, or click Create API key to generate the second of a maximum of two API keys for your application authentication credentials. The API key is created and displayed.

Send a request

There are several ways to combine the APIs provided in the Fleet Optimization Package. See the Tutorials for a sample. The following section provides a sample send request you can use to validate that your routing service has been linked correctly.

A route calculation consists of a single GET request. The only required parameters are an origin and a destination, given by two pairs of WGS84 coordinates in the form <latitude>,<longitude>; and a transportation mode, which can be bicycle, bus, car,pedestrian,scooter, taxi, or truck.

Request

The following request will calculate a car route with default options:

curl -X GET \
    'https://router.hereapi.com/v8/routes?transportMode=car&origin=52.5308,13.3847&destination=52.5264,13.3686&return=summary&apikey={YOUR_API_KEY}'

You can import these examples with Postman: Import > Paste Raw Text.

Response

If the route calculation was successful, the response contains the calculated route with departure and arrival times in one or more sections. Additional summary information, such as the length and duration, are also provided.

{
  "routes": [
    {
      "id": "cc0441f1-b8ca-4410-95d5-bfd930053c03",
      "sections": [
        {
          "id": "256fef6e-6712-47fe-8e68-095c1204eb1a",
          "type": "vehicle",
          "departure": {
            "place": {
              "type": "place",
              "location": {
                "lat": 52.5309837,
                "lng": 13.384567
              },
              "originalLocation": {
                "lat": 52.5307999,
                "lng": 13.3847
              }
            }
          },
          "arrival": {
            "place": {
              "type": "place",
              "location": {
                "lat": 52.5263761,
                "lng": 13.3686186
              },
              "originalLocation": {
                "lat": 52.5263999,
                "lng": 13.3686
              }
            }
          },
          "summary": {
            "duration": 243,
            "length": 1206,
            "baseDuration": 136
          },
          "transport": {
            "mode": "car"
          }
        }
      ]
    }
  ]
}

No routes possible

Some requests will not result in any routes for a number of reasons. This example requests a route from the HERE Berlin office to the HERE Chicago office:

curl -X GET \
  'https://router.hereapi.com/v8/routes?transportMode=car&origin=52.5308,13.3847&destination=41.8845,-87.6386&apikey={YOUR_API_KEY}' \

The Atlantic Ocean is between these two offices. This causes the route calculation to fail with the following response:

{
  "notice": [
    {
      "title": "Route calculation failed: Couldn't find a route.",
      "code": "routeCalculationFailed"
    }
  ],
  "routes": []
}

Encoding your request

Some parameter values, especially waypoint specifications, use a structured string in their values. Content characters may then clash with control characters in your request. Consider for example a request such as the following:

https://router.hereapi.com/v8/routes?transportMode=car&origin=54.32556,14.65314&destination=54.65422,14.66636;nameHint=Fish & Chips! St. 25&apikey={YOUR_API_KEY}

Such a request is ambiguous due to the use of control characters (&, !) in the value of nameHint. Such characters need to be appropriately percent-encoded for disambiguation. The following guidelines apply for percent-encoding your requests:

  • Never percent encode & or = when they are used as control characters.
  • If your request does not use control characters as content (that is, they are only used for their intended control meaning), you don't need to encode anything.
  • If your request does use control characters for content, percent-encode them, but leave the controlling characters unencoded. Do not double-encode. In such mixed requests, all naked control characters will be interpreted as control, and all encoded ones as content.

Therefore, the above request should be encoded as:

https://router.hereapi.com/v8/routes?transportMode=car&origin=53.32556,14.65314&destination=53.65422,14.66636;nameHint=Fish%20%26%20Chips%21%20St.%2025&apikey={YOUR_API_KEY}

Next steps

To learn more, refer to the following sections: