Load libraries

library(httr)
library(dplyr)
library(stringi)
library(stringr)
library(jsonlite)
library(kableExtra)

Fetch data

api_key <- "EFifKA3eey63dolyo33iCamKmfgtO8Ig"
api_url <- "https://api.nytimes.com/svc/topstories/v2/arts.json?api-key=EFifKA3eey63dolyo33iCamKmfgtO8Ig" 

response <- GET(api_url, query = list(api_key = api_key, order = "by-title", offset = 20))

#Response should be 200 OK
response[2]
## $status_code
## [1] 200
#Read art books
arts_books <- readLines(api_url, warn = FALSE)

#Read JSON data
arts_books <- fromJSON(arts_books)  
arts_books_df <- arts_books$results
colnames(arts_books_df)
##  [1] "section"             "subsection"          "title"              
##  [4] "abstract"            "url"                 "byline"             
##  [7] "item_type"           "updated_date"        "created_date"       
## [10] "published_date"      "material_type_facet" "kicker"             
## [13] "des_facet"           "org_facet"           "per_facet"          
## [16] "geo_facet"           "multimedia"          "short_url"

Clean data

#Get only needed columns
arts_books_df = arts_books_df[c("section","subsection","title", "byline", "org_facet", "per_facet", "short_url")]

Show results

#Display output
kable(arts_books_df)
section subsection title byline org_facet per_facet short_url
Arts Television Director Amy Berg on Why the Adnan Syed Case Still Matters By AUSTIN CONSIDINE Home Box Office Berg, Amy (1970- ) https://nyti.ms/2CM0aFA
Movies Agnès Varda: The Filmmaker as Rigorous Friend By A.O. SCOTT character(0) Varda, Agnes https://nyti.ms/2CKkuqy
Arts Music Billie Eilish Redefines Teen-Pop Stardom on a Haunted, Heartfelt Debut Album By JON PARELES character(0) Eilish, Billie https://nyti.ms/2CKgSoK
Arts Music Billie Eilish Is Not Your Typical 17-Year-Old Pop Star. Get Used to Her. By JOE COSCARELLI character(0) Eilish, Billie https://nyti.ms/2TZLUDH
Arts Art & Design On the Met Roof, Alicja Kwade’s Test of Faith By THOMAS ROGERS Metropolitan Museum of Art Kwade, Alicja https://nyti.ms/2TEaSU9
Arts Television ‘The Twilight Zone’: Here’s Why We Still Care By BRIAN TALLERICO CBS Corporation c(“Peele, Jordan”, “Serling, Rod”) https://nyti.ms/2YvSQa9
Arts Television ‘Us’ Reflects a Mirror Image of ‘The Twilight Zone’ By AISHA HARRIS character(0) c(“Peele, Jordan”, “Serling, Rod”) https://nyti.ms/2Yvy9eC
Arts Music Boy Bands, Now Featuring Grown Men c(“Backstreet Boys”, “Jonas Brothers”, “N Sync”, “New Kids on the Block”) character(0) https://nyti.ms/2CM5ubM
Movies ‘Beat the Devil,’ the Bogart Flop That Spawned a Cult By J. HOBERMAN c(“YouTube.com”, “Amazon.com Inc”) c(“Bogart, Humphrey”, “Huston, John”, “Capote, Truman”, “Jones, Jennifer (1919-2009)”, “Lollobrigida, Gina”) https://nyti.ms/2TJNxQO
Arts Dance City Ballet’s New Season: Here’s What Our Critics Want to See By MICHAEL COOPER New York City Ballet c(“Cunningham, Merce”, “Liang, Edward”, “Lovette, Lauren”, “Roberts, Jamar”, “Tanowitz, Pam”, “Taylor, Paul”) https://nyti.ms/2TJsvC3
Arts Television ‘Fosse/Verdon’ Has Magic to Do. And Undo. By ALEXIS SOLOSKI character(0) c(“Fosse, Bob”, “Blankenbuehler, Andy”, “Kail, Thomas”, “Lacamoire, Alex”, “Levenson, Steven”, “Williams, Michelle (Actor)”, “Sam Rockwell”, “Gwen Verdon”) https://nyti.ms/2V5dxaK
Arts Music Beth Gibbons of Portishead Learned to Sing in Polish. So I Did, Too. By ALEX MARSHALL Portishead (Music Group) c(“Gibbons, Beth”, “Gorecki, Henryk Mikolaj”, “Penderecki, Krzysztof”) https://nyti.ms/2CE3CSz
Theater Review: A Magnificent Road to Ruin in ‘The Lehman Trilogy’ By BEN BRANTLEY Park Avenue Armory (Manhattan, NY) c(“Miles, Ben (1976- )”, “Godley, Adam”, “Beale, Simon Russell”, “Mendes, Sam”, “Massini, Stefano”, “Power, Ben (Playwright)”) https://nyti.ms/2YvZtt7
Arts Music New York Chased the Olympics. It Got the Shed Instead. By MICHAEL COOPER c(“Culture Shed”, “Shed (Manhattan, NY)”, “Diller Scofidio & Renfro”, “Rockwell Group”) c(“Bloomberg, Michael R”, “Diller, Elizabeth”, “Doctoroff, Daniel L”, “Levin, Kate D”, “Poots, Alex”, “Rockwell, David (1956- )”, “Ross, Stephen M”) https://nyti.ms/2TZZS8L
Arts Music Janet Jackson and Stevie Nicks Speak Up for Women at the Rock & Roll Hall of Fame By BEN SISARIO c(“Cure, The (Music Group)”, “Def Leppard (Music Group)”, “Radiohead (Music Group)”, “Roxy Music”, “Zombies, The (Music Group)”, “Rock and Roll Hall of Fame and Museum”) c(“Jackson, Janet”, “Nicks, Stevie”) https://nyti.ms/2UmvxQV
Style What Would Texas Be Without Buc-ee’s? By ELI DURST, CHARLEY LOCKE and EVE LYONS character(0) character(0) https://nyti.ms/2Ur5DvD
Arts The Week in Arts: Martha Graham, ‘Ink’ and Let’s Eat Grandma By THE NEW YORK TIMES c(“Let’s Eat Grandma (Music Group)”, “Museum of Modern Art”, “Friedman, Samuel J, Theater”, “Joyce Theater”, “Roulette (Brooklyn, NY, Performance Space)”, “MoMA PS1”) c(“Hollingworth, Jenny”, “Walton, Rosa”, “Fattal, Simone”, “Azaria, Hank”, “Carvel, Bertie”, “Leigh, Mike”) https://nyti.ms/2TIpim7
Arts Television New on Netflix Canada: The Best Movies and TV Shows for April 2019 By SCOTT TOBIAS Netflix Inc character(0) https://nyti.ms/2TEInpn
Arts Music A Brünnhilde Is Born: The Week in Classical Music c(“Attacca Quartet”, “Metropolitan Opera”, “Morgan Library & Museum”, “New York Philharmonic”) c(“Adams, John (1947- )”, “Griffey, Anthony Dean”, “Wang, Yuja (1987- )”, “Goerke, Christine”) https://nyti.ms/2CIWHaw
Arts Music Review: An Intimate ‘St. Matthew Passion’ Has a Shattering Effect By ANTHONY TOMMASINI c(“Tenet and the Sebastians (Music Group)”, “St Peter’s Episcopal Church (West 20th Street, Manhattan, NY)”) Bach, Johann Sebastian https://nyti.ms/2TL83Rc
Arts Music The Playlist: Sky Ferreira’s Moody Re-emergence, and 13 More New Songs By JON PARELES, JON CARAMANICA, CARYN GANZ and GIOVANNI RUSSONELLO c(“Bomba Estereo (Music Group)”, “Cage the Elephant”, “Secret Machines”, “Systema Solar (Music Group)”, “Black Midi (Music Group)”, “Nat Turner Rebellion (Music Group)”) c(“Allen, Geri”, “Beck”, “Clarkson, Kelly”, “Director X (1975- )”, “J Balvin (1985- )”, “Lil Uzi Vert (Rapper)”, “Mac, Steve”, “Marshmello (1996- )”, “McDaid, Johnny”, “Pink (1979- )”, “Pink Sweat$ (Singer)”, “Vila Tobella, Rosalia”, “Ashton, Kassi”, “Carter, Betty”, “Uwaifo, Victor”) https://nyti.ms/2CHiFek
Arts Music Review: Conjuring the Splintered Self With Electronics and Voice By CORINNA da FONSECA-WOLLHEIM c(“New York Festival of Song”, “DiMenna Center for Classical Music”) c(“Saariaho, Kaija”, “Soper, Kate”, “Lee, Charmaine”, “Lucier, Alvin (1931- )”) https://nyti.ms/2CF8qXB
Arts Newly Discovered Photograph of Harriet Tubman Goes on Display By LAURA M. HOLSON c(“Smithsonian Institution”, “National Museum of African American History and Culture”) Tubman, Harriet https://nyti.ms/2CKiG10
Arts Music Review: Roam the Spectrum With Tyshawn Sorey By SETH COLTER WALLS c(“Miller Theater at Columbia University”, “JACK Quartet”) c(“Sorey, Tyshawn”, “Smythe, Cory (1977- )”, “Chase, Claire”) https://nyti.ms/2TL3I0m
Arts Television Review: Amazon’s ‘Hanna,’ Genetically Modified for Streaming Video By MIKE HALE Amazon.com Inc character(0) https://nyti.ms/2TIkugr
Movies Agnès Varda: Highlights From Her Film Career By MEKADO MURPHY character(0) Varda, Agnes https://nyti.ms/2TIpula
Books Book Review The Debut Novel That Rules the Best-Seller List By TINA JORDAN character(0) Owens, Delia https://nyti.ms/2CM0y70
Style Aml Ameen Competes in a Poetry Slam By ALEXIS SOLOSKI Nuyorican Poets Cafe (Manhattan, NY) Ameen, Aml https://nyti.ms/2TEWrPL
Arts Television Rewatching ‘Game of Thrones,’ Season 5: Shame, Shame, Shame By JENNIFER VINEYARD character(0) character(0) https://nyti.ms/2CEZbXp
Style Mary Boone Is Not Done By JACOB BERNSTEIN Boone, Mary, Gallery c(“Boone, Mary (1951- )”, “Baldwin, Alec”, “Basquiat, Jean-Michel”, “Bleckner, Ross”) https://nyti.ms/2CLcW75
Books Book Review New in Paperback: ‘No Turning Back,’ ‘A Gentleman in Moscow’ By JOUMANA KHATIB character(0) character(0) https://nyti.ms/2THDLPa
Movies This Week’s Trailers: ‘Scary Stories’ and a New ‘Toy Story’ By BRUCE FRETTS character(0) character(0) https://nyti.ms/2TEbIQM
Movies Dev Patel Goes for Shock and Awe By KATHRYN SHATTUCK character(0) Patel, Dev https://nyti.ms/2CG87fi
Arts Television ‘Star Trek: Discovery’ Season 2, Episode 11: Struggle Is Pointless By SOPAN DEB character(0) character(0) https://nyti.ms/2CLQA5k
Movies ‘The Legend of Cocaine Island’ Review: Florida Man’s Silly Odyssey By ELISABETH VINCENTELLI character(0) Love, Theo https://nyti.ms/2THEDTR
Obituaries Agnès Varda, Influential French New Wave Filmmaker, Dies at 90 By JOHN ANDERSON character(0) Varda, Agnes https://nyti.ms/2YvD1k1
Movies Watch the Hunt for Bonnie and Clyde in ‘The Highwaymen’ By MEKADO MURPHY character(0) c(“Hancock, John Lee”, “Costner, Kevin”, “Harrelson, Woody”, “Hamer, Frank (1884-1955)”) https://nyti.ms/2YztEja
Books Book Review Kids Searching for the Complicated Truth By LENORA TODARO character(0) c(“Stoddard, Lindsey (Author)”, “Schmidt, Gary D”, “Salazar, Aida (Author)”, “Smith, Andrew (1959- )”) NA
Books Book Review The Poet Family Who Were Icons of Spanish Nationalism By AMANDA VAILL character(0) c(“Shulman, Aaron (Author)”, “Panero, Leopoldo”, “Franco, Francisco”) NA
Books Book Review Families Banter and Bicker Their Way Through Three New Novels By JENNIFER REESE character(0) c(“Butler, Nickolas”, “Langsdorf, Julie”, “Markovits, Benjamin”) NA
Books Book Review Unraveling the Putin Enigma By OLIVER BULLOUGH character(0) c(“Stent, Angela E”, “Putin, Vladimir V”) https://nyti.ms/2YyjhMr
Books Book Review A Debut Novel Probes the Difficult Lives of Arab-American Women By BEEJAY SILCOX character(0) Rum, Etaf https://nyti.ms/2YxOkbq
Books Book Review A History of American Jewish Women Shows How the Country Influenced Them, and Vice Versa By JORDANA HORN character(0) Nadell, Pamela S https://nyti.ms/2Yz1STW
Books Book Review Stories That Double as a Field Guide to Women’s Desires and Miseries By MERRITT TIERCE character(0) Meijer, Maryse https://nyti.ms/2U4N7cX
Arts Television Trevor Noah Isn’t Sorry for Kids Caught up in College-Admissions Scandal By GIOVANNI RUSSONELLO International Olympic Committee c(“Kimmel, Jimmy”, “McConaughey, Matthew”, “Noah, Trevor (1984- )”, “Peele, Jordan”) https://nyti.ms/2V4fULc
Arts Television What’s on TV Friday: ‘Hanna’ and ‘The Highwaymen’ By GABE COHN character(0) character(0) https://nyti.ms/2V2erVx
Theater Review: In ‘The Tragedy of Julius Caesar,’ the Political Thrill Is Gone By ALEXIS SOLOSKI Theater for a New Audience Cooper, Shana (Theater Director) https://nyti.ms/2Yxct1O
Movies ‘Super Deluxe’ Review: A Tamil Film, With a Cosmic Indie Vibe By RACHEL SALTZ character(0) Kumararaja, Thiagarajan https://nyti.ms/2UXTpYa