Hi Karen,

I worked out a solution that works for what I’m doing that goes something like 
this using the JSON API.. It goes something like this.  Thanks for the help.


1. First query with Works Key to get the Edition Key

http://openlibrary.org/query.json?type=/type/edition&works=/works/OL14949733W

[{"key": "/books/OL10680763M"}]

2. then query with the Edition Key to return needed info on book:

https://openlibrary.org/api/books?bibkeys=OLID:OL10680763M&format=json

{"OLID:OL10680763M": {"bib_key": "OLID:OL10680763M", "preview": "noview", 
"preview_url": 
"https://openlibrary.org/books/OL10680763M/To_Kill_a_Mockingbird";, "info_url": 
"https://openlibrary.org/books/OL10680763M/To_Kill_a_Mockingbird"}}

3. Info comes in different levels of detail

Query with jscmd=viewapi

https://openlibrary.org/api/books?bibkeys=OLID:OL10680763M&jscmd=viewapi&format=json

{"OLID:OL10680763M": {"bib_key": "OLID:OL10680763M", "preview": "noview", 
"preview_url": 
"https://openlibrary.org/books/OL10680763M/To_Kill_a_Mockingbird";, "info_url": 
"https://openlibrary.org/books/OL10680763M/To_Kill_a_Mockingbird"}}


Query with jscmd=data

https://openlibrary.org/api/books?bibkeys=OLID:OL10680763M&jscmd=data&format=json

{"OLID:OL10680763M": {"publishers": [{"name": "Hodder Murray"}], "weight": "2.6 
pounds", "title": "To Kill a Mockingbird", "url": 
"https://openlibrary.org/books/OL10680763M/To_Kill_a_Mockingbird";, "notes": 
"Hodder Graphics", "identifiers": {"isbn_13": ["9780340942208"], "openlibrary": 
["OL10680763M"], "isbn_10": ["0340942207"], "librarything": ["3092"], 
"goodreads": ["2264111"]}, "publish_date": "October 26, 2007", "key": 
"/books/OL10680763M", "authors": [{"url": 
"https://openlibrary.org/authors/OL235479A/Philip_Page";, "name": "Philip 
Page"}]}}


Query with jscmd=details 

https://openlibrary.org/api/books?bibkeys=OLID:OL10680763M&jscmd=details&format=json

var _OLBookInfo = {"OLID:OL10680763M": {"bib_key": "OLID:OL10680763M", 
"preview": "noview", "preview_url": 
"https://openlibrary.org/books/OL10680763M/To_Kill_a_Mockingbird";, "info_url": 
"https://openlibrary.org/books/OL10680763M/To_Kill_a_Mockingbird";, "details": 
{"publishers": ["Hodder Murray"], "physical_format": "Paperback", 
"classifications": {}, "key": "/books/OL10680763M", "weight": "2.6 pounds", 
"title": "To Kill a Mockingbird", "notes": {"type": "/type/text", "value": 
"Hodder Graphics"}, "identifiers": {"goodreads": ["2264111"], "librarything": 
["3092"]}, "created": {"type": "/type/datetime", "value": 
"2008-04-30T09:38:13.731961"}, "isbn_13": ["9780340942208"], "isbn_10": 
["0340942207"], "latest_revision": 6, "last_modified": {"type": 
"/type/datetime", "value": "2011-01-07T07:55:43.657128"}, "authors": [{"name": 
"Harper Lee", "key": "/authors/OL498120A"}, {"name": "Philip Page", "key": 
"/authors/OL235479A"}], "publish_date": "October 26, 2007", "works": [{"key": 
"/works/OL14949733W"}], "type": {"key": "/type/edition"}, "subjects": ["English 
literature: texts", "For National Curriculum Key Stage 4 & GCSE"], 
"physical_dimensions": "9.4 x 7.3 x 1.1 inches", "revision": 6}}};



On Dec 30, 2014, at 7:01 PM, Karen Coyle <[email protected]> wrote:

> Note that there is no correspondence between the "W" keys and the "M" keys -- 
> they are unrelated, so you can't change a "W" to "M" and get anything 
> sensible.
> 
> Also, it's possible that the information you need is in the documentation for 
> the RESTFul API, here:
> 
> https://openlibrary.org/dev/docs/restful_api
> 
> kc
> 
> On 12/30/14 6:52 PM, Chris wrote:
>> Thanks Karen.. That does help, since I’m completely new here.
>> 
>> Basically,  I guess the question is if given only a ‘W’ Works key how do
>> I get to the Edition or ‘M’ key.  It looks like all the works have a
>> unique ‘W’ key, so there should be a way.
>> 
>> As a little more of background:
>> 
>> I extracted a dump, which gives me a lot OLID’s that end in ‘W’ that I
>> can use on the web.
>> 
>> For example:
>> 
>> https://openlibrary.org/works/OL15346679W.json
>> 
>> works and gives me this:
>> 
>> {"title": "Adventures of Tom Sawyer", "created": {"type": "/type/datetime", 
>> "value": "2010-08-20T09:50:50.944421"}, "last_modified": {"type": 
>> "/type/datetime", "value": "2012-07-07T03:04:45.302947"}, "latest_revision": 
>> 2, "key": "/works/OL15346679W", "authors": [{"type": {"key": 
>> "/type/author_role"}, "author": {"key": "/authors/OL18319A"}}], "type": 
>> {"key": "/type/work"}, "revision": 2}
>> 
>> But the info I need is in an edition so, I need a key that ends in ‘M’ so 
>> I’m having trouble finding books.  No results are returned with OLIDs that 
>> end in ‘W’.
>> 
>> Example this works:
>> 
>> https://openlibrary.org/api/books?bibkeys=OLID:OL15346679M
>> 
>> var _OLBookInfo = {"OLID:OL15346679M": {"bib_key": "OLID:OL15346679M", 
>> "preview": "noview", "preview_url": 
>> "https://openlibrary.org/books/OL15346679M/Raghuvam\u015ba_cantos_14_15.";, 
>> "info_url": 
>> "https://openlibrary.org/books/OL15346679M/Raghuvam\u015ba_cantos_14_15."}};
>> 
>>  but this yields nothing:
>> 
>> https://openlibrary.org/api/books?bibkeys=OLID:OL15346679W
>> 
>> var _OLBookInfo = {};
>> 
>> 
>> I’m puzzled. t
>> 
>> Thanks.
>> Chris
>> On Dec 30, 2014, at 6:44 PM, Karen Coyle <[email protected]
>> <mailto:[email protected]>> wrote:
>> 
>>> I can give you some info, but others with more experience with the API
>>> will need to give you more.
>>> 
>>> There are two types of bibliographic entities in OL: Works and
>>> Editions. The OLIDs that end in "W" are for works; the OLIDs that end
>>> in "M" are for editions. (Yes, there's a reason why M=edition, but
>>> it's a long story.)
>>> 
>>> A work is a general record linking to all of the books of the same
>>> content, e.g. all of the versions of Tom Sawyer. Individual books are
>>> editions. Editions can be retrieved using the API:
>>> 
>>> https://openlibrary.org/api/books?bibkeys=OLID:OL24367990M
>>> 
>>> They can also be retrieved with the OLID, the ISBN or the OCLC number.
>>> 
>>> I don't know how you format a query to retrieve all of the editions
>>> starting with a Work OLID -- can somewhere here answer that question?
>>> 
>>> Thanks,
>>> kc
>>> 
>>> On 12/30/14 5:41 PM, Chris wrote:
>>>> Hi all,
>>>> I’m new to OL.  I’m excited about it’s vast potential.
>>>> 
>>>> I had a quick question.
>>>> 
>>>> I recently downloaded a dump and extracted it to a sql database.  When I
>>>> query this database I retrieve a OL id for a given book, but when I turn
>>>> around and use this ID against open library directly with an API call, I
>>>> get no results.
>>>> 
>>>> For example, this row extracted from the Dump
>>>> 
>>>> Adventures of Tom SawyerMark TwainOL15346679W
>>>> 
>>>> returns no results
>>>> 
>>>> https://openlibrary.org/api/books?bibkeys=OLID:OL15346679W
>>>> 
>>>> Other entries I’ve noticed that do work correctly end with ‘M’ as the
>>>> last character of the OLID instead of ‘W’
>>>> 
>>>> I’m hoping the OL ids have not all changed.  It took a good while to
>>>> pull down the 100gig dump and build a database that I could query and
>>>> consume.
>>>> 
>>>> I’m hoping someone can lend some light on this problem for me.
>>>> 
>>>> Thanks
>>>> 
>>>> -Chris Flynn
>>>> 
>>>> 
>>>> _______________________________________________
>>>> Ol-tech mailing list
>>>> [email protected]
>>>> http://mail.archive.org/cgi-bin/mailman/listinfo/ol-tech
>>>> Archives: http://www.mail-archive.com/[email protected]/
>>>> To unsubscribe from this mailing list, send email to
>>>> [email protected]
>>>> 
>>> 
>>> --
>>> Karen Coyle
>>> [email protected] http://kcoyle.net
>>> m: 1-510-435-8234
>>> skype: kcoylenet/+1-510-984-3600
>>> _______________________________________________
>>> Ol-tech mailing list
>>> [email protected]
>>> http://mail.archive.org/cgi-bin/mailman/listinfo/ol-tech
>>> Archives: http://www.mail-archive.com/[email protected]/
>>> To unsubscribe from this mailing list, send email to
>>> [email protected]
>> 
> 
> -- 
> Karen Coyle
> [email protected] http://kcoyle.net
> m: 1-510-435-8234
> skype: kcoylenet/+1-510-984-3600

_______________________________________________
Ol-tech mailing list
[email protected]
http://mail.archive.org/cgi-bin/mailman/listinfo/ol-tech
Archives: http://www.mail-archive.com/[email protected]/
To unsubscribe from this mailing list, send email to 
[email protected]

Reply via email to