Skip to contents

Fetches Atmotube air quality data from the Atmotube Cloud API. Automatically switches to batch mode if the requested date range exceeds 7 days, ensuring compliance with API limits while preserving a one-day overlap.

Usage

get_atmotube_data(
  api_key,
  mac,
  start_date,
  end_date,
  order = "asc",
  format = "json",
  offset = 0,
  limit = 1440,
  separator = ",",
  base_url = "https://api.atmotube.com/api/v1/data"
)

Arguments

api_key

A string containing the user's API key (required).

mac

A string representing the MAC address of the Atmotube device (format: "aa:bb:cc:dd:ee:ff").

start_date

A string representing the start date (format: "YYYY-MM-DD").

end_date

A string representing the end date (format: "YYYY-MM-DD").

order

A string indicating sorting order, either "asc" (ascending) or "desc" (descending). Default is "asc".

format

A string specifying the response format, either "json" or "csv". Default is "json".

offset

A non-negative integer specifying the starting index for pagination. Default is 0.

limit

An integer (1-1440) defining the number of records per request. Default is 1440.

separator

A string indicating the CSV separator when format="csv". Default is ",".

base_url

A string representing the API base URL (default: "https://api.atmotube.com/api/v1/data").

Value

A list (if format="json") or a concatenated CSV string (if format="csv").

Examples

if (FALSE) {
api_key <- "your_api_key_here"
mac <- "aa:bb:cc:dd:ee:ff"
start_date <- "2024-06-01"
end_date <- "2024-06-15"
data <- get_atmotube_data(api_key, mac, start_date, end_date)
print(data)
}