library(httr)
library(jsonlite)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
# 1. Call a public API: GitHub issues for ggplot2
url <- "https://api.github.com/repos/tidyverse/ggplot2/issues?per_page=20"

resp <- GET(url)

# 2. Check that the request worked
status_code(resp)
## [1] 200
# 3. Parse JSON content into a list, then data frame
issues_raw <- content(resp, as = "text", encoding = "UTF-8")
issues_list <- fromJSON(issues_raw, flatten = TRUE)
issues <- as_tibble(issues_list)

# 4. Keep just a few useful columns
issues_clean <- issues %>%
  select(number, title, state, user.login, created_at)

issues_clean
## # A tibble: 20 × 5
##    number title                                      state user.login created_at
##     <int> <chr>                                      <chr> <chr>      <chr>     
##  1   6774 Enable `filter` aesthetic à la ggforce     open  teunbrand  2025-12-1…
##  2   6773 Layer-level clipping                       open  teunbrand  2025-12-1…
##  3   6772 Track ggplot2 version in plot              open  teunbrand  2025-12-1…
##  4   6771 Add `theme(axis.ontop)`                    open  teunbrand  2025-12-1…
##  5   6768 geom_vline() and geom_hline() affect x an… open  dboutwell3 2025-12-0…
##  6   6767 Improve message of `palette`/`na.value` m… open  teunbrand  2025-12-0…
##  7   6766 Add check function for named-ness          open  teunbrand  2025-12-0…
##  8   6763 Inconsistency of `linewidth`/`stroke` int… open  teunbrand  2025-12-0…
##  9   6757 geom_violin(): draw_quantiles deprecation… open  twest822   2025-11-2…
## 10   6752 ggtext and parsing html with latest versi… open  Philip-Le… 2025-11-1…
## 11   6726 pass plot into `alt` lambda to match S7 m… open  JacobBumg… 2025-11-0…
## 12   6725 lambdas in `alt` text have unexpected and… open  JacobBumg… 2025-11-0…
## 13   6716 Broken support on `annotation_custom()`    open  yotasama   2025-10-2…
## 14   6714 Version info stored and can be queries in… open  cschwarz-… 2025-10-2…
## 15   6704 debug: Test install on macos w/ R4.2       open  schloerke  2025-10-1…
## 16   6702 bug(install): `element_geom()` causes iss… open  schloerke  2025-10-1…
## 17   6689 Omit legend items                          open  luisDVA    2025-10-0…
## 18   6652 Rename `justification` settings to `just`… open  teunbrand  2025-09-2…
## 19   6651 Graphical parameters for `geom_smooth()` … open  teunbrand  2025-09-2…
## 20   6636 Should the shape scale `na.value` default… open  davidhodg… 2025-09-2…