Skip to contents

Interface to the Telraam traffic API, retrieving traffic data for a specified segment or instance and time interval.

Usage

read_telraam_traffic(
  id,
  level = c("segments", "instances"),
  report = c("per-hour", "per-quarter"),
  time_start,
  time_end,
  tz = Sys.timezone(),
  mytoken = get_telraam_token(),
  include_speed = FALSE
)

Arguments

id

Integer. Segment or instance identifier (see Telraam website for details).

level

Character. Either "segments" or "instances" (default: "segments").

report

Character. Either "per-hour" or "per-quarter". "per-quarter" requires an Advanced API token and returns 15-minute aggregated data.

time_start

Character string. Start date-time in format "YYYY-MM-DD HH:MM:SS".

time_end

Character string. End date-time in format "YYYY-MM-DD HH:MM:SS" (exclusive).

tz

Character string. Timezone name (default: value from Sys.timezone()).

mytoken

Character string. Authentication token. If not set, uses value from environment.

include_speed

Logical. If TRUE, includes car speed distribution in the returned data (default: FALSE).

Value

Data frame with traffic data for the specified segment/instance and time interval.

Examples

if (FALSE) { # \dontrun{
# Set up the token (see set_telraam_token)
mytoken <- "your_token_here"
read_telraam_traffic(9000003890,
                     time_start = "2023-03-25 07:00:00",
                     time_end = "2023-03-30 07:00:00")
read_telraam_traffic(9000003890,
                     time_start = "2023-03-25 07:00:00",
                     time_end = "2023-03-30 07:00:00",
                     include_speed = TRUE)
read_telraam_traffic(12031,
                     time_start = "2025-07-20 00:00:00",
                     time_end = "2025-07-28 00:00:00",
                     level = "instances",
                     report = "per-quarter")
} # }