LOC.gov JSON API Guide#

The Library of Congress has created an API to allow for automated processes to interact with its collections data. The way that we interact with this data is through JSON.

What is JSON?#

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.

What skills do you need to navigate it?#

  • Reading

  • Curiosity

  • A willingness to try (and maybe mess up and then try again)

What can you do with it?#

Explore, discover, and make cool stuff! Let’s look at some examples you can try:

Ok so I got some text that looks like gibberish, now what?#

Now we can use a bit of Python to do cool stuff with it! Want to see all of the titles of the Library of Congress collections? Sure, let’s try it!

collections_json = requests.get("https://www.loc.gov/collections/?fo=json").json()

for collection in collections_json["results"]:
    print(collection["title"])
10th-16th Century Liturgical Chants
Aaron Copland Collection
Abdul Hamid II Collection
Abdul-Hamid II Collection of Books and Serials Gifted to the Library of Congress
Abraham Lincoln Papers at the Library of Congress
Afghanistan Web Archive
Afghanistan, Iran, Pakistan and Tajikistan Government Web Archive
Afghanistan, Iran, Pakistan, and Tajikistan Elections Web Archive
African American Perspectives: Materials Selected from the Rare Book Collection
African American Photographs Assembled for 1900 Paris Exposition
African Government Web Archive
African-American Band Music & Recordings, 1883-1923
After the Day of Infamy: "Man-on-the-Street" Interviews Following the Attack on Pearl Harbor
Ainu and Ezochi Rare Collection
Alan Lomax Collection
Alan Lomax Collection of Michigan and Wisconsin Recordings
Albert Schatz Collection
Alexander Graham Bell Family Papers at the Library of Congress
Alexander Hamilton Papers
Alexander Hamilton Stephens Papers
The Alfred Whital Stern Collection of Lincolniana
Amazing Grace
America at Work, America at Leisure: Motion Pictures from 1894-1915
America Singing: Nineteenth-Century Song Sheets
An American Ballroom Companion: Dance Instruction Manuals, ca. 1490-1920
American Choral Music
American Civil War Sesquicentennial Web Archive
American Colony in Jerusalem, 1870-2006
American English Dialect Recordings: The Center for Applied Linguistics Collection
American Federation of Labor Records
American Leaders Speak: Recordings from World War I
American Life Histories: Manuscripts from the Federal Writers' Project, 1936-1940
American Music Creators Web Archive
American Music Industry Web Archive
American Notes: Travels in America, 1750-1920
American Revolution and Its Era: Maps and Charts of North America and the West Indies, 1750-1789
American Variety Stage: Vaudeville and Popular Entertainment, 1870-1920
Ancestral Voices
Andre Kostelanetz Collection
Andrew Jackson Papers

Why does it stop after 40?#

You might be thinking “there must be colletions after “B”… and you’re correct. If we were to give you the data for all our collections it would take a really long time to return the information. So instead we break it into pages. The pagination section of the json contains the information that you need to really get everything (this list is going to be LONG!):

collections_json = requests.get("https://www.loc.gov/collections/?fo=json").json()

while True: #As long as we have a next page, go and fetch it
    for collection in collections_json["results"]: 
        print(collection["title"]) #print out the collection's title
    next_page = collections_json["pagination"]["next"] #get the next page url
    if next_page is not None: #make sure we haven't hit the end of the pages
        collections_json = requests.get(next_page).json()
    else:
        break #we are done and can stop looping
10th-16th Century Liturgical Chants
Aaron Copland Collection
Abdul Hamid II Collection
Abdul-Hamid II Collection of Books and Serials Gifted to the Library of Congress
Abraham Lincoln Papers at the Library of Congress
Afghanistan Web Archive
Afghanistan, Iran, Pakistan and Tajikistan Government Web Archive
Afghanistan, Iran, Pakistan, and Tajikistan Elections Web Archive
African American Perspectives: Materials Selected from the Rare Book Collection
African American Photographs Assembled for 1900 Paris Exposition
African Government Web Archive
African-American Band Music & Recordings, 1883-1923
After the Day of Infamy: "Man-on-the-Street" Interviews Following the Attack on Pearl Harbor
Ainu and Ezochi Rare Collection
Alan Lomax Collection
Alan Lomax Collection of Michigan and Wisconsin Recordings
Albert Schatz Collection
Alexander Graham Bell Family Papers at the Library of Congress
Alexander Hamilton Papers
Alexander Hamilton Stephens Papers
The Alfred Whital Stern Collection of Lincolniana
Amazing Grace
America at Work, America at Leisure: Motion Pictures from 1894-1915
America Singing: Nineteenth-Century Song Sheets
An American Ballroom Companion: Dance Instruction Manuals, ca. 1490-1920
American Choral Music
American Civil War Sesquicentennial Web Archive
American Colony in Jerusalem, 1870-2006
American English Dialect Recordings: The Center for Applied Linguistics Collection
American Federation of Labor Records
American Leaders Speak: Recordings from World War I
American Life Histories: Manuscripts from the Federal Writers' Project, 1936-1940
American Music Creators Web Archive
American Music Industry Web Archive
American Notes: Travels in America, 1750-1920
American Revolution and Its Era: Maps and Charts of North America and the West Indies, 1750-1789
American Variety Stage: Vaudeville and Popular Entertainment, 1870-1920
Ancestral Voices
Andre Kostelanetz Collection
Andrew Jackson Papers
Andrew Johnson Papers
Anna E. Dickinson Papers
Anna Maria Brodeau Thornton Papers
Ansel Adams's Photographs of Japanese-American Internment at Manzanar
Architecture, Design & Engineering Drawings
Archive of Hispanic Literature on Tape
Archive of Recorded Poetry and Literature
Armenian Rarities Collection
Associated Press News Dispatches, 1915-1930
Author Websites Web Archive
Bain Collection
Ballets Russes de Serge Diaghilev
Band Music from the Civil War Era
Bangladeshi Elections Web Archive
Banking Industry in Southeast Asia Web Archive
Baseball Cards
Baseball Sheet Music
Before and After the Great Earthquake and Fire: Early Films of San Francisco, 1897-1916
Benjamin Franklin Papers
Benjamin Harrison Papers
Bess Lomax Hawes Collection
Betty Herndon Maury Maury Papers
Blackwell Family Papers
Blue Ridge Parkway Folklife Project
Books About Music Before 1800
Born in Slavery: Slave Narratives from the Federal Writers' Project, 1936-1938
Brady-Handy Collection
Branch Rickey Papers
Brazil Cordel Literature Web Archive
Brazilian Elections Web Archive
Bronislava Nijinska Collection
Brumfield Collection
Buckaroos in Paradise: Ranching Culture in Northern Nevada, 1945-1982
Burma/Myanmar Elections Web Archive
Business in America Web Archive
By Popular Demand: Jackie Robinson and Other Baseball Highlights, 1860s-1960s
Cabinet of American Illustration
California as I Saw It: First-Person Narratives of California's Early Years, 1849-1900
California Gold: Northern California Folk Music from the Thirties Collected by Sidney Robertson Cowell
Cambini Quintets
Cambodian Elections Web Archive
Capital and the Bay: Narratives of Washington and the Chesapeake Bay Region, 1600-1925
Captain Pearl R. Nye: Life on the Ohio and Erie Canal
The Carnegie Hall Collection of Conversations with Composers
Carnegie Survey of the Architecture of the South
Carpenter Collection
Carrie Chapman Catt Papers
Cartoon Drawings
Cartoon Drawings: Herblock Collection
Cartoon Drawings: Swann Collection of Caricature and Cartoon
Cartoon Prints, American
Cartoon Prints, British
Case Books
A Century of Lawmaking for a New Nation: U.S. Congressional Documents and Debates 1774-1875
Charles S. Hamlin Papers
Charles Wellington Reed Papers, 1776 to 1926
Chester Alan Arthur Papers
Chicago Ethnic Arts Project Collection
Children's Book Selections
China-Pakistan Economic Corridor (CPEC) 2018-2020 Web Archive
Chinese Rare Book Digital Collection
Chronicling America
Cities and Towns
Civil Rights History Project
Civil War
Civil War Glass Negatives and Related Prints
Civil War Maps
Civil War Sheet Music Collection
Civil War Soldier in the Wild Cat Regiment : Selections from the Tilton C. Reynolds Papers
Clara Barton Papers
Code of Federal Regulations
College Women's Association of Japan Print Show Collection
Colorado Folklife Project Collection
Comics Literature and Criticism Web Archive
Confederate States of America Records
Coptic Orthodox Liturgical Chant and Hymnody
Country Studies
Crisis in Darfur 2006 Web Archive
Curtis (Edward S.) Collection
Daguerreotypes
The Danny Kaye and Sylvia Fine Collection
Dayton C. Miller Collection
Department of Defense Annual Reports (1948-1996) and Military Branch Budget Justification Books (1980-1996)
Detroit Publishing Company
The Different Faces of Nationalism in Pakistan Web Archive
Directory of US Newspapers in American Libraries
Discovery and Exploration
Documents from the Continental Congress and the Constitutional Convention, 1774-1789
Dolly Parton and the Roots of Country Music
Donald Benham Civil War Collection
Drawings (Documentary)
Drawings (Master)
E. B. Washburne Papers
Early American Sheet Music
Early Copyright Records Collection, 1790 to 1870
East European Government Ministries Web Archive
Economics Blogs Web Archive
Edwin McMasters Stanton Papers, 1818-1921
Egypt 2008 Web Archive
Egyptian Elections Web Archive
Elizabeth Cady Stanton Papers
Elliott Carter Collection
Eltaher Collection
Emile Berliner and the Birth of the Recording Industry
Ernest Bloch Collection
Eugene Meyer Papers
Event Videos
The Evolution of the Conservation Movement
Executive Branch Federal Government Web Archive
Farm Security Administration/Office of War Information Black-and-White Negatives
Farm Security Administration/Office of War Information Color Photographs
Federal Advisory Committee Web Archive
Federal Courts Web Archive
Federal Register
Federal Theatre Project, 1935 to 1939
Felix Mendelssohn at the Library of Congress
Fenton Crimean War Photographs
Fiddle Tunes of the Old Frontier: The Henry Reed Collection
Finding Our Place in the Cosmos: From Galileo to Sagan and Beyond
Fine Prints
Fine Prints: Japanese, pre-1915
Florida Folklife from the WPA Collections, 1937-1942
Food and Foodways Web Archive
Foreign Law Web Archive
France in America
Franklin Pierce Papers
Franz Liszt at the Library of Congress
Frederick Douglass Newspapers, 1847-1874
Frederick Douglass Papers at the Library of Congress
Frederick Law Olmsted Papers
Freedom's Fortress: The Library of Congress, 1939-1953
Frontline Diplomacy: The Foreign Affairs Oral History Collection of the Association for Diplomatic Studies and Training
Gaetano Brunetti Manuscript Scores
General Maps
General News on the Internet Web Archive
Genthe Collection
Geographers on Film
George Brinton McClellan Papers
George S. Patton Papers: Diaries, 1910-1945
George Washington Papers
The Gerry Mulligan Collection
Gideon Welles Papers
Gladstone Collection of African American Photographs
Goldstein Foundation Collection--Prints and Drawings
Gottscho-Schleisner Collection
Grabill Collection
Great Conversations in Music
Groups of Images (LOTs)
Guide Records
Hannah Arendt Papers
Harris & Ewing Collection
Herndon-Weik Collection of Lincolniana
Hidden Treasures at the Library of Congress
Highsmith (Carol M.) Archive
Hispano Music and Culture of the Northern Rio Grande: The Juan B. Rael Collection
Historic American Buildings Survey/Historic American Engineering Record/Historic American Landscapes Survey
Historic Sheet Music Collection, 1800-1922
Home Sweet Home: Life in Nineteenth-Century Ohio
Horace Greeley Papers
Horace H. Lurton Papers
Horydczak Collection
Hotchkiss Map Collection
Ilka Kolsky Artwork
Indian Elections Web Archive
Indigenous Law Web Archive
Indonesian Elections Web Archive
Inside an American Factory: Films of the Westinghouse Works, 1904
International Tribunals Web Archive
Inventing Entertainment: The Early Motion Pictures and Sound Recordings of the Edison Companies
Iraq War 2003 Web Archive
Irving Fine Collection, ca. 1914-1962
James A. Garfield Papers
James Buchanan and Harriet Lane Johnston Papers
James K. Polk Papers
James Madison Papers, 1723-1859
James Monroe Papers
Japanese Censorship Collection
Japanese-American Internment Camp Newspapers, 1942-1946
Jazz on the Screen Filmography
Jedediah Hotchkiss Papers
Joe Smith
John Carvel Arnold Papers
John G. Nicolay Papers
John J. Pershing Papers
John Tyler Papers
Johnston (Frances Benjamin) Collection
Joseph Holt Papers
Jubal Anderson Early Papers
Korab Collection
Lamb Studios Archive
Laotian Elections Web Archive
Lars Schmidt Collection
Last Days of a President: Films of McKinley and the Pan-American Exposition, 1901
Lawrence & Houseworth Collection
LC Commissioned Composers Web Archive
Legal Blawgs Web Archive
Legislative Branch Web Archive
Leonard Bernstein
Lessing J. Rosenwald Collection
Lewis Carroll Scrapbooks
Lewis H. Machen Family Papers
LGBTQ+ Politics and Political Candidates Web Archive
LGBTQ+ Studies Web Archive
The Library of Congress Celebrates the Songs of America
Library of Congress Concerts
Library of Congress Websites Web Archive
The Life of a City: Early Films of New York, 1898-1906
Liljenquist Family Collection of Civil War Photographs
Lomax Collection
Look Collection
Louisiana: European Explorations and the Louisiana Purchase
Lowell Folklife Project Collection
Macedonian Politics Web Archive
Maine Acadian Cultural Survey Collection
Malaysian Elections Web Archive
Manuscript Division Web Archive
Manuscripts from the Monasteries of Mt. Athos
Manuscripts in St. Catherine's Monastery, Mount Sinai
Manuscripts in the Libraries of the Greek and Armenian Patriarchates in Jerusalem
Mapping the National Parks
Maps of Liberia, 1830-1870
The March King: John Philip Sousa
Margaret Bayard Smith Papers
Martha Graham at the Library of Congress
Martin Van Buren Papers, 1787 to 1910
Mary Ann Bickerdyke Papers
Mary Church Terrell Papers
Matson (G. Eric and Edith) Photograph Collection
Meeting of Frontiers
Middle East/North Africa Government Institutions Web Archive
Military Battles and Campaigns
Millard Fillmore Papers
The Moldenhauer Archives - The Rosaleen Moldenhauer Memorial
Montana Folklife Survey Collection
Music for the Nation: American Sheet Music, ca. 1820-1860
Music for the Nation: American Sheet Music, ca. 1870-1885
Music Treasures Consortium
Musical Instruments at the Library of Congress
Nathan W. Daniels Diary and Scrapbook
National American Woman Suffrage Association Collection
National American Woman Suffrage Association Records
National Child Labor Committee Collection
National Jukebox
National Photo Company Collection
National Screening Room
National Transportation Safety Board Orders, Petitions, and Decisions
Nelson W. Aldrich Papers
New Mexico Folklife Project Collection
New York Journal and Related Titles, 1896-1899
Newspaper Pictorials: World War I Rotogravures, 1914-1919
North Korean Serials
Now What a Time: Blues, Gospel, and the Fort Valley Music Festivals, 1938-1943
Occupational Folklife Project
Olmsted Associates Records
Omaha Indian Music
Omar Ibn Said Collection
Origins of American Animation
Panoramic Maps
Panoramic Photographs
Papal Transition 2005 Web Archive
Papal Transition 2013 Web Archive
Patriotic Melodies
Performing Arts Web Archive
Persian Language Rare Materials
PH Filing Series Photographs
Philip Henry Sheridan Papers
Philippine Elections Web Archive
Phillips/Mathée Collection
Photochrom Prints
Pioneering the Upper Midwest: Books from Michigan, Minnesota, and Wisconsin, ca. 1820-1910
Polish Declarations of Admiration and Friendship for the United States, 1926
Political Islam Web Archive
Popular Graphic Arts
Posters: Artist Posters
Posters: Performing Arts Posters
Posters: Spanish Civil War Posters
Posters: World War I Posters
Posters: WPA Posters
Posters: Yanker Poster Collection
Prairie Settlement: Nebraska Photographs and Family Letters, 1862-1912
Pre-1700 Musical Treasures: Manuscript and Print Collection
Printed Ephemera: Three Centuries of Broadsides and Other Printed Ephemera
Prokudin-Gorskii Collection
Prosperity and Thrift: The Coolidge Era and the Consumer Economy, 1921-1929
Public Policy Topics Web Archive
Publications of the Law Library of Congress
Puerto Rico at the Dawn of the Modern Age: Nineteenth- and Early-Twentieth-Century Perspectives
Quilts and Quiltmaking in America, 1978-1996
Ragtime
Railroad Maps, 1828-1900
Rare Book Selections
Rhode Island Folklife Project Collection
Robert Lansing Papers
Rochambeau Map Collection
The Roger Reynolds Collection
Roman Totenberg Papers
Roman Totenberg Papers: Totenberg-Wilk Holocaust Material
Rosa Parks Papers
Royal Cremation Ceremony for H.M. King Bhumibol Adulyadej of Thailand Web Archive
Salmon P. Chase Papers
Samuel Barber at the Library of Congress
Samuel F. B. Morse Papers at the Library of Congress, 1793-1919
Samuel J. Gibson Diary and Correspondence
Sanborn Maps
Science Blogs Web Archive
Selected Datasets
Selected Digitized Books
Selections from the Katherine Dunham Collection
Selections from the National Film Registry
September 11, 2001 Web Archive
September 11, 2001, Documentary Project
Show Music on Record
Sigmund Freud Papers
Sikkim Photos (Kandell Collection)
Sir Francis Drake (Kraus Collection)
Slaves and the Courts, 1740-1860
Small Press Expo Comic and Comic Art Web Archive
South Pacific Islands Web Archive
South-Central Georgia Folklife Project Collection
Southern Mosaic: The John and Ruby Lomax 1939 Southern States Recording Trip
The Spalding Base Ball Guides, 1889-1939
Spanish Legal Documents (15th-19th Centuries)
The Spanish-American War in Motion Pictures
Sports Byline
Sri Lankan Elections Web Archive
Stars and Stripes: The American Soldiers' Newspaper of World War I, 1918-1919
Stereograph Cards
Susan B. Anthony Papers
Tending the Commons: Folklife and Landscape in Southern West Virginia
Thaddeus Stevens Papers
Thai Elections Web Archive
Theodore Roosevelt Papers
Theodore Roosevelt: His Life and Times on Film
Thomas Biggs Harned Collection of Walt Whitman Papers
Thomas Jefferson Papers, 1606-1827
Tibetan Oral History Archive Project
Timor-Leste 2010-2011 Web Archive
Timor-Leste Elections Web Archive
Tissandier Collection
Today in History
Traditional Music and Spoken Word
Transit of Venus March
Transportation and Communication
U.S. Code
U.S. Reports
U.S. Telephone Directory Collection
Ulysses S. Grant Papers
United States Congressional Web Archive
United States Elections Web Archive
United States Supreme Court Nominations Web Archive
Van Vechten Collection
Variety Stage Sound Recordings and Motion Pictures
Veterans History Project
Veterans History Project Web Archive
Vietnam-Era Prisoner-of-War/Missing-in-Action Database
Vietnamese Elections Web Archive
Visual Image Web Archive
Voices from the Dust Bowl: the Charles L. Todd and Robert Sonkin Migrant Worker Collection, 1940-1941
Voices Remembering Slavery: Freed People Tell Their Stories
Walt Whitman Papers (Miscellaneous Manuscript Collection)
Walt Whitman Papers in the Charles E. Feinberg Collection
War of 1812 Bicentennial Web Archive
Warren G. Harding-Carrie Fulton Phillips Correspondence
Washington During the Civil War: The Diary of Horatio Nelson Taft, 1861-1865
Web Cultures Web Archive
Webcomics Web Archive
Webinars
Wilbur and Orville Wright Papers at the Library of Congress
William A. Gladstone Afro-American Military Collection
William H. Taft Papers
William Henry Harrison Papers
William McKinley Papers
William P. Gottlieb Collection
William Speiden Journals
William T. Sherman Papers
Winter Olympic Games 2002 Web Archive
Wm. Oland Bourne Papers
Women of Protest: Photographs from the Records of the National Woman's Party
Women's and Gender Studies Web Archive
Women's Suffrage in Sheet Music
Woodrow Wilson Papers
Woody Guthrie and the Archive of American Folk Song: Correspondence, 1940-1950
Working in Paterson: Occupational Heritage in an Urban Setting
World War History: Newspaper Clippings, 1914-1926
World War I Centennial Web Archive
World War I Sheet Music
World War II Military Situation Maps
World's Transportation Commission
Wright Brothers Negatives
Yiddish American Popular Sheet Music
Zachary Taylor Papers
Zine Web Archive
Zora Neale Hurston Plays at the Library of Congress

Looking more closely at Collections#

We hear you saying “Ohh cool, you have World War I Sheet Music! “ Yes we do! Let’s grab the titles and the front covers:

from IPython.display import Image, display #tell python that we want to reuse some code to display the images for us

wwi_sheet_music = requests.get("https://www.loc.gov/collections/world-war-i-sheet-music/?fo=json").json() #get the JSON data
for item in wwi_sheet_music["results"]:
    print(item["title"]) #print out the title
    display(Image(url=item["image_url"][0])) #display the front cover art
All the way from San Jose
Sailor's life
For the boys who did not return
The  parting sailor boy's vow
God speed the day we get the Kaiser's goat
On to Berlin spirit of 1918
Hats off to U.S.A
Hats off to U.S.A
Now he is over
Kaiser Bill, world's assassin
America, the greatest of them all
Good bye my boy we're proud to see you go
Ev-ry-bod-y takes you by the hand in home sweet home
Arise! ye stalwart sons
When I come back to you op. 75, no. 1
Since my boy has gone away
The  Irish Kaiser
Safe for democracy New America
Safe for democracy Take your pen and sign the peace
Safe for democracy When my boy comes marching home
Lullaby of war while your daddy's far away
Welcome home to our soldier boys
There is no place like home dear in the good old U.S.A
The  working man
Lafayette--we are here!

Asking another question#

You noticed that the sheet music covers sometimes include publishers. You wonder if you can get more details about that. Yes, you can! Much of the sheet music was published by multiple organizations or people and around the country and world. We’ll use some python code to display the list of publishers and created date of the titles:

wwi_sheet_music = requests.get("https://www.loc.gov/collections/world-war-i-sheet-music/?fo=json").json()
for item in wwi_sheet_music["results"]:
    item_json = requests.get(item["id"] + "?fo=json").json()
    print("'%s', %s" % (item_json["item"]["title"], item_json["item"]["created_published"]))
'All the way from San Jose', ['1948, monographic.', 'SANTLY-JOY, Inc. Music Publishers,, New York :, [1948].']
'Sailor's life', ['1919, monographic.', 'Delmar Music Co.,, Chicago :, [1919].']
'For the boys who did not return', ['1919, monographic.', 'Legters Music Co.,, Chicago :, [1919].']
'The  parting sailor boy's vow', ['1918, monographic.', 'Ehrgott & Kahl,, Union Square, N.Y. :, [1918].']
'God speed the day we get the Kaiser's goat', ['1918, monographic.', 'Adam D. Kahler,, [United States?] :, [1918].']
'On to Berlin spirit of 1918', ['1918, monographic.', 'O.L. Burch,, Denver, Colo. :, [1918].']
'Hats off to U.S.A', ['1917, monographic.', 'Howard Earl Jaynes,, Detroit, Mich. :, [1917].']
'Hats off to U.S.A', ['monographic.']
'Now he is over', ['1919, monographic.', 'Delmar Music Co.,, Chicago:, [1919].']
'Kaiser Bill, world's assassin', ['monographic.']
'America, the greatest of them all', ['monographic.']
'Good bye my boy we're proud to see you go', ['monographic.']
'Ev-ry-bod-y takes you by the hand in home sweet home', ['1919, monographic.', 'Triangle Music Pub. Co.,, New York :, [1919].']
'Arise! ye stalwart sons', ['monographic.']
'When I come back to you op. 75, no. 1', ['monographic.', 'Willis Music Company,, Cincinatti, O. :, [1919].']
'Since my boy has gone away', ['monographic.']
'The  Irish Kaiser', ['1917, monographic.', 'Edwin Forrest Kamerly,, Philadelphia :, [1917].']
'Safe for democracy New America', ['monographic.']
'Safe for democracy Take your pen and sign the peace', ['monographic.']
'Safe for democracy When my boy comes marching home', ['monographic.']
'Lullaby of war while your daddy's far away', ['monographic.', 'Thos. Goggan & Bros.,, San Antonio, Texas :, [1917].']
'Welcome home to our soldier boys', ['1918, monographic.', 'Jennie D. Kane,, Stroudsburg, Pa. :, [1918].']
'There is no place like home dear in the good old U.S.A', ['1918, monographic.', 'Lyric Music Co.,, Seattle, Wash., U.S.A. :, [1918].']
'The  working man', ['monographic.', 'Lyric Music Publishing Company,, Seattle, U.S.A. :, [1918].']
'Lafayette--we are here!', ['monographic.']

Digging into the results#

Now that you have the list of who published the sheet music and when, you might want to learn where they were published. Let’s create a graph of the places where the sheet music was published for the first 25 items. Note, sheet music can have multiple places where it was published.

import pandas as pd
%matplotlib inline
from collections import Counter
location_counter = Counter()
wwi_sheet_music = requests.get("https://www.loc.gov/collections/world-war-i-sheet-music/?fo=json").json()

for item in wwi_sheet_music["results"]:
    if item['location'] is not None: #check that the item has a location, since it is optional
        for location in item['location']:
            location_counter[location] += 1 #add one for the location
    
locations = pd.Series(location_counter)
locations.sort_values(ascending=True).plot(kind='barh', figsize=(9,9))
<matplotlib.axes._subplots.AxesSubplot at 0x110712bd0>
../_images/0905010c66d87fabb152e9253debfd3da843aac6fa3cee230a932e66603fb32b.png

Further Research#

Check out the “ask a librarian” section of our website: https://www.loc.gov/rr/askalib/