Using the slideshare API from Apps Script

I used to use Slideshare a fair bit but I'd forgotten all about it until today. I wanted to see what I had there and if anyone was looking at it. I suppose I could have used the UI, but whe
re's the fun it that.

So it turns out that Slideshare has an API that you can do various things with including getting stats, so I though I may as well use that. I was expecting it to use OAuth2 but it doesn't. It does have a client secret and an API key it uses to measure your usage (pretty low daily quota actually), but the most useful stuff (for me anyway) doesn't need authentication - (which is done through a username.password approach)

The data also comes back in XML format, so I've created an Apps Script library to convert that back into JSON and to handle the API interaction. For now I've only implemented a couple of methods

- getSlideshowsByUserName
- getSlideShow

I may add to that later if anybody is interested.

Set up

You need to apply for an apikey and client secret at the slideshare API page, but it's painless - you get one by email right away. Once you have those, I recommend you store them in a properties  store somewhere.

Getting a instance of SlideShare

You'll need the cSlideShare library (or you can get in from github)


Then you can do this  .. or something else if you haven't stored your credentials in a properties store as I have,

  // get all my slideshare stuff
  // script properties have my creds
  var sshareCreds = JSON.parse(PropertiesService.getScriptProperties().getProperty("slideshareCredentials"));
  var sshare = new cSlideShare.SlideShare()

Now you can get all your (or someone elses) slideshare data like this (the true says I want maximum detail)

  // get all of them .. the first arg can be any slideshare username
  var all = sshare.getSlideshowsByUserName ("",true).data;

Or you can get the data for one slideshow like this
  // ...or get just one by its ID
  var one = sshare.getSlideshow ("55548998",true).data;

and that's pretty much it. Here's how to select a few fields and write the data to a sheet
 // dump to a sheet
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('slides');
  // there are loads of fields, but i'll just take these for demo.
  var fields = ["ID","Title","URL","Created",
  var values = [fields].concat( (function (d) {
    return (function (f) {
      return d[f];
  // write that out
  sheet.getRange (1,1,values.length,fields.length).setValues(values);

Which gives you something like this

For more like this, see Google Apps Scripts snippets. Why not join our forumfollow the blog or follow me on twitter to ensure you get updates when they are available. 

You want to learn Google Apps Script?

Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, available All formats are available now from O'Reilly,Amazon and all good bookshops. You can also read a preview on O'Reilly

If you prefer Video style learning I also have two courses available. also published by O'Reilly.
Google Apps Script for Developers and Google Apps Script for Beginners.