Skip to Main Content

Special Interest Group Archive: Tech SIG - API's August 25, 2020

These are the notes from meetings dating back to 2015.

August 25, 2020

The Tech SIG met on August 25, 2020 to talk about API's. The presenter was Arianna Schlegel of Vassar College. Please see an edited transcript of her presentation below.

Notes from the meeting

Information Technology SIG

Arianna Schlegel: I get really excited about API's, I love that interconnectivity of them.

We're going to talk today about API's: what they are, what they can do for you.

  • I know they can feel a little bit daunting, especially that it isn't like learning a coding language or a new technology because it's adaptable to whatever you know.
  • You can learn how to make one API work and still not know how to make any other work. Usually once you learn one you kind of get the feel for them.

Basic concepts to get started:

(at the risk of sounding like I am giving a high school paper,) I'm going to start with the definition of an API, because I want to focus on that application programming.

API stands for Application Programming Interface: that means that the applications are interfacing talking directly with one another. Counter example: when I use an app or a program on my phone or computer if I open up Excel on my computer or I open up Facebook on my phone, I'm the one interfacing with it. An API basically takes you out of the equation of doing the work. Essentially it helps programs play nicely with one another and share the information that they have, while keeping stuff protected.

The waiter analogy:

One of the most popular ways that people like to describe API's is by using the analogy of a waiter. If you go into the restaurant you sit down and look at the menu you're looking at 20 options on a menu, you make your selection and a waiter comes up and says, “What can I get for you?” You make your selection from the menu. Whatever you decide to eat and waiter says “very good” and then proceeds into the kitchen and the kitchen is blocked from your view or behind the scenes they do a whole bunch of stuff. I call it magic. Maybe the kitchen is doing work involving like proprietary spice blends and secret recipes and you don't get to know any of that stuff that's going on. Eventually the waiter comes back out of the door with what you asked for and delivers it to you correctly. In this case the waiter is the API -- it takes your requests, it retrieves your results, and then delivers what you asked for.

Say you went back to that restaurant and you sat down at the table and the waiter came up and you said, “I would like a list of all the customers that have been in here in the last month and all of their credit card numbers.” So, the waiter is going be like, “I'm sorry, that's not on the menu, I'm afraid I can't get that for you.” So it's the same kind of thing for an API, you can get what's being offered up by the other program, basically what the other company is willing to share. But not all the behind the scenes stuff.

Real World Examples:

One of the things that is probably immediately familiar most of you is when you log into something and there's that already established login from another place that you've already connected to. I sign up for a new app and I have the option of either creating my own account or logging in with something I already have like Google or Facebook -- that's an API. That app is just requesting that Facebook or Google or whoever Twitter gives them the access to your information, usually just your name and their knowledge that you exist as an entity that they've already kind of you exist because you have this established login. So Facebook isn't letting this program go behind the scenes and it won't let them know its proprietary code and stuff, but it does give the opportunity to access the information that Facebook has about you.

Hopefully, within reason, Facebook is limiting it it's not what the company is trying to do. It’s like the like the waiter, Facebook, isn't going to give you access to all the credit card numbers, but it's probably willing to share your like your name and maybe something like where you work, information that you've agreed to share with the world. Another example is financial institutions. If you're familiar with Mint, it takes all of your various accounts and amalgamates them into one. You can get your network basically from all of these different places all these electronic places that hold your money like PayPal and your credit cards and student loans and all those things that are listed there and bring it into one program. I can pull in my bank information and they're not sharing that all of the information about me, but they're willing to share. Maybe my current balance and my past transactions up to a point, so that they're all playing nicely with each other and you're more likely to stick with this program because they make your life easier.

Another example is weather widgets that you see like if you just went into Google and typed in Vancouver weather, you'd see something like this. But as one blogger I read put in Google isn't in the business of weather, they don't hire meteorologists. They don't have meteorologists on staff so this is being pulled from somewhere else so they are getting that information and serving it up to you, so that it's more convenient for you.

Bringing API’s to the library: another example of a real world API opportunity is your LMS, The most modern systems offer some sort of API service I know all my WorldCat Discovery definitely do. I'll use Sierra as my example but they'll mostly work the same way.

How do you get information out of your LMS? you log into the client.

You have to sit down and physically in front of the client run your query and then you have to usually export it from the system manipulate it a little bit, open up some other application uploaded somewhere else, a bunch of steps, they're all very manual. It all takes this human intervention.

The API allows for you to be taken right out of the picture there and they speak directly to each other.

One of the setups that I inherited when I got to Vassar was the thing called the acquisitions workflow and this is part of this larger group of monthly routines that I had to perform every month. It’s a lot of busy work, you have to process things each time. Each month so it took it took time. I'd have to go into Sierra, create generate a list of like all the books that we purchased all the items that we purchased in the last month, export it fiddle with it a little bit in another program and then upload it into a third like onto a web server that would that would process it again and then spit out.

[shows an example on the website.]

This is our old recent acquisition page as you can see it has not been updated since February 2019. But what happened was the patron could come in and open up the page and say “I want to see all of the things that we bought from a naval science from the main library in a month’s time.” This is a really great program for what it was, is it simplified a lot of work and it allowed our users to kind of see these acquisitions. But what I wanted to kind of do was give it like an API facelift and also not have to do these monthly routines anymore. So I just want to run slowly and doesn't have as many bells and whistles, as I intended, but the concept is sort of a proof of concept for me right now. I make this API call and I'm going to allow the user to offer to select any date range that they want so this is up to the minute it's pulling directly from our catalog, they can select like last week if they wanted, they can I will be offering the same kinds of things choosing the subjects that it's under and the location.

So, this again the brilliance of this, despite its slowness is I don't have to intervene in this at all. This is all done once I set it up. The user can come in and do whatever kind of query they'd like to do. There we go. So this just happens most recent books we purchased. And you can kind of go through the list of them. You can see that directly in our catalog. So really bare bones right now but the idea is there that it would all be able to just be set up by the user basically. So another project that we've been working on using an API is this SEAL integration.

SEAL: southeastern access to libraries:

so it's an interlibrary loan resource sharing program, and our ILL logs into the website, manually copies every line, line by line into our system so that they can process the admin and maintain the transaction. What we wanted to do was make that less of a manual process.

I am sharing this code that that I threw together for a test. Mostly I know it's really hard to read. But the point of it is that it's not much code. I mean, really, it's, it's a page of code and if you look at it, the, the actual processing doesn't even happen until halfway down the screen. So it's only a few lines of code to do this API process and the top half is just all of our test data that we're working with. But I just wanted to share that kind of to show that there are like many varying levels of how complex things can get.

How I got started with API’s

I want to transition a little bit to how I manually got started on it with API's because for a long time I was interested in working with them and just did not know where to start with, I felt like there was me and there was API's on the other side of this wall and I just could not scale that wall to get over I knew, kind of vaguely what had to happen but didn't have any sense of where to get started I did web searches I just tried to find the information and couldn't. So that, again, like I mentioned earlier, it's really based on what you know and it can be very, very different for each system that you're working at but I think once you get the sense of API's it's a lot easier to work with a lot of different ones.

This one I really like is because I feel like you can just really see a basic call. This Google Books API is offered without having to have any kind of key interface you basically send it a call and it sends you a reply, or it sends it, you send a request and it sends a reply. So if you take a look at the URL that I pasted. It's very simple and basically it's just looking for that ISP and the end of the string, you can replace that with any ISBN, that you find out in the world. And if you click it. You then see kind of how a call is returned, and I just really like this for, for kind of understanding. It's clearly made for computer processing and not human processing, but it is also readable and you can kind of see where all the pieces are you can see the title and subtitle the author description blah blah blah. So all of that content.

 You can kind of get a sense of how an API works and how you how you parse that information out. So, another thing to know is kind of how it's nested. So you if you're trying to pull the information out of this query you'd have to look at it, you'd have to look under items and then under. If you want it to get like the, the author you'd have to go items volume info authors. So, just kind of a good way to look at how that's processed. And then, that's nice. I'll mention that this, this and this slide.

My final slide about how to get started is a massive oversimplification of an API process because it does get very complex and I don't mean to make it seem like simple, but just as an overarching strategy to get started with anything if you find something that you'd like to work with an API, with the first thing to do is apply for an API key from whoever is offering this API, they verify that you are who you are and that you have a reason to need this information, and then they also know who's getting that information when people are pulling it. Second thing to do is determine the coding language you feel most comfortable with. I think most coding languages can make API calls I use PHP because it's just simple and immediate. But I think that really whatever you are familiar with. You can use. And then basically to really get started and this is like this was the lightbulb moment for me when I finally just got this first piece going, was that you get when you apply for the API key that gives you a key and sometimes a value. And you use those that combination of things, you create a request, and you request a token and the token is basically your like time delimited access to content, you can't just leave an API key open all the time so you can get something like, it depends on the program. You can go for anything from like 90 seconds to a minute minutes or something, but it's basically allowing you to open up that network and exchange information within the program. So, the first thing I do whenever I try to set up an API is just verify that I got a token back. It's usually a random string of letters and numbers and once I see that I know that I can then start sending requests for information and then you can get more and more complex with it but really that token is like that first key piece to get going with it. And that, in a very high level nutshell is API's. I have some other uses, that we can talk about I can share some other ideas that I've either used them for wanted to stand for.

Question:

Have you done anything with the Content dm API's at all?

Arianna Schlegel  42:08

No, because we don't do much with content yet. We have one instance of it. That is 15 years old. So no but yes actually years and years and years ago I it might not have even been an API call but there I was pulling data on like populating a website for a professor at a different college environment. But yeah, I feel like there are just so many ideas of things you can do with them, and it's just a question of like what ideas can you think I was mentioning that I had some other. Some other so one of the early things I heard about people dealing with API's was so we check out you know laptops or devices and we have people sign a, like a waiver, a paper waiver that we put in a filing cabinet somewhere and I don't actually even know where those go, or how long we keep them, but I know somebody was using a tablet to kind of capture a signature into like a PDF document, and then saving that into their iOS, and I thought that was brilliant. It's just a great way to kind of link it directly with the patron. You can pull it up quickly. And just seems like a really good use of API's and I was like I'm going to do that but of course I've not yet done it.

Question:

Can you show us, or the example you use of your book catalog, when you did your query of your catalog for the dates for the new books. Can you show us like the code like what you did, how you did that?

Arianna Schlegel  44:02

Or no, you want to see the code for it.

Yeah. So, I will show the, the basic steps for it, the broad strokes.

I used an editor. And so there was a lot. A lot of my code is not cleaned up so there's a lot of comments and probably maybe some swears something doesn't work. I don't think I swear my code but often I'll write myself notes, I'm just warning you all but there's a lot of comments and stuff all the gray stuff is just stuff that like I tried or will also. So I'm going to share

I just was like is this is this what I'm starting. Um, so, let's see, so I will talk I mentioned the key and the secret, They're specific to you and your institution. So what you do is set up a key and a secret with API for our example and then I had said give them our URL to our catalog. This is the token thing I was talking about. So I chose to use CRL. Because, again, that was just something I'm familiar with and it's easy, in a sense, it's easy, it's, it's got a lot of pieces to it as you can see this is all part of this like curl setup, but I find that I can usually just like copy paste these chunks and use them again and again in various places so once you kind of get again, once you get the sense of that API. It helps a lot. So, this, this line takes that that key and secret and encodes it. There's all this documentation online about it so you really don't have to like, remember anything I'm saying here, and then a lot of these things are telling you like how to, how to give me my information. How long until you stop trying to connect. Some of these I don't even remember all they do. So then I just basically make this call here. And it doesn't fail, if that error doesn't happen. I request a token and put it in this token. And then, I usually good like I said, the first thing I want to do is make sure that tokens coming back and that people are like, or that that I made the connection and that I am allowed access. So if I see this like token is string of letters and numbers and I'm like yes I'm in and I can do stuff. Then you have to make another call. Because that was doing a show, back and forth with them. Um, and then this is where you would work with the specific API parameters. This is specifically from triple eyes men API manual. This is how you make a call for bids. You can do patron. Thanks information, you can do orders you can do circulation, you can do a bunch of stuff, but I'm specifically working with books here items here. And so I send that string through curl again. And then, oh this is where I just took the data that they gave us gave me, and then you create see this is me trying a bunch of different things that didn't work. But this line is where I have all of the stuff in one. And honestly, I don't remember why I had to do all of that, oh I had to escape all of the all those backslashes so that the code recognizes that those quotations are supposed to be there in my string. And so I'm just asking for like a specific it's kind of like an SQL query where you're just cut it asked me for specific things. Bring me back all of these records that you know date range.

And then again you’re checking if it comes back right. See this is something like this is my comments like if I want to see the response on screen, you can uncomment that. And then when you're ready for it to actually do something else like processing the information I just I commented back out. And then I close it and then the, this is actually the most fun part for me is when you take the. Oh, by the way, when you take all the pieces and pull out all of the information to display it on wherever you're displaying it so I've done API calls where I've been throwing it into an Excel spreadsheet. This one clearly is printing out the stuff onto like a webpage. And that's it. It's the rest of this is just creating the look and layout of the webpage.

there's a lot of fiddly bits like that's always a problem is like I have torn my hair out trying to, like, figure out why I can't get this model work and it's like one little thing and maybe in the curl op settings all the way up here that I didn't have or this was false or something you know like there's just so many little bets. So that's why I often just copy and paste stuff, because there were times. Let's see if it works here. But yeah, it is it is a lot of like getting all the little pieces.

We’ll see if I can get it to do all the granular, things like pull out subjects and stuff, but then that also depends a lot on what again what the API, the offer of the API is willing to give you, because for a long time like Sierra wouldn't do patron stuff I think and then I think now in their API, you can write to them right to their database but for a long time it was only pulling stuff out so that makes sense. Yeah, it's a lot like SQL for me like that's, that's why I think it makes sense, because it's just that same kind of like requesting and sending information.

Comment:

yeah I don't actually use it, frankly, I've seen it used, I tend to run API's and are because it's an environment of learning, very slowly, but postman apparently lets you do things like enter the endpoint and enter like little bits of information and then it kind of cobbles together the query for you so you don't have to do quite as much of the coding if you are not somebody who's familiar with a specific programming or coding kind of language or environment. Yeah, so it's something to check out if people are like I think people are not like scared off by coding, or don't know any languages but kind of want to try out some simple API's I that's my impression of postman.

Arianna Schlegel  53:06

Oh, yeah, I feel like that's part of it is just kind of getting a sense of what the little pieces are within the API unit yeah without like expanding it into writing code that does stuff with it just like seeing what a specific. Yeah. I've used the, I've used another Sierra API call to doesn't work anymore from nothing to show, but we tried to make kind of a bento box search results, when they offered that ability to like pull in various pieces and make a bento box I think I did, I did summon and Sierra as two of the results. So that's another thing. another way to like integrate that content. One I always mention. Oh, the Google Books API that I showed that I'm like a huge fan of for again just seeing kind of how that those pieces all work together. I use that to pop into auto populate book request forms, because we have lazy faculty No just kidding. But they want to just type in IBM and have it like fill in the title, author, etc. So in our book request form. I just make a call to the Google API and just have it bring back those pieces that I was showing that they just fit back into JSON parse it out for them. And they like the convenience of it, although it doesn't always Google Books is like sometimes a little weird. I don't know if their system or for free is the system but I've occasionally had it return something that didn't look anything like what the professor requested, but it's a convenience thing it's not necessarily like set in stone so luckily they saw it and more like that wasn't a book I wanted. So I like that, and I'm not. Oh, and we we have workday, as our like accounts payable system, I don't even know what is workday, a whole business behind the scenes thing, but it does accounts payable and we and I also set up a link between Sierra and so we use the process our orders. But I think we printed them out, and then brought them over to accounts payable and they entered them in manually. But when we transition from banner to work day, they told us, we had to give them electronic invoices and we're like what Okay, so I had to either the invoice person was going to have to, like, create a list and Sierra export it manually manipulated a bunch to fit exactly the parameters that work they needed, and then send it up to their FTP server but we set up a, an export that just runs. If you click a button. Give it like a date range like the last month, click a button, it creates the, the Excel sheet for you. So, those kind of things also just to help those work processes work more smoothly, save people work when it's stuff that just doesn't need that human intervention you know what that was all of the examples I found out by

Comment: I use the Google Books API I guess I just haven't as awesome as it sounds, I have not found any use for it, really. So, can you just repeat what you use it for.

Arianna Schlegel  56:55

Yeah, that was probably the most single one of every day because it doesn't tell you but it's just auto populates a form that the when people are requesting a book, they just want to be able to type in or copy paste the ISBN and then they click a button and it just fills in like publication there some very basic stuff. But yeah I don't I'd like to see more of what people do with that API is it's out there and so many cool features but I don't use it for much. Well I'm always willing to talk about API's if anyone ever wants to reach out anytime. It doesn't have to be now but I'd love to talk over ideas or, you know, Getting Started anything.

Tessa Killian  58:08

Probably the staff are like thinking oh no the bosses here is gonna be great for Zach like hide under your desk No, I think they use that the one that you're creating right now that way. And I love that you're teaming up on it to create the API for Iliad and seal I mean that's something that we've wanted to do for five years now so my route right exactly five years I mean the back fact that it did perfect use so that they don't have to like your you know efficiencies, you don't have to copy and paste things. Yeah, it makes it makes great sense, other than like I love the query that the things that you're showing us but in order also like, like you said with your, your workflow like your new banner like spiel to automate things like that, I think, are going to be good. Yeah. Very good. It's going to save people time.

Arianna Schlegel  58:58

Yeah, I just I just thought meticulousness of having to like copy and paste things. I'm always especially because they want to be perfectionist and they don't want to miss anything and so it's just nice to have that like

Tessa Killian  59:09

right the people who's doing it are probably each time are copying and pasting can't this be automated somehow.

Tessa Killian  59:30

add on. It was doing the same kind of thing, I think, but not as efficient as this end result but

Zachary Spalding  59:39

because at the time didn't have an API for lending. They weren't they weren't long time so that's what, so that was our backup was to do an add on module. So, of course, whenever she was like, addresses, find out.

Southeastern NY Library Resources Council
21 South Elting Corners Road | Highland, NY 12528
Phone: (845) 883-9065
www.senylrc.org