The MET API#

This session examines how to use the MET API in practice to gather and explore data.

Through the session, we will:

  • learn the components of an API request: the root, path, and endpoint

  • practice with a few handy functions for examining request data

    • type() and dir()

  • learn about a super important data type, the dictionary or dict, and how to access items within that structure.

  • create more requests with that data

    • f-strings

  • sort through request data using loops and conditionals

  • transform our data into a dataframe, for doing simple data analysis

import requests
# the structure of our request: base_url, path, query

base_url = "https://collectionapi.metmuseum.org"
path = "/public/collection/v1/search"
query = "?q=woman"

the anatomy of an API request:#

  • the root which consists of the base URL.

  • the path which consists of a directory structure (file structure) where the data is held.

    • /public/collection/v1/objects

    • /public/collection/v1/departments

    • /public/collection/v1/search

  • the parameter or the endpoint which is the specific request. For example, a query parameter takes a search term following ?q=, like:

    • ?q=woman

    • ?q=van+gogh

A complete sample request that searches for the “woman” keyword would be:

To read more about the MET API, see here: https://metmuseum.github.io/

# the request, saved to a variable

url = f'{base_url}{path}{query}'
women = requests.get(url)

inspecting objects: two functions: type() and dir()#

Using type() and dir() to better understand our response data. The end goal is to sift through the data to discover interesting things.

# what type of object do we have?

type(women)
requests.models.Response

What can we do with a Response object? Spend a couple of minutes exploring the different methods.

dir(women)
['__attrs__',
 '__bool__',
 '__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__enter__',
 '__eq__',
 '__exit__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__getstate__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__iter__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__nonzero__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__setstate__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_content',
 '_content_consumed',
 '_next',
 'apparent_encoding',
 'close',
 'connection',
 'content',
 'cookies',
 'elapsed',
 'encoding',
 'headers',
 'history',
 'is_permanent_redirect',
 'is_redirect',
 'iter_content',
 'iter_lines',
 'json',
 'links',
 'next',
 'ok',
 'raise_for_status',
 'raw',
 'reason',
 'request',
 'status_code',
 'text',
 'url']
women.headers
{'Content-Type': 'application/json; charset=UTF-8', 'Vary': 'Origin', 'Access-Control-Allow-Origin': '*', 'X-Powered-By': 'ARR/3.0, ASP.NET', 'Date': 'Tue, 29 Apr 2025 18:09:50 GMT', 'Set-Cookie': 'visid_incap_1662004=RkqV5Vm7RhK0lXugkPwooO8VEWgAAAAAQUIPAAAAAADDp6yvQ6qiwsWZ093Rhh1W; expires=Wed, 29 Apr 2026 07:06:42 GMT; HttpOnly; path=/; Domain=.metmuseum.org, incap_ses_1700_1662004=mwxSRMgDNVRY2n+2VJ2XF/AVEWgAAAAAi5vyj0hkSTLAMk1yDlnhTg==; path=/; Domain=.metmuseum.org', 'X-CDN': 'Imperva', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'X-Iinfo': '48-91203089-91200587 PNYy RT(1745950191858 6) q(0 0 0 0) r(6 6) U12'}
women.raw
<urllib3.response.HTTPResponse at 0x7f5fb4bfbee0>
women.elapsed
datetime.timedelta(microseconds=822289)
women.ok
True
women
<Response [200]>

.json() to parse our response object#

# why do we need to add parenthesis? 
parsed = women.json()
type(parsed)
dict

what is a dict? 2D data. We will look more closely soon.

dir(parsed)
['__class__',
 '__class_getitem__',
 '__contains__',
 '__delattr__',
 '__delitem__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__getitem__',
 '__getstate__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__ior__',
 '__iter__',
 '__le__',
 '__len__',
 '__lt__',
 '__ne__',
 '__new__',
 '__or__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__reversed__',
 '__ror__',
 '__setattr__',
 '__setitem__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 'clear',
 'copy',
 'fromkeys',
 'get',
 'items',
 'keys',
 'pop',
 'popitem',
 'setdefault',
 'update',
 'values']
parsed.keys()
dict_keys(['total', 'objectIDs'])

We access items from a dict with brackets[].

accessing items from a dict#

What is a dictionary anyway?

instructor = {
    'name': ['filipa calado', 'patrick smyth', 'stephen zweibel'],
    'age': [35, 37, 38],
    'degree': ['literature', 'literature', 'library science'],
    'job': ['digital scholarship specialist', 'startup', 'digital scholarship librarian']
}
# see the keys

instructor.keys()
dict_keys(['name', 'age', 'degree', 'job'])
# access items through brackets containing keys

instructor['name']
['filipa calado', 'patrick smyth', 'stephen zweibel']

similar to a DataFrame in pandas#

import pandas as pd
df = pd.DataFrame(instructor)
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[18], line 1
----> 1 import pandas as pd
      2 df = pd.DataFrame(instructor)

ModuleNotFoundError: No module named 'pandas'
df
name age degree job
0 filipa calado 35 literature digital scholarship specialist
1 patrick smyth 37 literature startup
2 stephen zweibel 38 library science digital scholarship librarian
# let's try with the first object

parsed.keys()
dict_keys(['total', 'objectIDs'])

We access items from a dict using brackets.

# just printing out the first ten
parsed['objectIDs'][:10]
[483873,
 207162,
 247582,
 283274,
 483877,
 685333,
 494305,
 481438,
 374147,
 489510]
type(parsed['objectIDs'])
list
parsed['objectIDs'][0]
483873

individual challenge:#

Reading the docs for the “Search” endpoint, play around with the different parameters. Try do searches for isHighlight, or dateBegin and dateEnd. You can layer parameters by using the & character in between them.

using the “objects” endpoint#

So far, we have been using the “search” endpoint for our requests. Now, we will create a new request using the “objects” endpoint”. with data from the original request

Now we past the URL for “object” (rather than search), and we do it within an f-string, putting the variable “first” into curly brackets at the end.

first = parsed['objectIDs'][0]
path = '/public/collection/v1/objects/'
# the base_url stays the same, so we don't need to change it.

url = f"{base_url}{path}{first}"
# running the request

first_object = requests.get(url)
# checking the resulting object

first_object
<Response [200]>
dir(first_object)
['__attrs__',
 '__bool__',
 '__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__enter__',
 '__eq__',
 '__exit__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__getstate__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__iter__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__nonzero__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__setstate__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_content',
 '_content_consumed',
 '_next',
 'apparent_encoding',
 'close',
 'connection',
 'content',
 'cookies',
 'elapsed',
 'encoding',
 'headers',
 'history',
 'is_permanent_redirect',
 'is_redirect',
 'iter_content',
 'iter_lines',
 'json',
 'links',
 'next',
 'ok',
 'raise_for_status',
 'raw',
 'reason',
 'request',
 'status_code',
 'text',
 'url']

look at the json for the first object

# all of the data about this object
# look at the URL! 

first_object.json()
{'objectID': 483873,
 'isHighlight': False,
 'accessionNumber': '1984.613.2',
 'accessionYear': '1984',
 'isPublicDomain': False,
 'primaryImage': '',
 'primaryImageSmall': '',
 'additionalImages': [],
 'constituents': [{'constituentID': 161817,
   'role': 'Artist',
   'name': 'Willem de Kooning',
   'constituentULAN_URL': 'http://vocab.getty.edu/page/ulan/500000974',
   'constituentWikidata_URL': 'https://www.wikidata.org/wiki/Q132305',
   'gender': ''}],
 'department': 'Modern and Contemporary Art',
 'objectName': 'Painting',
 'title': 'Woman',
 'culture': '',
 'period': '',
 'dynasty': '',
 'reign': '',
 'portfolio': '',
 'artistRole': 'Artist',
 'artistPrefix': '',
 'artistDisplayName': 'Willem de Kooning',
 'artistDisplayBio': 'American (born The Netherlands), Rotterdam 1904–1997 East Hampton, New York',
 'artistSuffix': '',
 'artistAlphaSort': 'De Kooning, Willem',
 'artistNationality': 'American, born The Netherlands',
 'artistBeginDate': '1904',
 'artistEndDate': '1997',
 'artistGender': '',
 'artistWikidata_URL': 'https://www.wikidata.org/wiki/Q132305',
 'artistULAN_URL': 'http://vocab.getty.edu/page/ulan/500000974',
 'objectDate': '1944',
 'objectBeginDate': 1944,
 'objectEndDate': 1944,
 'medium': 'Oil and charcoal on canvas',
 'dimensions': '45 7/8 Ă— 31 3/4 in. (116.5 Ă— 80.6 cm)',
 'measurements': [{'elementName': 'Overall',
   'elementDescription': None,
   'elementMeasurements': {'Height': 116.522736, 'Width': 80.645164}},
  {'elementName': 'Frame',
   'elementDescription': 'F.1.1984.613.2 Brown wood float frame-AR Pexi',
   'elementMeasurements': {'Depth': 9.207519,
    'Height': 125.730255,
    'Width': 90.80518}}],
 'creditLine': 'From the Collection of Thomas B. Hess, Gift of the heirs of Thomas B. Hess, 1984',
 'geographyType': '',
 'city': '',
 'state': '',
 'county': '',
 'country': '',
 'region': '',
 'subregion': '',
 'locale': '',
 'locus': '',
 'excavation': '',
 'river': '',
 'classification': 'Paintings',
 'rightsAndReproduction': '© 2025 Artists Rights Society (ARS), New York',
 'linkResource': '',
 'metadataDate': '2025-01-31T04:54:36.6Z',
 'repository': 'Metropolitan Museum of Art, New York, NY',
 'objectURL': 'https://www.metmuseum.org/art/collection/search/483873',
 'tags': [{'term': 'Women',
   'AAT_URL': 'http://vocab.getty.edu/page/aat/300025943',
   'Wikidata_URL': 'https://www.wikidata.org/wiki/Q467'}],
 'objectWikidata_URL': 'https://www.wikidata.org/wiki/Q20189686',
 'isTimelineWork': False,
 'GalleryNumber': ''}
# now we can save this first object to its own variable. 
# will make it easier to do more things to it!

first_json = first_object.json()

individual practice:#

Take a few minutes to inspect the dataset by using different keys.

Why do you think there’s no gender?

# no result!

first_json['artistGender']
''
first_json['department']
'Modern and Contemporary Art'
first_json['culture']
''

looping through our objects#

We are going to create a larger collection of object information (the metadata about each art object in the search results), so that we can loop through the objects to find out more about the artist’s gender.

making a list of ids#

# first, print out the first 10 items in the objectIDs list
parsed['objectIDs'][:10]
[483873,
 207162,
 247582,
 283274,
 483877,
 685333,
 494305,
 481438,
 374147,
 489510]
ids = parsed['objectIDs'][:10]
# remember we can slice our list, to get just the first ten

for item in ids:
    print(item)
483873
207162
247582
283274
483877
685333
494305
481438
374147
489510
type(ids)
list
len(ids)
10

Now let’s go back to the original list, and pull out all the info for the results.

making a new request#

Remember how to make a new request, using an f-string

url = f'{base_url}{path}{item}

Now, add that request to your loop so you make a new request for the first ten items on the list of object IDs. Once you get the response, parse it (with json()) and append that item to a new list.

first_ten = []
for item in ids:
    # passing the objectID variable into the URL
    base_url = 'https://collectionapi.metmuseum.org'
    path = '/public/collection/v1/objects/'
    url = f'{base_url}{path}{item}'
    # grabbing our response for that object
    response = requests.get(url)
    # parsing our response with json
    parsed = response.json()
    # appending the response to our new list
    first_ten.append(parsed)
# because we already know the first, let's check the last item

first_ten[-1]
{'objectID': 489510,
 'isHighlight': False,
 'accessionNumber': '66.75.2',
 'accessionYear': '1966',
 'isPublicDomain': False,
 'primaryImage': '',
 'primaryImageSmall': '',
 'additionalImages': [],
 'constituents': [{'constituentID': 161734,
   'role': 'Artist',
   'name': 'Alexander Calder',
   'constituentULAN_URL': 'http://vocab.getty.edu/page/ulan/500007824',
   'constituentWikidata_URL': 'https://www.wikidata.org/wiki/Q151580',
   'gender': ''}],
 'department': 'Modern and Contemporary Art',
 'objectName': 'Sculpture',
 'title': 'Woman',
 'culture': '',
 'period': '',
 'dynasty': '',
 'reign': '',
 'portfolio': '',
 'artistRole': 'Artist',
 'artistPrefix': '',
 'artistDisplayName': 'Alexander Calder',
 'artistDisplayBio': 'American, Philadelphia, Pennsylvania 1898–1976 New York',
 'artistSuffix': '',
 'artistAlphaSort': 'Calder, Alexander',
 'artistNationality': 'American',
 'artistBeginDate': '1898',
 'artistEndDate': '1976',
 'artistGender': '',
 'artistWikidata_URL': 'https://www.wikidata.org/wiki/Q151580',
 'artistULAN_URL': 'http://vocab.getty.edu/page/ulan/500007824',
 'objectDate': 'ca. 1926',
 'objectBeginDate': 1926,
 'objectEndDate': 1926,
 'medium': 'Stained wood',
 'dimensions': '19 9/16 Ă— 6 7/8 Ă— 6 in., 10.9 lb. (49.7 Ă— 17.5 Ă— 15.3 cm, 4.9 kg)',
 'measurements': [{'elementName': 'Overall',
   'elementDescription': None,
   'elementMeasurements': {'Depth': 15.3,
    'Height': 49.7,
    'Weight': 4.9442077,
    'Width': 17.5}}],
 'creditLine': 'Gift of Charles Oppenheim Jr., 1966',
 'geographyType': '',
 'city': '',
 'state': '',
 'county': '',
 'country': '',
 'region': '',
 'subregion': '',
 'locale': '',
 'locus': '',
 'excavation': '',
 'river': '',
 'classification': 'Sculpture',
 'rightsAndReproduction': '© 2025 Artists Rights Society (ARS), New York',
 'linkResource': '',
 'metadataDate': '2025-01-08T04:53:43.917Z',
 'repository': 'Metropolitan Museum of Art, New York, NY',
 'objectURL': 'https://www.metmuseum.org/art/collection/search/489510',
 'tags': [{'term': 'Women',
   'AAT_URL': 'http://vocab.getty.edu/page/aat/300025943',
   'Wikidata_URL': 'https://www.wikidata.org/wiki/Q467'}],
 'objectWikidata_URL': '',
 'isTimelineWork': False,
 'GalleryNumber': ''}

now guess what type of data we have for first_ten?

type(first_ten)
list

group challenge:#

Write a loop to print out information about some of the keys for each object. For example, print out the value of artistDisplayName.

for item in first_ten:
    print(item['artistDisplayName'])
Willem de Kooning
Royal Porcelain Manufactory, Naples
Woman Painter
Man Ray
Willem de Kooning
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[38], line 2
      1 for item in first_ten:
----> 2     print(item['artistDisplayName'])

KeyError: 'artistDisplayName'

let’s look at some of the values

for item in first_ten:
    print(item['title'])
Woman
Woman
Terracotta lekythos (oil flask)
Woman
Woman
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[39], line 2
      1 for item in first_ten:
----> 2     print(item['title'])

KeyError: 'title'

There’s another way to grab items from a dict, using the get() method.

dir(item)
['__class__',
 '__class_getitem__',
 '__contains__',
 '__delattr__',
 '__delitem__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__getitem__',
 '__getstate__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__ior__',
 '__iter__',
 '__le__',
 '__len__',
 '__lt__',
 '__ne__',
 '__new__',
 '__or__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__reversed__',
 '__ror__',
 '__setattr__',
 '__setitem__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 'clear',
 'copy',
 'fromkeys',
 'get',
 'items',
 'keys',
 'pop',
 'popitem',
 'setdefault',
 'update',
 'values']
for item in first_ten:
    if item.get('artistDisplayName'):
        print(item['artistDisplayName'])
Willem de Kooning
Royal Porcelain Manufactory, Naples
Woman Painter
Man Ray
Willem de Kooning
Joan MirĂł
Willem de Kooning
Harold Anchel
Alexander Calder
for item in first_ten:
    title = item.get('artistDisplayName')
    print(title)
Willem de Kooning
Royal Porcelain Manufactory, Naples
Woman Painter
Man Ray
Willem de Kooning
None
Joan MirĂł
Willem de Kooning
Harold Anchel
Alexander Calder

about “women”#

Let’s make our dataset bigger, with 50 works.

first_fifty = []
for item in parsed['objectIDs'][:50]:
    url = f'https://collectionapi.metmuseum.org/public/collection/v1/objects/{item}'
    response = requests.get(url)
    parsed = response.json()
    first_fifty.append(parsed)
# combine get() with conditional to get rid of the None's

for item in first_fifty:
    if item.get('artistDisplayName'):
        print(item['artistDisplayName'])
# or, if we want to show the value, even if empty or None

for item in first_hundred:
    gender = item.get('artistGender')
    print(gender)
None


None





None









None





































Female














Female



Female

Let’s use get() combined with f-strings to print both the name and the gender.

# why do you think we see only female?

for item in first_fifty:
    if item.get('artistDisplayName'):
        print(f"artist name: {item['artistDisplayName']}")
        print(f"artist gender: {item['artistGender']}")
artist name: Willem de Kooning
artist gender: 
artist name: Royal Porcelain Manufactory, Naples
artist gender: 
artist name: Woman Painter
artist gender: 
artist name: Man Ray
artist gender: 
artist name: Willem de Kooning
artist gender: 
artist name: Joan MirĂł
artist gender: 
artist name: Willem de Kooning
artist gender: 
artist name: Alexander Calder
artist gender: 
artist name: Harold Anchel
artist gender: 
artist name: Malick Sidibé
artist gender: 
artist name: Joan MirĂł
artist gender: 
artist name: Joan MirĂł
artist gender: 
artist name: Lorenzo Mosca
artist gender: 
artist name: Bow Porcelain Factory
artist gender: 
artist name: Royal Porcelain Manufactory, Berlin
artist gender: 
artist name: Vienna
artist gender: 
artist name: Edgar Degas
artist gender: 
artist name: Gaston Lachaise
artist gender: 
artist name: Fernand Léger
artist gender: 
artist name: Edgar Degas
artist gender: 
artist name: Frans Hals
artist gender: 
artist name: Jean Dubuffet
artist gender: 
artist name: Edgar Degas
artist gender: 
artist name: Fra Filippo Lippi
artist gender: 
artist name: Rembrandt (Rembrandt van Rijn)
artist gender: 
artist name: Gustave Courbet
artist gender: 
artist name: Quinten Massys
artist gender: 
artist name: Jean-François Millet
artist gender: 
artist name: Henri Fantin-Latour
artist gender: 
artist name: Charles-Henri-Joseph Cordier
artist gender: 
artist name: Louis Anquetin
artist gender: 
artist name: Pablo Picasso
artist gender: 
artist name: Bastis Master
artist gender: 
artist name: Ruth Ava Lyons
artist gender: Female
artist name: Christian Julia
artist gender: 
artist name: Johannes Vermeer
artist gender: 
artist name: Georges Braque
artist gender: 
artist name: Gustave Courbet
artist gender: 
artist name: Johannes Vermeer
artist gender: 
artist name: Orazio Borgianni
artist gender: 
artist name: Antoine Watteau
artist gender: 
artist name: Johannes Vermeer
artist gender: 
artist name: Berthe Morisot
artist gender: Female
artist name: Charles-Henri-Joseph Cordier
artist gender: 
artist name: Gustave Courbet
artist gender: 
artist name: Louise Bourgeois
artist gender: Female
artist name: Edgar Degas
artist gender: 
artist name: Rembrandt (Rembrandt van Rijn)
artist gender: 
artist name: Petrus Christus
artist gender: 
artist name: Léon Bonnat
artist gender: 
artist name: Pablo Picasso
artist gender: 
artist name: Master of Rimini
artist gender: 

saving to DataFrame#

# look again at the first object
first_fifty[0]
{'objectID': 483873,
 'isHighlight': False,
 'accessionNumber': '1984.613.2',
 'accessionYear': '1984',
 'isPublicDomain': False,
 'primaryImage': '',
 'primaryImageSmall': '',
 'additionalImages': [],
 'constituents': [{'constituentID': 161817,
   'role': 'Artist',
   'name': 'Willem de Kooning',
   'constituentULAN_URL': 'http://vocab.getty.edu/page/ulan/500000974',
   'constituentWikidata_URL': 'https://www.wikidata.org/wiki/Q132305',
   'gender': ''}],
 'department': 'Modern and Contemporary Art',
 'objectName': 'Painting',
 'title': 'Woman',
 'culture': '',
 'period': '',
 'dynasty': '',
 'reign': '',
 'portfolio': '',
 'artistRole': 'Artist',
 'artistPrefix': '',
 'artistDisplayName': 'Willem de Kooning',
 'artistDisplayBio': 'American (born The Netherlands), Rotterdam 1904–1997 East Hampton, New York',
 'artistSuffix': '',
 'artistAlphaSort': 'De Kooning, Willem',
 'artistNationality': 'American, born The Netherlands',
 'artistBeginDate': '1904',
 'artistEndDate': '1997',
 'artistGender': '',
 'artistWikidata_URL': 'https://www.wikidata.org/wiki/Q132305',
 'artistULAN_URL': 'http://vocab.getty.edu/page/ulan/500000974',
 'objectDate': '1944',
 'objectBeginDate': 1944,
 'objectEndDate': 1944,
 'medium': 'Oil and charcoal on canvas',
 'dimensions': '45 7/8 Ă— 31 3/4 in. (116.5 Ă— 80.6 cm)',
 'measurements': [{'elementName': 'Overall',
   'elementDescription': None,
   'elementMeasurements': {'Height': 116.522736, 'Width': 80.645164}},
  {'elementName': 'Frame',
   'elementDescription': 'F.1.1984.613.2 Brown wood float frame-AR Pexi',
   'elementMeasurements': {'Depth': 9.207519,
    'Height': 125.730255,
    'Width': 90.80518}}],
 'creditLine': 'From the Collection of Thomas B. Hess, Gift of the heirs of Thomas B. Hess, 1984',
 'geographyType': '',
 'city': '',
 'state': '',
 'county': '',
 'country': '',
 'region': '',
 'subregion': '',
 'locale': '',
 'locus': '',
 'excavation': '',
 'river': '',
 'classification': 'Paintings',
 'rightsAndReproduction': '© 2024 Artists Rights Society (ARS), New York',
 'linkResource': '',
 'metadataDate': '2024-09-21T04:53:05.127Z',
 'repository': 'Metropolitan Museum of Art, New York, NY',
 'objectURL': 'https://www.metmuseum.org/art/collection/search/483873',
 'tags': [{'term': 'Women',
   'AAT_URL': 'http://vocab.getty.edu/page/aat/300025943',
   'Wikidata_URL': 'https://www.wikidata.org/wiki/Q467'}],
 'objectWikidata_URL': 'https://www.wikidata.org/wiki/Q20189686',
 'isTimelineWork': False,
 'GalleryNumber': ''}
# let's get a bunch of this data into lists

titles = []
names = []
genders = []
depts = []
countries = []
urls = []

for item in first_fifty:
    title = item.get('artistGender')
    titles.append(title)
    name = item.get('artistDisplayName')
    names.append(name)
    gender = item.get('artistGender')
    genders.append(gender)
    dept = item.get('department')
    depts.append(dept)
    country = item.get('country')
    countries.append(country)
    url = item.get('objectURL')
    urls.append(url)
countries
['',
 '',
 '',
 '',
 '',
 None,
 '',
 '',
 None,
 '',
 '',
 'Mali',
 '',
 '',
 None,
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 None,
 'Egypt',
 'Egypt',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 'Egypt',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 'France',
 '',
 'Egypt',
 '',
 'Egypt',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 'Turkey',
 '',
 '',
 'Byzantine Egypt',
 'Egypt',
 '',
 '',
 'Egypt',
 '',
 '',
 '',
 '',
 'Egypt',
 '',
 '',
 '',
 '',
 '',
 '',
 'Egypt',
 'Egypt',
 '',
 'Egypt',
 'Egypt',
 'Egypt',
 '',
 'Egypt',
 'Egypt',
 '',
 'Egypt',
 '',
 'Egypt',
 '',
 '',
 '',
 'Egypt']
depts
['Modern and Contemporary Art',
 'European Sculpture and Decorative Arts',
 'Greek and Roman Art',
 'Photographs',
 'Modern and Contemporary Art',
 None,
 'Modern and Contemporary Art',
 'Modern and Contemporary Art',
 None,
 'Modern and Contemporary Art',
 'Drawings and Prints',
 'The Michael C. Rockefeller Wing',
 'Modern and Contemporary Art',
 'Modern and Contemporary Art',
 None,
 'European Sculpture and Decorative Arts',
 'European Sculpture and Decorative Arts',
 'European Sculpture and Decorative Arts',
 'European Sculpture and Decorative Arts',
 'European Sculpture and Decorative Arts',
 'European Sculpture and Decorative Arts',
 'European Sculpture and Decorative Arts',
 'European Paintings',
 'Modern and Contemporary Art',
 None,
 'Egyptian Art',
 'Egyptian Art',
 'Greek and Roman Art',
 'Modern and Contemporary Art',
 'Medieval Art',
 'European Sculpture and Decorative Arts',
 'European Paintings',
 'Greek and Roman Art',
 'Greek and Roman Art',
 'Egyptian Art',
 'Modern and Contemporary Art',
 'European Paintings',
 'European Paintings',
 'Egyptian Art',
 'European Paintings',
 'European Paintings',
 'Greek and Roman Art',
 'Egyptian Art',
 'European Paintings',
 'Greek and Roman Art',
 'Greek and Roman Art',
 'Greek and Roman Art',
 'Greek and Roman Art',
 'Greek and Roman Art',
 'European Paintings',
 'European Paintings',
 'European Sculpture and Decorative Arts',
 'Drawings and Prints',
 'Modern and Contemporary Art',
 'Egyptian Art',
 'Greek and Roman Art',
 'Egyptian Art',
 'Greek and Roman Art',
 'Egyptian Art',
 'Greek and Roman Art',
 'Greek and Roman Art',
 'Greek and Roman Art',
 'Drawings and Prints',
 'Drawings and Prints',
 'Islamic Art',
 'European Paintings',
 'Modern and Contemporary Art',
 'Medieval Art',
 'Egyptian Art',
 'European Paintings',
 'European Paintings',
 'Egyptian Art',
 'European Paintings',
 'Greek and Roman Art',
 'Robert Lehman Collection',
 'European Paintings',
 'Egyptian Art',
 'European Paintings',
 'European Sculpture and Decorative Arts',
 'European Paintings',
 'Greek and Roman Art',
 'Drawings and Prints',
 'European Sculpture and Decorative Arts',
 'Egyptian Art',
 'Egyptian Art',
 'European Paintings',
 'Egyptian Art',
 'Egyptian Art',
 'Egyptian Art',
 'Robert Lehman Collection',
 'Egyptian Art',
 'Egyptian Art',
 'European Paintings',
 'Egyptian Art',
 'Greek and Roman Art',
 'Egyptian Art',
 'Modern and Contemporary Art',
 'The Cloisters',
 'Medieval Art',
 'Egyptian Art']
urls
['https://www.metmuseum.org/art/collection/search/483873',
 'https://www.metmuseum.org/art/collection/search/207162',
 'https://www.metmuseum.org/art/collection/search/247582',
 'https://www.metmuseum.org/art/collection/search/283274',
 'https://www.metmuseum.org/art/collection/search/483877',
 None,
 'https://www.metmuseum.org/art/collection/search/494305',
 'https://www.metmuseum.org/art/collection/search/481438',
 None,
 'https://www.metmuseum.org/art/collection/search/489510',
 'https://www.metmuseum.org/art/collection/search/374147',
 'https://www.metmuseum.org/art/collection/search/515811',
 'https://www.metmuseum.org/art/collection/search/492892',
 'https://www.metmuseum.org/art/collection/search/486510',
 None,
 'https://www.metmuseum.org/art/collection/search/204181',
 'https://www.metmuseum.org/art/collection/search/205376',
 'https://www.metmuseum.org/art/collection/search/193453',
 'https://www.metmuseum.org/art/collection/search/195502',
 'https://www.metmuseum.org/art/collection/search/193045',
 'https://www.metmuseum.org/art/collection/search/200897',
 'https://www.metmuseum.org/art/collection/search/208482',
 'https://www.metmuseum.org/art/collection/search/436173',
 'https://www.metmuseum.org/art/collection/search/483484',
 None,
 'https://www.metmuseum.org/art/collection/search/548584',
 'https://www.metmuseum.org/art/collection/search/551500',
 'https://www.metmuseum.org/art/collection/search/253505',
 'https://www.metmuseum.org/art/collection/search/486423',
 'https://www.metmuseum.org/art/collection/search/467700',
 'https://www.metmuseum.org/art/collection/search/196462',
 'https://www.metmuseum.org/art/collection/search/436616',
 'https://www.metmuseum.org/art/collection/search/255391',
 'https://www.metmuseum.org/art/collection/search/251428',
 'https://www.metmuseum.org/art/collection/search/547202',
 'https://www.metmuseum.org/art/collection/search/486578',
 'https://www.metmuseum.org/art/collection/search/436121',
 'https://www.metmuseum.org/art/collection/search/436896',
 'https://www.metmuseum.org/art/collection/search/547334',
 'https://www.metmuseum.org/art/collection/search/437402',
 'https://www.metmuseum.org/art/collection/search/436002',
 'https://www.metmuseum.org/art/collection/search/254469',
 'https://www.metmuseum.org/art/collection/search/560727',
 'https://www.metmuseum.org/art/collection/search/436986',
 'https://www.metmuseum.org/art/collection/search/254597',
 'https://www.metmuseum.org/art/collection/search/253135',
 'https://www.metmuseum.org/art/collection/search/249222',
 'https://www.metmuseum.org/art/collection/search/253050',
 'https://www.metmuseum.org/art/collection/search/248132',
 'https://www.metmuseum.org/art/collection/search/437099',
 'https://www.metmuseum.org/art/collection/search/436295',
 'https://www.metmuseum.org/art/collection/search/232047',
 'https://www.metmuseum.org/art/collection/search/334249',
 'https://www.metmuseum.org/art/collection/search/486845',
 'https://www.metmuseum.org/art/collection/search/544210',
 'https://www.metmuseum.org/art/collection/search/252452',
 'https://www.metmuseum.org/art/collection/search/587759',
 'https://www.metmuseum.org/art/collection/search/249091',
 'https://www.metmuseum.org/art/collection/search/547257',
 'https://www.metmuseum.org/art/collection/search/255417',
 'https://www.metmuseum.org/art/collection/search/255275',
 'https://www.metmuseum.org/art/collection/search/248689',
 'https://www.metmuseum.org/art/collection/search/389226',
 'https://www.metmuseum.org/art/collection/search/839042',
 'https://www.metmuseum.org/art/collection/search/451943',
 'https://www.metmuseum.org/art/collection/search/437881',
 'https://www.metmuseum.org/art/collection/search/486742',
 'https://www.metmuseum.org/art/collection/search/464456',
 'https://www.metmuseum.org/art/collection/search/550970',
 'https://www.metmuseum.org/art/collection/search/436024',
 'https://www.metmuseum.org/art/collection/search/437879',
 'https://www.metmuseum.org/art/collection/search/544689',
 'https://www.metmuseum.org/art/collection/search/441024',
 'https://www.metmuseum.org/art/collection/search/247004',
 'https://www.metmuseum.org/art/collection/search/459192',
 'https://www.metmuseum.org/art/collection/search/437880',
 'https://www.metmuseum.org/art/collection/search/547860',
 'https://www.metmuseum.org/art/collection/search/437160',
 'https://www.metmuseum.org/art/collection/search/231788',
 'https://www.metmuseum.org/art/collection/search/436004',
 'https://www.metmuseum.org/art/collection/search/249223',
 'https://www.metmuseum.org/art/collection/search/371017',
 'https://www.metmuseum.org/art/collection/search/196452',
 'https://www.metmuseum.org/art/collection/search/555567',
 'https://www.metmuseum.org/art/collection/search/554337',
 'https://www.metmuseum.org/art/collection/search/437390',
 'https://www.metmuseum.org/art/collection/search/546746',
 'https://www.metmuseum.org/art/collection/search/547758',
 'https://www.metmuseum.org/art/collection/search/547476',
 'https://www.metmuseum.org/art/collection/search/459052',
 'https://www.metmuseum.org/art/collection/search/547820',
 'https://www.metmuseum.org/art/collection/search/543905',
 'https://www.metmuseum.org/art/collection/search/435711',
 'https://www.metmuseum.org/art/collection/search/566713',
 'https://www.metmuseum.org/art/collection/search/255697',
 'https://www.metmuseum.org/art/collection/search/568194',
 'https://www.metmuseum.org/art/collection/search/500194',
 'https://www.metmuseum.org/art/collection/search/468716',
 'https://www.metmuseum.org/art/collection/search/466235',
 'https://www.metmuseum.org/art/collection/search/550158']

data anlaysis with pandas#

import pandas as pd
df = pd.DataFrame({
    'title': titles,
    'name': names,
    'gender': genders,
    'department': depts,
    'country': countries,
    'link': urls
})
df
title name gender department country link
0 Willem de Kooning Modern and Contemporary Art https://www.metmuseum.org/art/collection/searc...
1 Royal Porcelain Manufactory, Naples European Sculpture and Decorative Arts https://www.metmuseum.org/art/collection/searc...
2 Woman Painter Greek and Roman Art https://www.metmuseum.org/art/collection/searc...
3 Man Ray Photographs https://www.metmuseum.org/art/collection/searc...
4 Willem de Kooning Modern and Contemporary Art https://www.metmuseum.org/art/collection/searc...
... ... ... ... ... ... ...
95 Egyptian Art Egypt https://www.metmuseum.org/art/collection/searc...
96 Pablo Picasso Modern and Contemporary Art https://www.metmuseum.org/art/collection/searc...
97 The Cloisters https://www.metmuseum.org/art/collection/searc...
98 Master of Rimini Medieval Art https://www.metmuseum.org/art/collection/searc...
99 Egyptian Art Egypt https://www.metmuseum.org/art/collection/searc...

100 rows Ă— 6 columns

df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 100 entries, 0 to 99
Data columns (total 6 columns):
 #   Column      Non-Null Count  Dtype 
---  ------      --------------  ----- 
 0   title       96 non-null     object
 1   name        96 non-null     object
 2   gender      96 non-null     object
 3   department  96 non-null     object
 4   country     96 non-null     object
 5   link        96 non-null     object
dtypes: object(6)
memory usage: 4.8+ KB
df.value_counts('department')
department
Egyptian Art                              21
European Paintings                        18
Greek and Roman Art                       18
Modern and Contemporary Art               13
European Sculpture and Decorative Arts    12
Drawings and Prints                        5
Medieval Art                               3
Robert Lehman Collection                   2
Islamic Art                                1
Photographs                                1
The Cloisters                              1
The Michael C. Rockefeller Wing            1
Name: count, dtype: int64
df.department.value_counts().plot(kind = 'barh')
<Axes: ylabel='department'>
../_images/810b06ae7dadf9ab79389810ac522118e2ab0016fb51ff889d01dbaaf8039010.png
df.department.value_counts().plot(kind = 'pie')
<Axes: ylabel='count'>
../_images/2f31712e9db59c0af4594e4c663940336f2cdd94a38e2ae5517f13212ae52ecd.png