API Workflows

The HERE platform allows users to work directly with the REST API. OLP CLI provides helper tools to facilitate direct calls to the REST API, such as:

For more details, see API Commands.

The following steps show how to combine the functionality of OLP CLI to fetch access token and list of endpoints with direct call to REST API by curl and direct call to REST API by curl using a project-scoped token.

Get API Token

To get a new API token, run the api token get command.

olp api token get --json

The command displays the following results.

{
    "accessToken": "eyJhbG...LMXA",
    "expiresAt": "2019-03-07T10:56:51.329Z"
}

List All API Endpoints

To list all endpoints offered by the HERE platform, use the api list command.

olp api list --json

The command displays the following results:

{"apis": [
    {
        "baseURL": "https://account.api.here.com",
        "api": "account",
        "version": "v1",
        "parameters": {}
    },
    {
        "baseURL": "https://artifact.api.platform.here.com/v1",
        "api": "artifact",
        "version": "v1",
        "parameters": {}
    },
    {
        "baseURL": "https://config.data.api.platform.here.com/config/v1",
        "api": "config",
        "version": "v1",
        "parameters": {}
    },
    {
        "baseURL": "https://api-lookup.data.api.platform.here.com/lookup/v1",
        "api": "lookup",
        "version": "v1",
        "parameters": {}
    },
    {
        "baseURL": "https://marketplace.api.platform.here.com/api/v1",
        "api": "marketplace",
        "version": "v1",
        "parameters": {}
    },
    {
        "baseURL": "https://pipelines.api.platform.here.com/pipeline-service",
        "api": "pipelines",
        "version": "v2",
        "parameters": {}
    }
]}

Call REST API with curl

To get catalogs to which you have access, execute the following command:

Note

Download and install curl to execute the command below.


curl -k -s -H "Authorization: Bearer eyJhbG...LMXA" https://config.data.api.platform.here.com/config/v1/catalogs

This is equivalent to running the catalog list command.

The command displays results like below:


{
  "results": {
    "items": [
      {
        "title": "HERE - Sensor Sample Data",
        "hrn": "hrn:here:data::olp-here:sensor-sample-data",
        "href": "https://config.data.api.platform.here.com/config/v1/catalogs/hrn:here:data::olp-here:sensor-sample-data",
        "type": "urn:olp-types:catalog"
      },
      {
        "title": "HERE Live Weather Europe",
        "hrn": "hrn:here:data::olp-here:live-weather-eu",
        "href": "https://config.data.api.platform.here.com/config/v1/catalogs/hrn:here:data::olp-here:live-weather-eu",
        "type": "urn:olp-types:catalog"
      },
      {
        "title": "HERE Map Content",
        "hrn": "hrn:here:data::olp-here:rib-2",
        "href": "https://config.data.api.platform.here.com/config/v1/catalogs/hrn:here:data::olp-here:rib-2",
        "type": "urn:olp-types:catalog"
      }
    ]
  }
}

For more information on the APIs that the platform offers, see Data API, Lookup API, and Pipeline API.

Get Project-Scoped API Token

To get a new API token with a project scope, run the api token get command with the --scope flag.

olp api token get --scope {{book.filtered.hrnPrefix}}:authorization::myrealm:project/my-project --json

The command displays the following results.

{
    "accessToken": "eyJhbG...LMXA",
    "expiresAt": "2019-03-07T10:56:51.329Z"
}

Call REST API with curl using a Project-Scope Token

To get the catalogs related to the project, execute the following command:


curl -k -s -H "Authorization: Bearer eyJhbG...LMXA" https://config.data.api.platform.here.com/config/v1/catalogs

The command displays empty results because there are no catalogs that are created within the project or linked to project we used to create the API token for:


{
"results": {
    "items": []
    }
}

To create a catalog within the project use the olp catalog create command with the --scope flag. To link a catalog to the project use the olp project resources link command.

results matching ""

    No results matching ""