Call Location Service API

This chapter explains how to construct an HTTP request and use it to call the API of a location service hosted on the HERE platform.

HTTP Request Structure

To construct an HTTP request to a location service API, you need the following:

  • The base URL of the service
  • The OpenAPI specification for the service

Get the Base URL

To obtain the location service's base URL, first look up the service that you need in the HERE Location Service registry by means of one of the available options.

The result includes the base URL of the location service that you can use to construct a request to the endpoint.

Get the OpenAPI Specification

To obtain a location service's OpenAPI specification in the YAML format, you can use the following options:

  • Download the API specification document from the location service's details page in the HERE platform portal (from the API Reference tab).

  • Call the following endpoint and pass the service's HRN:

    Linux
    Windows
    curl https://registry.services.api.platform.here.com/v1/services/{service HRN}/openApi \
           -H "Authorization: Bearer <your access token>" \
           -o <path to output file>
    curl https://registry.services.api.platform.here.com/v1/services/{service HRN}/openApi ^
           -H "Authorization: Bearer <your access token>" ^
           -o <path to output file>

Construct a Request

Once you have obtained the base URL and the specification for a location service, you can construct the request for the target endpoint.

Example Call to a Location Service

To show how you can use your access token within your requests to a HERE location service, you can call a sample HERE Location Service Demo service. Use the following command and pass your access token to it to see how it works:

Linux
Windows
curl https://location-service-demo.services.api.platform.here.com/v1/pedestrianroutes \
       -H "Authorization: Bearer <your access token>"
curl https://location-service-demo.services.api.platform.here.com/v1/pedestrianroutes ^
       -H "Authorization: Bearer <your access token>"

The following response illustrates a possible result:

{"type":"FeatureCollection","features":[{"type":"Feature","properties":null,"geometry":{"type":"LineString","coordinates":[[30.50373315811157,50.4742767962409],[30.50529956817627,50.47310234931454],[30.503690242767334,50.47196884379929],[30.506608486175537,50.470248048543745],[30.50472021102905,50.468977897586086],[30.506522655487057,50.46829500662366],[30.506179332733154,50.4681037953868]]}}]}

Generate a Client Application

You are recommended to create an API client application that you can integrate with your projects. With the OpenAPI Generator, you can create an API client that interacts with a HERE Location Service API. Before you proceed, you need to obtain an OpenAPI specification document for a location service.

OpenAPI Generator supports different integrations, including:

  • Maven
  • Gradle
  • GitHub
  • CLI via Docker
  • and others

For more information on supported integrations, see Workflow Integrations.

Note: OpenAPI specification compatibility

For more information on the openapi-generator compatibilities with the OpenAPI specification, see Compatibility.

For more information on the languages that OpenAPI Generator supports, see the corresponding README.md file on GitHub.

Next Steps

The guidelines in the next chapter walk you through the entire process of generating a sample Java API client application that you can include as a dependency in your projects.

results matching ""

    No results matching ""