Get historical traffic data from hereR

I waant to get historical traffic data from HERE map using hereR package. As I tried even the simples example from munterfi

set_key(here_api_key)
flow(aoi, min_jam_factor = 0, url_only = FALSE)

it return error like this:

Warning messages:
1: In .parse_response(i, out$responses()[[i]]) :
  https://traffic.ls.hereapi.com/traffic/6.2/flow.json: Request 'id = 1' failed. 
  Status 403; Forbidden; Request forbidden -- authorization will not help.
2: In .parse_response(i, out$responses()[[i]]) :
  https://traffic.ls.hereapi.com/traffic/6.2/flow.json: Request 'id = 2' failed. 
  Status 403; Forbidden; Request forbidden -- authorization will not help.

Is this is related to the change in HERE API? Even though in their base plan they said this includes all location services except matrix routing and tour planning

What's the problem?

  • Is this really due to change in their API? (I've used my api key to get isoline data and it works well)
  • If the problem is the hereR package hasn't been updated, can I use httr to request the data?
  • If the problem is the change in API access, is there any alternative solution

Alternatives to HERE?
I'm using HERE instead of google, because to the best of my knowledge, HERE API provide more free access than google, and also, it takes forever and a ton of data space to get google traffic data for a city smaller than New york (prolly around 1 hour and 10GB data. Is this normal case for all traffic data?)

I'm interested using tomtom API, but I'm not sure if its still available. The develover seems to remove the documentation site of tomtom package

This was raised and closed as an API key issue earlier this year here.

Thank you for the reply. I got my API key from in the platform site. I'm sure the API is right because I used it to request isoline data and it responded very well.

The thing that I keep wondering is: is developer.here.com and platform.here.com have different API access? I get the API from the platform one, while can't register in developer portal because it keep redirect to the platform.here.com.

In case you want to try, you can use this:

# libraries
library(tidyverse)
library(hereR)

# health facility
data <- read.csv("https://raw.githubusercontent.com/isaid-hi/bipi.datalab/main/2023.06.24_%234%20Hospital%20Access/hospitals.csv")

# hospital only
hospitals <- data %>% filter(Type %in% "Rumah Sakit")
hospital_sf <- st_as_sf(x = hospitals,
         coords = c("Longitude", "Latitude"),
         crs = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")

# get isoline ----
  ## here api setup ----
  set_key(here_api_key)
  
  ## build isoline ----
    ### isoline for hospitals ----
    isochrones_all <- isoline(
      poi = hospital_sf,
      range = seq(10, 30, 10) * 60,
      range_type = "time",
      datetime <- as.POSIXct(paste0(Sys.Date()," 10:00")) 
    ) %>%
      mutate(name = paste0((range - 600) / 60," to ", range / 60, " mins"))

It works with my API key.

While when executing flow(), it didn't work

I got a 401 with a fresh access key from the here developer onboarding, but I'm not fully sure that I understand their scheme. I get

1: In .parse_response(i, out$responses()[[i]]) :
  https://isoline.router.hereapi.com/v8/isolines: Request 'id = 1' failed. 
  Status 401; Unauthorized; No permission -- see authorization schemes.
2: In .parse_response(i, out$responses()[[i]]) :
  https://isoline.router.hereapi.com/v8/isolines: Request 'id = 2' failed. 
  Status 401; Unauthorized; No permission -- see authorization schemes.

It may be their credential system has some latency; I'll try tomorrow.

Yea I get the same result when using credential key in OAuth tab.
Okay then, I'll wait for your finding before raise the issue

1 Like

Hi welcome to the community! Love the spirit!

While you encounter error when request for traffic flow, are you able to obtain isoline data?

I've tossed the potato to the hereR issues page after failing to unlock the API key puzzle.

1 Like

Heard back

I noticed that traffic flow API v6 is on maintenance. While they have API v7 for traffic flow. Looked like hereR haven't used the API v7, have it?

I’ll keep an eye out.

Thanks. In the mean time, might be good for me to learn httr instead

It's a good to have, but bulk queries can be problematic because so many sites return paged results that go into JS caves of twisty little passages all different that can be difficult to deal with more than the first page.

yea I'm still struggling working on that

Still no success. The documents suggested that an API Access key, as opposed to an OA token would be available by signing up for fremium, and that created fremium app but still only the option to create an OA token, which doesn't work, But then it appears that applications needed to be migrated from the old deveoper.here.com to the new platform.here.com, which requires a separate account. And then after signing into the platform account links to documentation go back to the ifi. In any event, not one of the OA tokens work and there's a different way to create a different kind of token, called API I'm stumped. The return from flow() doesn't pass access either.

Their website seems mainly designed to drive views to their paid products. It is one of the least useful sites otherwise, that I've seen in a long time.

Right, the separation between depelover.here.com and platform.here.com, while it keeps redirected to the second one, drives me nuts.

Thanks for trying. I'll leave the project for the meantime.

1 Like

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.