For this assignment, I used the New York Times Most Popular API, which provides data on the most viewed, shared, and emailed articles on NYTimes.com. This API allows access to trending content over different time periods (1, 7, or 30 days). In this analysis, I retrieved the most viewed articles in the past week and transformed the JSON data into an R DataFrame for analysis.
library(httr)
library(jsonlite)
library(dplyr)
api_key <- "c96obdM8JuqLC6Avv0xQc4hR0YHGQhzL"
url <- paste0("https://api.nytimes.com/svc/mostpopular/v2/emailed/7.json?api-key=", api_key)
response <- GET(url)
status_code(response)
## [1] 200
data_json <- content(response, "text")
data_list <- fromJSON(data_json, flatten = TRUE)
names(data_list)
## [1] "status" "copyright" "num_results" "results"
mailed_df <- data_list$results %>%
select(title, byline, section, published_date, url)
head(mailed_df)
## title
## 1 9 Exercises for Strong, Stable Ankles
## 2 Burnin’ Down the House
## 3 Rewriting What’s Possible in the Mountains
## 4 There’s a Reason Trump Fears No Kings
## 5 The N.F.L. Players Trading Their Helmets for Scrubs
## 6 A Pilgrim Route in Norway: Berries, Bogs and a Viking King
## byline section published_date
## 1 By Anna Maltby and Theodore Tae Well 2025-10-18
## 2 By Maureen Dowd Opinion 2025-10-25
## 3 By Scott Cacciola and K.K. Rebecca Lai Style 2025-10-21
## 4 By Jamelle Bouie Opinion 2025-10-22
## 5 By Jancee Dunn Well 2025-10-19
## 6 By Marta Giaccone Travel 2025-10-23
## url
## 1 https://www.nytimes.com/2025/10/18/well/move/ankle-mobility-exercises.html
## 2 https://www.nytimes.com/2025/10/25/opinion/trump-white-house-east-wing-demolition.html
## 3 https://www.nytimes.com/interactive/2025/10/21/style/kilian-jornet-72-mountain-peaks.html
## 4 https://www.nytimes.com/2025/10/22/opinion/no-kings-trump-declaration-independence.html
## 5 https://www.nytimes.com/2025/10/19/well/nfl-players-nurses.html
## 6 https://www.nytimes.com/2025/10/23/travel/norway-pilgrimage-route-st-olav-ways.html
Using the New York Times Most Popular API, I successfully retrieved data on the most emailed articles from the past seven days. By connecting to the API through R, I was able to extract and organize JSON data into a clean DataFrame containing each article’s title, author, section, date, and link.
Through the New York Times Most Popular API, I explored which articles gained the most attention over the past week. Most top-emailed pieces were from the Opinion and Health sections, highlighting trending readers interests.