Home » OpenBook WordPress Plugin

OpenBook Plugin: The Open Library API

26 May 2008 No Comment
This entry is part 4 of 12 in the series Building OpenBook

OpenBook WordPress PluginThe OpenBook plugin will grab book data from OpenLibrary using its APIs.

If you are new to APIs, it stands for Application Programming Interface. Software use APIs to open up their functions to other programs. OpenLibrary exposes its data through a URL with a query string. The query string is everything that follows the “?” in the URL in the address bar. It is a series of name-value pairs that a website can pick up and read. More on this below.

For the plugin, I want to get data for one particular book at a time. Let’s pick a sample book: Revolting Librarians Redux. This book already exists in the Open Library database. Notice the link for the book:

http://openlibrary.org/b/OL3674869M

The last portion of the link is the unique identifier for the book: “/b/OL3674869M”. This is the identifier that the plugin in user will have to provide to link to the book data. I was curious what the “/b” stood for, a little concerned it might stand for “beta” as OpenLibrary is still in beta. I posted the question on the OpenLibrary list and learned that it stands for “book”. Author records use “/a”.

The URL to access any book’s data is “http://openlibrary.org/api/get”. The query string to access a particular book’s data looks like: ?key=/b/OL3674869M. Put the two together and you have:

http://openlibrary.org/api/get?key=/b/OL3674869M

You can use the URL just like that, but it returns an object that your browser cannot likely handle. You will be prompted to open or download it. If you like, download it and have a look. Or you can add a couple of name-value pairs to the query string to let it display as text in the browser. If you add “&text=true” the book record will display in your browser. If you also add “&prettyprint=true” it will format nicely.

http://openlibrary.org/api/get?key=/b/OL1001932M&text=true&prettyprint=true

You have the book data. In the next post, I will capture the post data in PHP to start building the plugin.

Additional Information

Application programming interface, Wikipedia
Open Library API
Open Library General Discussion List

Index

Series Navigation«OpenBook Plugin: RequirementsOpenBook Plugin: Coding in PHP»

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.

Print This Post Print This Post