library(tidyverse) # All the tidy things
library(jsonlite) # Converting json data into data frames
library(magrittr) # Extracting items from list objects using piping grammar
library(httr) # Interacting with HTTP verbsAccessing The Art Institute of Chicago’s API
Introduction to the API
The Art Institute of Chicago’s API provides developers with structured access to the museum’s vast collection of public data, enabling them to integrate detailed information about artworks, artists, and other museum resources into their applications. The API gives developers access to a wealth of metadata, including artwork titles, artist names, creation dates, and high-quality images. It also supports powerful search features, allowing users to filter by keywords, artist names, or specific themes like “cats” or “impressionism,” and even restrict results to public domain works. By using this API, developers can enhance their projects with rich, curated art data while offering users an engaging way to explore the museum’s collection.
Setup Process
No formal registration or API key is needed to access this data from the Art Institute of Chicago. Thus, we can begin with setting up this API on R by installing and running these packages below to make API requests and to process data in R. I have only shown the portion of loading the libraries below:
After loading the packages, I then define the base URL for the Art Institute of Chicago’s API endpoint. This URL will serve as the foundation for building the API requests.
art_endpoint <- "https://api.artic.edu/api/v1/artworks/"Demonstrating the API Call
To demonstrate how to make an API call and retrieve artwork data, I’ve created a function fetch_artwork_data() that accepts an art_id as input. The function constructs the full URL for the API request, sends a GET request, checks for a successful response, and parses the JSON data. If successful, it will return specific details about the artist.
fetch_artwork_data <- function(art_id) {
art_url <- paste0(art_endpoint, art_id)
art_response <- GET(art_url)
if (status_code(art_response) == 200) {
art_data_raw <- content(art_response, as = "text", encoding = "UTF-8")
art_data <- fromJSON(art_data_raw)
return(art_data$data$description)
} else {
print(paste("Error:", status_code(art_response)))
return(NULL)
}
}Here is an example call to the function with a specific artwork artist ID:
art_id <- 129884 # Example artwork ID
art_description <- fetch_artwork_data(art_id)
print(art_description)[1] "<p>After decades as a representational painter, in her seventies Alma Thomas turned to abstraction, creating shimmering, mosaic-like fields of color with rhythmic dabs of paint that were often inspired by forms from nature. The artist had been fascinated with space exploration since the late 1960s, and her later paintings often referenced America’s manned Apollo missions to the moon. Although she had never flown, Thomas began to paint as if she were in an airplane, capturing what she described as shifting patterns of light and streaks of color. “You look down on things,” she explained. “You streak through the clouds so fast. . . . You see only streaks of color.”</p>\n<p><em>Starry Night and the Astronauts</em> evokes the open expanse and celestial patterns of a night sky, but despite its narrative title, the work could also be read as an aerial view of a watery surface, playing with our sense of immersion within an otherwise flat picture plane. The viewer is immersed not only in the sense of organic expanse that this painting achieves, however, but also in an encounter with Thomas’s process: the surface here is clearly constructed stroke by stroke. Meanwhile, the glimpses of raw canvas between each primary-colored mark seem as vivid as the applied paint itself—almost as if the composition were backlit. Thomas relied on the enlivening properties of color throughout her late-blooming career. “Color is life,” she once proclaimed, “and light is the mother of color.” This painting was created in 1972, when the artist was eighty. In the same year, she became the first African American woman to receive a solo exhibition at a major art museum, the Whitney Museum of American Art in New York City.</p>\n"
Conclusion
In this brief tutorial, I explored the Art Institute of Chicago’s public API and demonstrated how to interact with it using R. By making API calls, we were able to retrieve detailed metadata about a specific artist, making this a useful tool for building educational or interactive applications that involve artist data.