Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including gapi-nano with all npm packages installed. Try it out:

var gapiNano = require("gapi-nano")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gapi-nano v1.0.1

a wrapper for Google API Client Library for using Google Apps Script REST Execution API


This is a wrapper for the Google API Client Library, providing opinionated syntactic sugar for client authentication and making requests to a Google Apps Script via the REST Execution API


Basic Usage

In your html, include the browser build gapi-nano.js from the dist directory after

<script src=""></script>
<script src="/dist/gapi-nano.js"></script>

Then in another script below that, pass in some options to gapiNano.init to get started

  var options = {
    discoveryDocs: ["$discovery/rest?version=v1"],
    scope: '[SCOPE]',
    scriptId: '[SCRIPT_ID]'

    console.log("User signed in?", signedIn)'sum',{a:1,b:2}).then(function(result){
      console.log('sum of 1 and 2 is', result)



init(options, authListener)undefined

init - loads and authenticates gapi client using Auth2

run(fName, parameters)Promise

run - calls a function from the script specified by scriptId option during init()

init(options, authListener) ⇒ undefined

gapiNano.init - loads and authenticates gapi client using Auth2

optionsobjectAuth2 options, including clientId and scope
authListenerfunction(optional) callback with a single boolean parameter, called whenever the authentication status changes

run(fName, parameters) ⇒ Promise - calls a function from the script specified by scriptId option during init()

Returns: Promise - a Promise object resolved with result of the function call

fNamestringthe name of the function
parametersobject(optional) the arguments passed to the function

Building Changes

To rebuild dist/gapi-nano.js from index.js, use the npm task:

$ npm run dist

Of course this requires browserify to be installed globally:

$ npm install -g browserify


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free