The ZenQuotes API gives us quotes from some of the worlds most famous authors. We can use it to generate a random quote of the day for something like a journal or a daily video.
library(httr)library(jsonlite)
Warning: package 'jsonlite' was built under R version 4.4.3
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ purrr::flatten() masks jsonlite::flatten()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
api_url <-"https://zenquotes.io/api/"
We start the process by building a get_random_quote function which gets the data converting the json storage into a df that’s easier for me to manipulate.