library(httr2) # Read NVDA's file (one GET, no key), naming your own project stock <- request("https://tickerinside.com/api/v1/sec/nvda.json") |> req_user_agent("MyProject/1.0 (+https://example.com)") |> req_perform() |> resp_body_json() # The etf_ownership block holds the figure own <- stock$etf_ownership # pct_lower_bound is null when no figure is published, and refused says why if (is.null(own$pct_lower_bound)) { writeLines(paste("NVDA etf_ownership: no figure published, refused", own$refused)) } else { writeLines(paste0("NVDA etf_ownership: at least ", own$pct_lower_bound, "% of its shares held by covered US ETFs, basis ", own$basis)) # The shares counted, and the date of the count of shares outstanding # big.mark puts a comma every three digits writeLines(paste("shares_held", format(own$shares_held, big.mark = ",", scientific = FALSE), "shares_outstanding", format(own$shares_outstanding, big.mark = ",", scientific = FALSE), "as of", own$shares_outstanding_as_of)) # The oldest and the newest holdings file behind the figure writeLines(paste("holdings dated", own$holdings_dates$oldest, "to", own$holdings_dates$newest)) # The line to print under the figure writeLines(own$cite_as) }