OpenBook Plugin: The Open Library API
- When You Link to a Book, Do You Link to Amazon, LibraryThing, WorldCat, or What?
- Four Big Libraries: I Pick OpenLibrary
- OpenBook Plugin: Requirements
- OpenBook Plugin: The Open Library API
- OpenBook Plugin: Coding in PHP
- OpenBook Plugin: Grabbing the Book Data
- OpenBook Plugin: Let There Be Cover Images!
- OpenBook Plugin: The Importance of Linking to Publisher Websites
- OpenBook Plugin: Graphic Design
- OpenBook Plugin: Hooking into WordPress
- OpenBook Plugin: Now Accepting Arguments, and Beta Testers
- OpenBook Beta Release!
The 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:
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:
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





Leave your response!