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 olp 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 olp api list command.

olp api list --json

The command displays the following results:

{
   "apis":[
      {
         "baseURL":"https://elb.cn-northwest-1.account.hereapi.cn",
         "api":"account",
         "version":"v1",
         "parameters":{

         }
      },
      {
         "baseURL":"https://elb.cn-northwest-1.account.hereapi.cn/authorization/v1.1",
         "api":"account",
         "version":"v1.1",
         "parameters":{

         }
      },
      {
         "baseURL":"https://artifact.api.platform.hereolp.cn/v1",
         "api":"artifact",
         "version":"v1",
         "parameters":{

         }
      },
      {
         "baseURL":"https://config.data.api.platform.hereolp.cn/config/v1",
         "api":"config",
         "version":"v1",
         "parameters":{

         }
      },
      {
         "baseURL":"https://api-lookup.data.api.platform.hereolp.cn/lookup/v1",
         "api":"lookup",
         "version":"v1",
         "parameters":{

         }
      },
      {
         "baseURL":"https://pipelines.api.platform.hereolp.cn/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.hereolp.cn/config/v1/catalogs

This is equivalent to running the olp catalog list command.

The command displays results like below:


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

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

Get project-scoped API token

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

olp api token get --scope {{book.filtered.hrnPrefix}}:authorization::org: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.hereolp.cn/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 resource link command.

results matching ""

    No results matching ""