A Node server that works with the LibCal and LibGuides API v1.2 endpoints and returns your requested data.
The new v1.2 API endpoints for LibGuides and LibCal require* (* highly highly suggest) that you do not expose your private authorization details to the world. If you put them in code in a widget on a libguide they would be exposed (naughty auth details!). So, the solution to this is to have them living on a webserver where no one else can see them.
Deploying to Heroku
You can use this code however you like, of course. But it's very easy to get this up and hosted on Heroku for free. Heroku is a well-regarded host that plays nicely with Node.js and other great technologies. (FYI: I'm not affiliated with Heroku in any way and can assume no liability in your using them blah blah blah.)
To create your own webserver on Heroku with this code:
- Go to Heroku and create an account.
- Come back here and click the 'Deploy to Heroku' button:
- You will go to a new page where you can create a name for your server. You will also need to add your authentication information for both LibCal and LibGuides. You can find this information on their respective API pages under the Authentication tab.
Things to consider with Heroku
The free tier of Heroku is great. The only downside is that your server will sleep after 30 minutes of no use. After sleeping it takes ~20 seconds for it to spin back up and respond to that waking request. There are services that will periodically ping your server to keep it awake, which helps remediate this problem. Also keep in mind that free tier apps (our server) have to sleep at least 6 hours per day. Check out Kaffeine which seems to take that into account and won't ping 24 hours per day.
The next pricing tier up is only 7 dollars per month if you don't want to worry about the sleeping issue.
Okay so I have it deployed, now what?
Well, now you can make your requests for data from the respective Springshare APIs to your (new, shiny, and extra special) server.
If you wanted a list of your AZ assets from LibGuides the documentation says you should query the url:
https://lgapi-us.libapps.com/1.2/az. Instead you would query your new server like this:
In LibCal, for a list of spaces by category they say you should query
https://api2.libcal.com/1.1/space/categories/:id. Instead you would query your server like this:
What's going on here? Basically you pull the last part(s) of the valid query you would make to them and put it in quotes there after
?what=. Do include the forward slash at the start of what's in quotes.
I'm working on building implementations for their APIs that work with your new server over at APIs for Librarians. You can copy and paste some code into your libguides or websites and not have to worry about a bunch of shenanigans.