# FiveLetterWords: reproducible, checksum-verified derived-data download.
# Install once: install.packages(c("jsonlite", "digest"))
base <- "https://www.fiveletterwords.io/data/releases/v2026-09-01/"
fetch_bytes <- function(url) {
  path <- tempfile()
  on.exit(unlink(path))
  status <- download.file(url, path, mode = "wb", quiet = TRUE,
    headers = c("User-Agent" = "FiveLetterWordsResearchExample/1.0"))
  stopifnot(status == 0)
  readBin(path, what = "raw", n = file.info(path)$size)
}
manifest <- jsonlite::fromJSON(rawToChar(fetch_bytes(paste0(base, "manifest.json"))),
                              simplifyVector = FALSE)
filename <- "answer-repeats.csv"
raw <- fetch_bytes(paste0(base, filename))
stopifnot(identical(digest::digest(raw, algo = "sha256", serialize = FALSE),
                    manifest$files[[filename]]$sha256))
rows <- read.csv(text = rawToChar(raw), stringsAsFactors = FALSE, check.names = FALSE)
print(manifest$release)
print(manifest$answer_history_data_through)
print(head(rows))
# Cite FiveLetterWords (2026), research release v2026-09-01 [Data set].
# Derived data: CC BY 4.0; separate upstream input terms still apply.
