Analyzing the Most Emailed New York Times Articles

Author

Renee Watson

Approach

For this assignment, I selected the New York Times Most Popular API to explore which newspaper sections appear most frequently among the 20 most emailed articles over a 30-day period. I chose this API because I wanted to better understand what types of articles readers are interested in sharing. My plan is to use R to connect to the API, retrieve the article information, and convert the JSON response into a tidy data frame. I will focus on the article titles, sections, publication dates, and rankings. I also plan to group the articles by section and count how many articles appear in each category to identify which sections are most represented.

One challenge I anticipate is working with the JSON response because some information may be nested or contain missing values. I will use the jsonlite and dplyr packages to extract and organize the data. Another potential challenge is authenticating the API request, so I will store my API key in an environment variable rather than including it directly in my code.

Data source: New York Times Most Popular API

https://developer.nytimes.com/docs/most-popular-product/1/overview

API endpoint:

https://api.nytimes.com/svc/mostpopular/v2/emailed/30.json

Research question

Which New York Times sections have the most articles among the 20 most emailed articles in the past 30 days?

API and request

I selected the New York Times Most Popular API to examine which newspaper sections appear most frequently among the most frequently among the most emailed articles. I used the following endpoint: https://api.nytimes.com/svc/mostpopular/v2/emailed/30.json. This endpoint retrieves the 20 most emailed articles over a 30-day period. The 30 in the URL specifies the period in days, while the api-key query parameter authenticates the request. For security, I stored my API key in an environment variable rather than including it directly in my code.

Request and tidy data frame

library(httr)
library(jsonlite)
library(dplyr)
library(tibble)
library(knitr)


api_key <- Sys.getenv("NYT_API_KEY")

if (api_key == "") {
  stop("API key not found. Check your .Renviron file.")
}

# NYT Most Popular API endpoint
endpoint <- "https://api.nytimes.com/svc/mostpopular/v2/emailed/30.json"


response <- GET(
  endpoint,
  query = list(`api-key` = api_key),
  timeout(30)
)


stop_for_status(response)


json_data <- fromJSON(
  content(response, as = "text", encoding = "UTF-8"),
  simplifyVector = FALSE
)


if (is.null(json_data$results)) {
  stop("No article results were returned.")
}
# Extract article information into a tidy data frame
articles <- lapply(seq_along(json_data$results), function(i) {
  article <- json_data$results[[i]]

  tibble(
    rank = i,
    title = if (is.null(article$title)) NA_character_ else article$title,
    section = if (is.null(article$section)) NA_character_ else article$section,
    published_date = if (is.null(article$published_date)) NA_character_ else article$published_date
  )
}) %>%
  bind_rows()

kable(
  head(articles),
  caption = "First Six Most Emailed NYT Articles"
)
First Six Most Emailed NYT Articles
rank title section published_date
1 Millions Lose Private Medicare Plans and Face Rising Costs Business 2026-10-09
2 In Six Decades of Public Life, I Never Thought I Would Write This Piece Opinion 2026-10-21
3 Will We Ever Understand Dementia? Science 2026-10-10
4 I Can Hear Everything U.S. 2026-10-29
5 The Neuroscience of Decluttering Opinion 2026-10-11
6 We Know How to Fix Homelessness. Look at Denver. Opinion 2026-10-13

Analysis

section_counts <- articles %>%
  count(section, name = "article_count") %>%
  arrange(desc(article_count))


kable(
  section_counts,
  caption = "Number of Most Emailed NYT Articles by Section"
)
Number of Most Emailed NYT Articles by Section
section article_count
Opinion 3
Science 3
U.S. 3
Well 3
Books 2
Style 2
Business 1
Magazine 1
Real Estate 1
World 1

The results show that the Opinion section had the most articles among the 20 most emailed New York Times articles, with 6 articles. Magazine, Science, U.S., and Well each had 2 articles, while Books, Food, Style, The Upshot, Travel, and Your Money each had 1 article. These findings suggest that Opinion articles were particularly prominent among the most emailed articles during the selected 30-day period. However, the results are limited to the 20 most emailed articles returned by the API and do not necessarily represent the popularity of all New York Times articles.

Data Cleaning Decisions

The API returned data in JSON format, which I converted into an R list using the jsonlite package. Since the JSON response contains nested information, I extracted only the fields needed for my analysis: article title, section, publication date, and ranking. I assigned NA to any missing values to keep the data frame consistent. Finally, I grouped the articles by section and counted the number of articles in each section to determine which sections appeared most frequently among the most emailed articles.