Here we are looking at data the Chicago art institution, this data records information about the various different art exhibits on display at the museum. Someone would want to use this database in order to keep inventory of the various different art exhibits as well as information about them like ID number and the artist who created the piece.
The Code used to get the information from the dataset
All of this code is essential for getting this information.
# The base URL for the Art Institute of Chicago APIbase_url <-"https://api.artic.edu/api/v1/artworks"# Here we request a single page, can be edited to get more information. request_url <-paste0(base_url, "?limit=10") #all of this information is to obtain thecat("Request URL:\n", request_url, "\n\n") #required data without error
#makes the "GET" Request for the dataresponse <-GET(request_url)if (http_error(response)) {stop("HTTP request failed with status code: ", status_code(response))}#JSON Responseresponse_text <-content(response, as ="text", encoding ="UTF-8")aic_data <-fromJSON(response_text, flatten =TRUE)#examens the data and returns a list through the apicat("Elements in the returned JSON object:\n")
Elements in the returned JSON object:
print(names(aic_data))
[1] "pagination" "data" "info" "config"
cat("\n")
#Formats the data into a tidy tableartworks_df <-as_tibble(aic_data$data)
ID and Title
Here are some of the various different art pieces that are given at the exhibit, the function gives us a sampling of some of the art works within the exhibit with their name as well as their ID number.
# This will limit the table to only things that will be relavant to what we are looking forartworks_df <- artworks_df %>%select(id, title, artist_title, date_display)#This prints out what we are looking for, The ID, Artist, and Title. cat("First few rows of the retrieved artworks:\n")
First few rows of the retrieved artworks:
print(head(artworks_df, 10))
# A tibble: 10 × 4
id title artist_title date_display
<int> <chr> <chr> <chr>
1 6699 Covered Bowl and Stand Chantilly Factory c. 1735
2 6694 Plate Niderviller Pottery and Porc… c. 1770
3 6681 Flower Vase (one of a pair) Grieksche A Factory c. 1700-22
4 6691 Plate Veuve Perrin Manaufactory c. 1770
5 275842 From the Morning Iain Stewart 1995
6 275841 Part Iain Stewart 1998
7 275833 Untitled Erika Blumenfeld c. 2008
8 275832 Untitled Erika Blumenfeld c. 2008
9 275844 Rhythm Iain Stewart 1997
10 275843 Path 95 Iain Stewart 1995