Introducing the Google Slides API

November 09, 2016


Link copied to clipboard
Originally posted on G Suite Developers Blog

Posted by Wesley Chun, Developer Advocate, G Suite

At Google I/O 2016, we gave developers a preview of the Google Slides API. Since then, the gears have been cranking at full speed, and we've been working with various early-access partners and developers to showcase what you can do with it. Today, we're happy to announce that the Slides API v1 is now generally available and represents the first time that developers have ever been able to programmatically access Slides!

The Slides API breaks new ground, changing the way that presentations are created. No longer do they require manual creation by users on their desktops or mobile devices. Business data on inventory items like retail merchandise, homes/property, hotels/lodging, restaurants/menus, venues/events, and other "cataloged" assets can be instantly turned into presentations based on pre-existing slide templates. Traditionally, the sheer amount of data (and of course time[!]) that went into creating these slide decks made it unwieldy if done by hand. Applications leveraging the API can easily generate presentations like these, customized as desired, and in short order.

Developers use the API by crafting a JSON payload for each request. (We recommend you batch multiple commands together to send to the API.) You can think of these as actions one can perform from the Slides user interface but available programmatically. To give you an idea of how the new API works, here are what some requests look like for several common operations:

// create new slide (title & body layout)
{
    "createSlide": {
        "slideLayoutReference": {
            "predefinedLayout": "TITLE_AND_BODY"
        }
    }
},
// insert text into textbox
{
    "insertText": {
        "objectId": titleID,
        "text": "Hello World!"
    }
},
// add bullets to text paragraphs
{
    "createParagraphBullets": {
        "objectId": shapeID,
        "textRange": {
            "type": "ALL"
        }
    }
},
// replace text "variables" with image
{
    "replaceAllShapesWithImage": {
        "imageUrl": imageURL,
        "replaceMethod": "CENTER_INSIDE",
        "containsText": {
            "text": "{{COMPANY_LOGO}}"
        }
    }
}

If you're interested in seeing what developers have already built using the API, take a look at our initial set of partner integrations by Conga, Trello, Lucidchart, Zapier and more, as described in detail in our G Suite blog post.


To help you get started, check out the DevByte above from our new series dedicated to G Suite developers. In the video, we demonstrate how to take "variables" or placeholders in a template deck and use the API to generate new decks replacing those proxies with the desired text or image. Want to dive deeper into its code sample? Check out this blogpost. If you're not a Python developer, it'll be your pseudocode as you can use any language supported by the Google APIs Client Libraries. Regardless of your development environment, you can use similar "scaffolding" to generate many presentations with varying content for your users. Stay tuned for more videos that highlight other Slides API features.

The Slides API is available to projects in your Google Developers console today. Developers can find out more in the official documentation which features an API overview plus Quickstarts, sample code in multiple languages and environments, to bootstrap your next project. We look forward to seeing all the amazing slide deck generating applications you build with our first ever API!