Artists’ Materials via the Brooklyn Museum API
From the Brooklyn Museum Collection

From the Brooklyn Museum Collection

For Programming A to Z last week, Adam asked us to get some XML from a web service and use it as input into one of our previous programs. I chose to work with the Brooklyn Museum’s API. In looking through an XML sample from their site, I was intrigued by the variety of artists’ materials listed under each object’s “medium” attribute. When I look at art in museum’s I’m often left guessing by the signage, wondering what process the artist used in order to get a material to behave in a specific way. So, I thought it would be interesting to reduce a description of a work to the media used to create it, then compile a new work out of images of those media (e.g. a work made of glass and walnut transformed and remade with images tagged “glass” and “walnut”). My code for getting the artist and materials data out of the XML returned by a keyword search is here:

import org.dom4j.Document;
import org.dom4j.DocumentFactory;
import org.dom4j.io.SAXReader;
import org.dom4j.Element;
import java.util.List;
import java.util.HashMap;
import java.net.URLEncoder;

public class BrookMuse {

public static void main(String[] args) throws Exception {

String keyword = args[0];

SAXReader reader = new SAXReader();
EasyHTTPGet getter = new EasyHTTPGet(
“http://www.brooklynmuseum.org/opencollection/api/?method=collection.search&version=1&api_key=[API KEY]&keyword=” + keyword
);

Document document = reader.read(getter.responseAsInputStream());
List works = document.selectNodes(“//items/object”);

for (Object o: works) {
Element work = (Element)o;

List artists = work.selectNodes(“artists/artist”);

if (artists.size() > 0) {
Element firstArtist = (Element)artists.get(0);
String artist = firstArtist.attributeValue(“name”);
String medium = work.attributeValue(“medium”);
System.out.println(artist + “: ” + medium);
}

else{
String medium = work.attributeValue(“medium”);
System.out.println(“Unknown: ” + medium);
}
}
}
}

It returns a list that looks ike this (e.g. with search term “noguchi”):

Unknown: Low fired earthenware pottery, reassembled from fragments
Isamu Noguchi: Terracotta, plaster
Isamu Noguchi: Glass, walnut
Isamu Noguchi: Bakelite plastic

Now on to gathering some images…

One Response Subscribe to comments


  1. Design for interactive and social media » Museum Links

    [...] http://carolineabrown.com/2009/04/artists-materials-via-the-brooklyn-museum-api/ [...]

    Oct 05, 2009 @ 12:21 pm

Reply