LESSON 4 OF 6

Getting started with the HAM API

First, sign up for an API key using this link. Within a few minutes of completing the form, you will receive an email containing a unique code that allows you to access the museum’s data. Be sure to keep your API key private. Each key is unique to the individual requesting it and should be treated like a password.

To retrieve data from the API, you must build queries that tell the API what to look for. A query, taking the form of a URL, consists of multiple components that act as building blocks.

A query to retrieve all of the object data looks like this:

https://api.harvardartmuseums.org/object?apikey=0000-0000-0000-000

Warning: If you try clicking on the link above, it will say “unauthorized” because it is using an invalid API key. Replace the example API key with your own.

When you go to the URL query, the unformatted data may look unreadable—try downloading a browser extension that reformats JSON data:

  • JSONview (Google Chrome)
  • JSON Formatter for Edge (Microsoft Edge)
  • JSON Peep for Safari (Safari)
  • Basic JSON Formatter (Mozilla Firefox)
  • Before and after installing a JSON reader

    The structure of a query follows a pattern. The four basic components are:

    Harvard Art Museums URL

    +

    Resource

    +

    Filter (optional)

    +

    API key

    All of the objects made in the year 2000:

    https://api.harvardartmuseums.org/ object ? yearmade=2002 & apikey=0000-0000-0000-0000
    URL Resource Filter API


    Alongside Objects, the Harvard Art Museums also provides access to other resources such as Exhibits, Artists, and Publications. Here is a full list of all resources available.

    All exhibits from the late 20th century:

    https://api.harvardartmuseums.org/ exhibition ? after=1975 & before=2000 & apikey=0000-0000-0000-0000
    URL Resource Filter Filter API
    Tip: To find the different types of Filters you can apply onto a Resource, look at The Harvard Art Museums' API documentation. Going to the Object Page, for example, will give you the numerous Parameters—or Filters—that you can use for the object resource.