Making Your First Sierra API Call
In the previous tutorial, we used the Sierra API Client Credentials Grant to authenticate with a Sierra server. Now we can use the bearer token (also referred to as the access token) that we created to make an API call.
Our goal in this tutorial is to obtain a list of new titles we can use to populate a library web site that promotes recent acquisitions.
Download and install the Advanced REST Client Chrome plug-in, or a similar REST client, if you have not already done so.
The access token from the previous post probably has expired. As a security measure, Sierra assigns them a lifespan of 3,600 seconds (6 minutes). To make our first Sierra API call, we must repeat the previous tutorial and obtain a new token.
- Our new access token is:
Next, we must construct an API call that returns all of the bibs created after a certain date. The sample data on the sandbox server does not included any recently created bibs. For this tutorial, we need to use an earlier date than we might apply to an actively growing library catalog. We’ll create an API call that retrieves the title, author, and year of publication for all the bibs in the sandbox library that are not deleted, not suppressed, and were created on or after July 30, 2013 at 7:20PM and 28 seconds.
- In your REST client, set the URL to:
- Add the following query parameters:
- deleted = false
- suppressed = false
- createdDate = [2013-07-30T19:20:28Z,]
- fields = title,author,publishYear
- Set the method to GET.
- In the Headers section, choose Raw, and then add the following header:
Authorization: Bearer <insert your access token from step 1>
The example header becomes:
Authorization: Bearer ed0g0xC5jfkst3DCq6t6x1hp7BwwozH7kg_31PF1XH-hFkBgnIQKqVyPmhmFXYa7jr-RfHE4m79i601XN0zjg2ckTgOeWs59Y67p0Ew5oXj_7hZt6Ic0CAosm5H05JYp-CaX0Wlr6ws2uHXIdAUV-g
- Click the Send button (on the lower-right).
- If the operation is successful, the API returns a status of 200 and a JSON-formatted list of bib records matching our query parameters.
We now have authenticated with the Sierra API on the Innovative Sandbox server and made our first successful API call. You can extend this example to the other API endpoints, with which you can access and update patron profile information, holds, fines, items, and authority records.