How to retrieve book's information in XML/JSON from library of congress by ISBN
Asked Answered
C

2

11

The Library of Congress has a site to search books by ISBN. A simple way to retrive book's information is using a URL like:

http://lccn.loc.gov/2009019559/mods

where it returns a XML structure that may parse easily. The URL requires a unique LCCN number in the the following format:

http://lccn.loc.gov/[lccn]/mods

I have a batch of books that has ISBN encoded in barcode. How may I retrieve/convert ISBN to LCCN in order to retrieve the XML data of the book?

Criollo answered 2/12, 2012 at 7:39 Comment(2)
Does it have to be a lookup by LCCN number? There are sites/API's that allow you to do a lookup by ISBN number if you have these available. See webhole.net/2009/08/25/get-book-info-from-isbnIdonah
I have tried isbndb before, but it is not as complete as loc for my case. I still prefer retrieving data from loc catalog.Criollo
A
5

You can use the SRU catalog from the Library of Congress. The query would look something like this:

lx2.loc.gov:210/lcdb?version=1.1&operation=searchRetrieve&query=bath.isbn=[ISBN]&maximumRecords=1&recordSchema=mods

Replacing [ISBN] with the ISBN you want to look up

Within that response is an LCCN element. However, the catalog already returns MODS, so it might not be necessary to do anything at all.

Armored answered 10/1, 2015 at 15:42 Comment(4)
@Menasheh Yes, maybeTrapes
The reason that it "doesn't appear to work for many ISBNs" is because the LOC may not have the exact book that matches your number. The same title of a book could have many different ISBNs. For example, one for the hardback version, one for paperback, one for an updated version of the book, etc. When your search fails, try by title instead of isbn.Janie
How did you find this information? This is literally the only place in the internet that says how to get a book info by ISBN via LoC. What I cannot figure out is how to get it in a JSON form. The fo=json does not work. Is there other way than reformatting this on my backend?Notepaper
Documentation: loc.gov/z3950/lcserver.htmlMarozas
J
1

You may use the Google Books API, for example: https://www.googleapis.com/books/v1/volumes?q=LCCN2001051058

Answer is in JSON format. It includes both ISBN-10 and ISBN-13 identifiers. You will have to batch the requests using your favorite programming language, in Pharo Smalltalk with PetitJson parser and Zinc with HTTPS support it would be:

| parser lccnCollection |
parser := PPParserResource current parserAt: PPJsonParser.
lccnCollection := #('2001051058' '2001051058').
lccnCollection do: [: lccnNumber | 
    | json jsonObject |
    json := (Url absoluteFromText: 'https://www.googleapis.com/books/v1/volumes?q=LCCN' , lccnNumber) retrieveContents contents.
    jsonObject := parser parse: json.
    " ... retrieve ISSN from jsonObject, etc ... "].

Beware you may need an API key to make batch requests to Google.

Jobina answered 3/12, 2012 at 6:8 Comment(2)
Thanks. Perhaps I didn't make myself clear in the question. I am looking for a direct solution like LOC's mods URL that allow me to pass ISBN as parameter. After some trial and error, I think a solution is using z3950 web service from LOC.Criollo
@ChauCheeYang, if you have a second, could you post the http request or a link to the docs that detail the method you used for this task? I'm in the same boat you were in...Humbuggery

© 2022 - 2024 — McMap. All rights reserved.