Basics and Resources: API

API stands for Application Programming Interface which allows external applications to access software or Web services data, in the latter case by using HTTP request messages, for recombination (mashup) or custom presentation by the external application.
Why use an API?

An application programming interface essentially allows programs and online services to talk to each other. APIs provide a set of definitions and protocols for services to request and exchange data. Many library vendors provide public and key-based APIs to their services in order to allow customers to pull bibliographic and other data into local systems and websites.

APIs may seem daunting if you have no programming skills, but Richard Manly Adams Jr found in his article “Overcoming disintermediation: a call for librarians to learn to use web service APIs“:

The implementation of web service APIs is within the reach of librarians who are not trained as software developers. Online documentation and free courses offer sufficient training for librarians to learn these new ways of sharing and curating digital content.

The Basics

For our purposes, we’ll only look at Web service APIs.

Web services and applications exchange data through APIs using a request and response system. The exchange uses HTTP and HTTPS (secure HTTP) like regular Web requests, however the data isn’t formatted for people to read but rather for other services. The data format is usually expressed in JavaScript Object Notation (JSON) or Extensible Markup Language (XML).

API Graphic

You may see an application programming interface described as a RESTful API. REST stands for representational state transfer. The REST architecture can be complicated, but essentially it indicates data sent over Web protocols using HTTP commands POST, GET, PUT, and DELETE.

Some APIs are “retrieval only” allowing only the GET command to retrieve data from the Web service. Others allow full access to get and write data to the Web service using all four of the HTTP commands.

You can also access a Web API using a URL containing a query string. The URL will include the domain, path, and the query terms after a question mark. The query terms can often use Boolean AND, OR, and wildcards (*). Multiple fields can be requested, separated by an ampersand (&).

The example below is an API URL which retrieves records from the Virtual International Authority File (VIAF) where the authority includes the term “Mark Twain” and returns a maximum of five records.

http://www.viaf.org/viaf/search?query=cql.any+=+”Mark Twain”&maximumRecords=5&httpAccept=application/json

Below is a good introduction to Web applications and APIs by Mark Breedlove from the Digital Public Library of America (DPLA). [40 minutes + Q&A]

Springshare has been very proactive in providing APIs to its LibGuides product since launch. Users can access the API tool right from the menu. With the LibGuides APIs, users can pull any content and data from their LibGuides site to display in their library website, blog, learning management system (LMS), and OPAC through four GET options: GET guides, GET accounts, GET subjects, and GET assets.

Springshare LibGuides CMS Menu API

Website widgets and plugins take advantage of APIs to pull data from Web services and also to write to them (using the POST command). For example, most social media sites provide APIs to display feeds, provide “Follow” or “Like” buttons, and even leave comments from external applications and websites.

Probably the most common API is the familiar RSS feed seen on many blog sites. The RSS API provides the unformatted data of blog post titles, dates, summaries, etc., which are then formatted for display by RSS readers.

Website developers can access a range of Twitter APIs from the Twitter Developers Documentation site. Here is their description of the Twitter API:

The Twitter API can be used to programmatically retrieve and analyze data, as well as engage with the conversation on Twitter.

This API provides access to a variety of different resources including the following: Tweets, Users, Direct Messages, Lists, Trends, Media, [and] Places[.]

Again, APIs allow external applications to exchange data and access functions normally handled by the host Web service.

Resources

Here are some great resources to learn about library-related APIs and what they can do:

Published resources about APIs:

APIs Unify Library Services by Marshall Breeding
APIs Unify Library Services

From the April 2014 issue of Computers in Libraries, Breeding gives a high-level overview of APIs and their increasing availability from library software vendors. He touches on the basics, methods, scripts to access APIs, and examples of library services utilizing APIs. Published in 2014.

Access the full-text article.

Comparing the LibraryThing, OCLC, and Open Library ISBN APIs by David Fiander
Code4Lib Journal

This article from Code4Lib Journal (Issue 21) compares the data retrieved from the API of LibraryThing, OCLC, and Open Library for related works based on ISBN. It shows real-life API request and results data in XML and JSON. Published in 2013.

Access the full-text article.

Web Service APIs and Libraries by Jason Paul Michel
Web Service APIs and Libraries

In this book from ALA Editions, the author demonstrates how to use APIs to integrate ten popular Web services into library websites: Twitter, Flickr, Vimeo, Google Charts, OCLC, HathiTrust, Open Library, LibraryThing, Goodreads, and Google Books. The book is a bit outdated but still useful for learning the basics. Published in 2013.

View details and find a place to buy or borrow at Google Books.