download_data: Download Data

View source: R/download_data.R

download_dataR Documentation

Download Data

Description

Downloads the data for a specific user, species, and region into a temporarly (or not) SQLite3 database. The data can be extracted from this database via the extract_data() function.

Usage

download_data(
  session,
  region,
  speciesID,
  token = session$unToken,
  curl_handle = session$curl,
  api_baseurl = session$base_url,
  db_file = tempfile(),
  end_point = "/api/data/download",
  api_url = paste0(api_baseurl, end_point),
  ...,
  debug_json = FALSE
)

Arguments

session

list, an object created by start_session()

region

integer, optional??

speciesID

integer, optional??

token

character, the token for the established session

curl_handle

a curl handle for the established session

api_baseurl

character, the base URL for the database API

db_file

character, the file to store the downloaded data in. Defaults to a temporary file.

end_point

character, the suffix for the download end point

api_url

character, the full url for the API end point for downloading data

...

additional arguments passed to getBinaryURL()

debug_json

logial, if TRUE the function returns the JSON payload as a string and does not send the request. This is primarily for debugging API behavior and checking the JSON payloads for correctness. The JSON will include white space for pretty printing, e.g. cat(payload)

Value

character, the file path to the downloaded SQLite database, or when debug_json = TRUE a string representing the JSON payload.

Author(s)

Matt Espe

Examples

## Not run: 
# All data
detection_db = download_data(my_session)

# One species
detection_db = dowloand(data(my_session, speciesID = 1)

# defaults to putting tables in an environment
detection_data = extract_data(detection_db)

# Access data via $
names(detection_data)
detection_data$Registrations
as.list(detection_data)

## End(Not run)

fishsciences/telemetry documentation built on May 31, 2024, 10:13 a.m.