Run Apps Script code from anywhere using the Execution API

Friday, September 25, 2015 | 12:23 PM

Labels: , , , , , , ,

Posted by Edward Jones, Software Engineer, Google Apps Script and Wesley Chun, Developer Advocate, Google Apps

Have you ever wanted a server API that modifies cells in a Google Sheet, to execute a Google Apps Script app from outside of Google Apps, or a way to use Apps Script as an API platform? Today, we’re excited to announce you can do all that and more with the Google Apps Script Execution API.

The Execution API allows developers to execute scripts from any client (browser, server, mobile, or any device). You provide the authorization, and the Execution API will run your script. If you’re new to Apps Script, it’s simply JavaScript code hosted in the cloud that can access authorized Google Apps data using the same technology that powers add-ons. The Execution API extends the ability to execute Apps Script code and unlocks the power of Docs, Sheets, Forms, and other supported services for developers.

One of our launch partners, Pear Deck, used the new API to create an interactive presentation tool that connects students to teachers by converting slide decks into interactive experiences. Their app calls the Execution API to automatically generate a Google Doc customized for each student, so everyone gets a personalized set of notes from the presentation. Without the use of Apps Script, their app would be limited to using PDFs and other static file types. Check out the video below to see how it works.

Bruce McPherson, a Google Developer Expert (GDE) for Google Apps, says: “The Execution API is a great tool for enabling what I call ‘incremental transition’ from Microsoft Office (and VBA) to Apps (and Apps Script). A mature Office workflow may involve a number of processes currently orchestrated by VBA, with data in various formats and locations. It can be a challenge to move an entire workload in one step, especially an automated process with many moving parts. This new capability enables the migration of data and process in manageable chunks.” You can find some of Bruce’s sample migration code using the Execution API here.

The Google Apps Script Execution API is live and ready for you to use today. To get started, check out the developer documentation and quickstarts. We invite you to show us what you build with the Execution API!

Programmatically transfer ownership of Google+ pages and Google Drive content

Thursday, September 17, 2015 | 9:37 AM

Labels: , ,

Google Apps users generate a lot of content at work—project plans, design documents, client presentations, and more. Many of these files are still relevant to an employee’s company or team even after he or she has left or transferred internally. The new Data Transfer API will make it easier for developers to build tools that will allow admins to better manage their end-user data, specifically apps that can transfer ownership of Google Docs, Sheets, and Slides, and all the other Google Drive files as well as Google+ pages in your Google for Work account—in bulk—from one employee/end-user to another using the API.

In July, we introduced the Data Transfer privilege, which makes it easier for admins to transfer data ownership. That same privilege is leveraged by the Data Transfer API. When enabled, it allows admins to programmatically migrate file ownership anytime they want using the API—provided they’ve enabled API access. In order to transfer ownership of Google Drive content as well as Google+ pages, super admins will need to grant/delegate the Data Transfer privilege to admins before end-user content can be migrated programmatically (via API or 3rd-party tools) or from the admin console.

This is what User Deletion looks like in the Administration console,
but now you can also do this programmatically with the API.

To get started with the Data Transfer API, take a look at the developer documentation. Keep in mind that while this programmatic feature is new, admins can still transfer user data manually from the admin console. For more general information, see the Help Center pages on transferring file ownership on Google Drive and how to delete a user.

Google Calendar API invites users to great experiences

Tuesday, September 15, 2015 | 10:01 AM


Originally posted on the Google Developers Blog.

Posted by Wesley Chun, Developer Advocate

Have you ever booked a dining reservation, plane ticket, hotel room, concert ticket, or seats to the game from your favorite app, only to have to exit that booking app to enter the details into your calendar? It doesn’t make for a friendly user experience. Why can’t today’s apps do that for you automatically?

In case you missed it the episode 97 of #GoogleDev100 the other week, I aim to inspire how app developers can streamline that process with the help of the Google Calendar API. A short Python script, anchored by the following snippet, is illustrated to show developers how easy it is to programmatically add calendar events:

CALENDAR ='calendar', 'v3', http=creds.authorize(Http()))
GMT_OFF = '-07:00' # PDT/MST/GMT-7
    'summary': 'Dinner with friends',
    'start': {'dateTime': '2015-09-18T19:00:00%s' % GMT_OFF},
    'end':   {'dateTime': '2015-09-18T22:00:00%s' % GMT_OFF},
    'attendees': [
        {'email': ''},
        {'email': ''},
}'primary', body=EVENT).execute()

For deeper dive into the script, check out the corresponding blogpost. With code like that, your app can automatically insert your relevant events into your users’ calendars, saving them the effort of manually doing it themselves. One of the surprising aspects is that a limited set of actions, such as RSVPing, is even available to non-Google Calendar users. By the way, inserting events is just the beginning. Developers can also delete or update events instantly in case that upcoming dinner gets pushed back a few weeks. Events can even be repeated with a recurrence rule. Attachments are also supported so you can provide your users a PDF of the concert tickets they just booked. Those are just some of the things the API is capable of.

Ready to get started? Much more information, including code samples in Java, PHP, .NET, Android, iOS, and more, can be found in the Google Calendar API documentation. If you’re new to the Launchpad Online developer series, we share technical content aimed at novice Google developers… the latest tools and features with a little bit of code to help you launch that app. Please give us your feedback below and tell us what topics you would like to see in future episodes!

Google Apps Marketplace gets a fresh new look

Thursday, September 3, 2015 | 10:21 AM


Posted by, Chris Han, Product Manager Google Apps Marketplace

The Google Apps Marketplace brings together hundreds of third-party applications that integrate with and enhance Google Apps for Work. It’s a great place to get discovered by more than five million Google Apps customers. Many of these customers depend on Google Apps Marketplace to find the solutions their organizations need, driving millions of users to the top listed apps.

Today, we’ve launched a brand new Google Apps Marketplace site aimed to improving discoverability and getting your app installed by even more customers. No need to do anything if you’ve already listed your app publicly on Google Apps Marketplace. Your app will appear on the new site automatically.

If you haven’t listed your app yet on Google Apps Marketplace, follow these instructions to get started!

Deprecating web hosting support in Google Drive

Monday, August 31, 2015 | 10:22 AM


Beginning August 31st, 2015, web hosting in Google Drive for users and developers will be deprecated. You can continue to use this feature for a period of one year until August 31st, 2016, when we will discontinue serving content via[doc id].

In the time since we launched web hosting in Drive, a wide variety of public web content hosting services have emerged. After careful consideration, we have decided to discontinue this feature and focus on our core user experience.

For those who have used Drive to host websites, Google Domains can refer you to third parties for website hosting functionality.

For those who use this feature to serve non-user content to web and mobile applications, Google Cloud Platform offers a better-performing solution.

Real-time notifications in add-ons with Firebase

Wednesday, July 29, 2015 | 3:09 PM

Labels: , ,

Editor's note: Posted by Romain Vialard, a Google Developer Expert and developer of Yet Another Mail Merge, a Google Sheets add-on.

Yet Another Mail Merge is a Google Sheets add-on that lets users send multiple personalized emails based on a template saved as a draft in Gmail and data in a Google Sheet. It can send hundreds of emails, but this kind of operation usually takes a few minutes to complete. This raises the question: what should be displayed in the user interface while a function is running on server side for a long time?

Real-time notifications in Add-ons

Firebase is all about real-time and became the answer to that issue. Last December, the Apps Script team announced a better version of the HtmlService with far fewer restrictions and the ability to use external JS libraries. With Firebase, we now had a solution to easily store and sync data in real-time.

Combined, users are able to know, in real-time, the number of emails sent by an Apps Script function running server-side. When the user starts the mail merge, it calls the Apps Script function that sends emails and connects to Firebase at the same time. Every time the Apps Script function has finished sending a new email, it increments a counter on Firebase and the UI is updated in real-time, as shown in the following image.


Inside the loop, each time an email is sent (i.e. each time we use the method GmailApp.sendEmail()), we use the Apps Script UrlFetch service to write into Firebase using its REST API. Firebase's capabilities makes this easy & secure and there’s no need for an OAuth Authorization Flow, just a Firebase app secret, as shown in the following example:

function addNewUserToFirebase() {
  var dbUrl = "";
  var secret = PropertiesService.getScriptProperties().getProperty("fb-secret");
  var path = "/users/";
  var userData = {
      registrationDate: new Date()
  var params = {
    method: "PUT",
    payload : JSON.stringify(userData)
   UrlFetchApp.fetch(dbUrl + path + ".json?auth=" + secret, params);

On the client side, thanks to the improved Apps Script HtmlService, we can use the official JS client library to connect to Firebase and retrieve the data stored previously. Specifically, the on() method in this library can be used to listen for data changes at a particular location in our database. So each time a new task is completed on server side (e.g. new email sent), we notify Firebase and the UI is automatically updated accordingly.

var fb = new Firebase("");
var ref = fb.child('users/' + UID + '/nbOfEmailsSent');
ref.on("value", function(data) {
  if (data.val()) {
    document.getElementById("nbOfEmailsSent").innerHTML = data.val();

More Firebase in Add-ons

In addition to the example above, there are other places where Firebase can be useful in Google Apps Script add-ons.

  • “Yet Another Mail Merge” also offers paid plans and it needs to store our customer list. It turns out, Firebase is perfect for that as well. Each time someone buys a plan, our payment tool calls an Apps Script web app which writes the payment details in Firebase. So right after the purchase, the user can open the add-on and a function on server side will call Firebase and see that premium features should now be enabled for this user.
  • Last but not least, at the end of a mail merge, we also use Firebase to provide real-time reporting of emails opened, directly in the sidebar of the spreadsheet.

Those are just a few examples of what you can do with Apps Script and Firebase. Don’t hesitate to try it yourself or install Yet Another Mail Merge to see a live example. In addition, there is a public Apps Script library called FirebaseApp that can help you start with Firebase; use it like any other standard Apps Script library.

For example, you can easily fetch data from Firebase using specific query parameters:

function getFrenchContacts() {
  var firebaseUrl = "";
  var base = FirebaseApp.getDatabaseByUrl(firebaseUrl);
  var queryParameters = {orderBy:"country", equalTo: "France"};
  var data = base.getData("", queryParameters);
  for(var i in data) {
    Logger.log(data[i].firstName + ' ' + data[i].lastName
        + ' - ' + data[i].country);

Build your own add-ons via Google Apps Script. Check out the documentation ( to get more information as well as try out the Quickstart projects there. We look forward to seeing your add-ons soon!

Romain Vialard profile | website

Romain Vialard is a Google Developer Expert. After some years spent as a Google Apps consultant, he is now focused on products for Google Apps users, including add-ons such as Yet Another Mail Merge and Form Publisher.

New ways to integrate with Google Classroom

Monday, June 29, 2015 | 11:28 AM


Classroom debuted last year to help teachers and students save time and collaborate with each other, and since then we’ve been working on how to make sure it worked well with other products that educators love and use in their classes.

Starting today, developers can embed the Classroom share button and sign up for the developer preview of the Classroom API. These tools make it easy for developers to seamlessly integrate with Classroom in ways that help teachers and students — like letting teachers create assignments directly from Quizlet, Duolingo, PBS and many other favorites.

Classroom API

By using the API, admins will be able to provision and populate classes on behalf of their teachers, set up tools to sync their Student Information Systems with Classroom, and get basic visibility into which classes are being taught in their domain. The Classroom API also allows other apps to integrate with Classroom.

Until the end of July, we’ll be running a developer preview, during which interested admins and developers can sign up for early access. When the preview ends, all Apps for Education domains will be able to use the API, unless the admin has restricted access.

A few developers have been helping us test the API, and we’re excited to share a few examples of what they’ve built:

  • The New Visions CloudLab (makers of Doctopus) built rosterSync for Sheets, an add-on integrated with Classroom. Harnessing the power of Google Sheets, admins can sync data from any student information system with Classroom.
  • Alma, a hybrid student information and learning management platform, will let schools easily create and sync their class rosters directly to Classroom with just a few clicks. And if an admin adds a student to a class in Alma, that student will get automatically added in the Classroom class. See more in their demo video.
  • And if you use Pear Deck, it’s now easy to start an interactive Pear Deck session with any of your Classroom classes. Just click “Invite from Google Classroom,” choose a class and your students will automatically be invited. Pear Deck will always use your current roster of students from Classroom, so you don’t have to keep rosters up to date across apps.

Classroom share button

Today we’re also introducing the Classroom share button, a simple way for developers – or schools – to allow teachers and students to seamlessly assign or turn-in links, videos and images from another webpage or product.

The share button only requires a few lines of JavaScript, and you can customize the button to meet the needs of your website. When teachers and students click the button, they can quickly share to Classroom without having to leave the site they’re on. More than 20 educational content and tool providers have already committed to integrating the Classroom share button, including:

To get started or learn more about either the API or integrating the share button, visit And let us know what you’re building using the #withclassroom hashtag on Twitter or G+. As always, we’re looking forward to hearing your feedback and making sure that we’re addressing top needs. We’ll use the developer community site Stack Overflow to field technical questions and feedback about the Classroom API. Please use the tag google-classroom.