Class: MetMuseum::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/met_museum/collection.rb

Instance Method Summary collapse

Instance Method Details

#departmentArray, ...

returns a listing of all departments

Returns:

  • (Array)

    departments An array containing the JSON objects that contain each department’s departmentId and display name. The departmentId is to be used as a query parameter on the ‘/objects` endpoint

  • (Integer)

    departments Department ID as an integer. The departmentId is to be used as a query parameter on the ‘/objects` endpoint

  • (String)

    departments Display name for a department



91
92
93
94
# File 'lib/met_museum/collection.rb', line 91

def department
  response = create_request(API_ENDPOINT, DEPARTMENTS_URI)
  arrange_response(response)
end

#object(object_id) ⇒ Hash<objectID, Integer>, ...

returns a record for an object, containing all open access data about that object, including its image (if the image is available under Open Access)

Parameters:

  • objectID (Integer)

    The unique Object ID for an object

Returns:

  • (Hash<objectID, Integer>)

    Identifying number for each artwork (unique, can be used as key field)

  • (Hash<isHighlight, Boolean>)

    When “true” indicates a popular and important artwork in the collection

  • (Hash<accessionNumber, String>)

    Identifying number for each artwork (not always unique)

  • (Hash<isPublicDomain, Boolean>)

    When “true” indicates an artwork in the Public Domain

  • (Hash<primaryImage, String>)

    URL to the primary image of an object in JPEG format

  • (Hash<primaryImageSmall, String>)

    URL to the lower-res primary image of an object in JPEG format

  • (Hash<additionalImages, Array<String>>)

    An array containing URLs to the additional images of an object in JPEG format

  • (Hash<constituents, Array<Hash<String:String>>>)

    An array containing the constituents of an object, with both an artist name and their role

  • (Hash<department, String>)

    Indicates The Met’s curatorial department responsible for the artwork

  • (Hash<objectName, String>)

    Describes the physical type of the object

  • (Hash<title, String>)

    Title, identifying phrase, or name given to a work of art

  • (Hash<culture, String>)

    Information about the culture, or people from which an object was created

  • (Hash<period, String>)

    Time or time period when an object was created

  • (Hash<dynasty, String>)

    Dynasty (a succession of rulers of the same line or family) under which an object was created

  • (Hash<reign, String>)

    Reign of a monarch or ruler under which an object was created

  • (Hash<portfolio, String>)

    A set of works created as a group or published as a series.

  • (Hash<artistRole, String>)

    Role of the artist related to the type of artwork or object that was created

  • (Hash<artistPrefix, String>)

    TDescribes the extent of creation or describes an attribution qualifier to the information given in the artistRole field

  • (Hash<artistDisplayName, String>)

    Artist name in the correct order for display

  • (Hash<artistDisplayBio, String>)

    Nationality and life dates of an artist, also includes birth and death city when known

  • (Hash<artistSuffix, String>)

    Used to record complex information that qualifies the role of a constituent, e.g. extent of participation by the Constituent (verso only, and followers)

  • (Hash<artistAlphaSort, String>)

    Used to sort artist names alphabetically. Last Name, First Name, Middle Name, Suffix, and Honorific fields, in that order.

  • (Hash<artistNationality, String>)

    National, geopolitical, cultural, or ethnic origins or affiliation of the creator or institution that made the artwork

  • (Hash<artistBeginDate, String>)

    Year the artist was born

  • (Hash<artistEndDate, String>)

    Year the artist died

  • (Hash<objectDate, string>)

    The total number of publicly-available objects

  • (Hash<total, string>)

    Year, a span of years, or a phrase that describes the specific or approximate date when an artwork was designed or created

  • (Hash<objectBeginDate, string>)

    Machine readable date indicating the year the artwork was started to be created

  • (Hash<objectEndDate, string>)

    Machine readable date indicating the year the artwork was completed (may be the same year or different year than the objectBeginDate)

  • (Hash<medium, string>)

    Refers to the materials that were used to create the artwork

  • (Hash<dimensions, string>)

    Size of the artwork or object

  • (Hash<dimensionsParsed, Array<Hash>>)

    Size of the artwork or object in centimeters, parsed

  • (Hash<measurements, Array<Hash>>)

    Array of elements, each with a name, description, and set of measurements. Spatial measurements are in centimeters; weights are in kg.

  • (Hash<creditLine, String>)

    Text acknowledging the source or origin of the artwork and the year the object was acquired by the museum.

  • (Hash<geographyType, String>)

    Qualifying information that describes the relationship of the place catalogued in the geography fields to the object that is being catalogued

  • (Hash<city, String>)

    City where the artwork was created

  • (Hash<state, String>)

    State or province where the artwork was created, may sometimes overlap with County

  • (Hash<county, String>)

    County where the artwork was created, may sometimes overlap with State

  • (Hash<country, String>)

    Country where the artwork was created or found

  • (Hash<region, String>)

    Geographic location more specific than country, but more specific than subregion, where the artwork was created or found (frequently null)

  • (Hash<subregion, String>)

    Geographic location more specific than Region, but less specific than Locale, where the artwork was created or found (frequently null)

  • (Hash<locale, String>)

    Geographic location more specific than subregion, but more specific than locus, where the artwork was found (frequently null)

  • (Hash<locus, String>)

    Geographic location that is less specific than locale, but more specific than excavation, where the artwork was found (frequently null)

  • (Hash<excavation, String>)

    The name of an excavation. The excavation field usually includes dates of excavation.

  • (Hash<river, String>)

    River is a natural watercourse, usually freshwater, flowing toward an ocean, a lake, a sea or another river related to the origins of an artwork (frequently null)

  • (Hash<classification, String>)

    General term describing the artwork type.

  • (Hash<rightsAndReproduction, String>)

    Credit line for artworks still under copyright.

  • (Hash<linkResource, String>)

    URL to object’s page on metmuseum.org

  • (Hash<metadataDate, String>)

    Date metadata was last updated

  • (Hash<repository, String>)
  • (Hash<objectURL, String>)

    URL to object’s page on metmuseum.org

  • (Hash<tags, Array<String>>)

    An array of subject keyword tags associated with the object

  • (Hash<objectWikidata_URL, string>)

    Wikidata URL for the object

  • (Hash<isTimelineWork, boolean>)

    Whether the object is on the Timeline of Art History website

  • (Hash<GalleryNumber, string>)

    Gallery number, where available



82
83
84
85
# File 'lib/met_museum/collection.rb', line 82

def object(object_id)
  response = create_request(API_ENDPOINT, "#{PUBLIC_URI}/#{object_id}")
  arrange_response(response)
end

#objects(**args) ⇒ Hash<total, Integer>, Hash<objectIDs, Array<Integer>>

Return a listing of all valid Object IDs available to use

Parameters:

  • metadataDate (Date)

    Returns any objects with updated data after this date

  • metadataDate (DateTime)

    Returns any objects with updated data after this date

Returns:

  • (Hash<total, Integer>)

    The total number of publicly-available objects

  • (Hash<objectIDs, Array<Integer>>)

    An array containing the object ID of publicly-available object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/met_museum/collection.rb', line 12

def objects(**args)
  options = {
    metadataDate: nil,
    departmentIds: nil
  }.merge(args)

  options[:metadataDate] = check_date(options[:metadataDate])
  query = { metadataDate: options[:metadataDate], departmentIds: options[:departmentIds] }
  response = create_request(API_ENDPOINT, PUBLIC_URI, query)
  arrange_response(response)
end

#search(query, **args) ⇒ Integer, ...

returns a listing of all Object IDs for objects that contain the search query within the object’s data

Parameters:

  • query (String)

    search term e.g. sunflowers

  • limit (Interger)

    number of objects zthat contain the search query within the object’s data

  • Returns (Boolean)

    objects that match the query and are designated as highlights. Highlights are selected works of art from The Met Museum’s permanent collection representing different cultures and time periods.

Returns:

  • (Integer)

    total The total number of publicly-available objects

  • (Array<Integer>)

    objectIDs An array containing the object ID of publicly-available object

  • (Array<Object>)

    objects An array containing the objects that contain the search query within the object’s data



103
104
105
106
107
108
109
110
111
# File 'lib/met_museum/collection.rb', line 103

def search(query, **args)
  args.merge!({q: query})
  response = create_request(API_ENDPOINT, SEARCH_URI, args)
  origin_response = arrange_response(response)
  limit = args[:limit].to_i
  return origin_response if limit <= 0

  origin_response["objectIDs"].lazy.map { |id| MetMuseum::Collection.new.object(id) }.first(limit)
end