npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

google-slides

v2.1.1

Published

NPM package for some simple Google Slides operations

Readme

Build Status

google-slides

NPM package for some simple Google Slides operations

contents

prerequisites

preparation

  1. visit the Google developers console
  2. create a new project
  3. enable the Google Drive and Google Slides APIs for your project
  4. create a service account connected to your project
  5. generate and download JSON credentials for your service account

installation

npm install google-slides

Presentation

copy

import { API, Presentation } from 'google-slides'

const api = new API('path/to/credentials.json')
const presentationId = '1yMEqtOta984dwNyJoeU92tsC5x7GV2fQK7V4wJc60Mg'
const template = new Presentation({ id: presentationId }, api)
template.copy()
.then(newPresentation => console.log(`New presentation created with name ${newPresentation.name} and ID ${newPresentation.id}.`))
.catch(e => console.log('Copy error:', e))

share

See API.sharePresentation. Instead of api.sharePresentation use presentation.share and don't pass id.

batchUpdate

See API.presentationBatchUpdate. Instead of api use presentation and don't pass presentationId.

API

import { API } from 'google-slides'

const api = new API('path/to/credentials.json')

copyPresentation

api.copyPresentation(id)
.then(newPresentation => console.log(`name: ${newPresentation.name}, id: ${newPresentation.id}`))

sharePresentation

const emailAddress = '[email protected]'
const role = 'writer'  // One of: owner | organizer | fileOrganizer | writer | commenter | reader
const type = 'user'  // One of: user | group | domain | anyone
const sendNotificationEmails = false 
api.sharePresentation(id, emailAddress, role, type, sendNotificationEmails)
.then(() => console.log(`Presentation with ID ${id} successfully shared with ${emailAddress}!`))

presentationBatchUpdate

import { API, TextReplacement, ShapeReplacementWithImage } from 'google-slides'

const api = new API('path/to/credentials.json')

api.presentationBatchUpdate(presentationId, [
    new TextReplacement('{{client-name}}', 'My Client'),
    new ShapeReplacementWithImage('{{client-logo}}', logoUrl)
])
.catch(error => doSomething(error))
TextReplacement

Replaces all instances of text matching a criterion with replaceText. \

const text = '{{some-text-to-replace}}'
const replaceText = 'Replacement Text'
const matchCase = true  // default
const textReplacement = new TextReplacement(text, replaceText, matchCase)
ShapeReplacementWithImage

Replaces all shapes that match the given criteria with the provided image.

const text = '{{text-contained-within-shape}}'
const imageUrl = 'https://example.com/my-img'
const matchCase = true  // default
const replaceMethod = 'CENTER_INSIDE'  // default
const shapeReplacement = new ShapeReplacementWithImage(text, imageUrl, matchCase, replaceMethod)

underlying services

The API class implements underlying services, which can be accessed directly if they are awaited. This provides access to further functions from the googleapis module, which may not be implemented here.

driveService

import { API } from 'google-slides'

(async function() {
    const api = new API('path/to/credentials.json')
    (await api.driveService).doSomething()
})()

The driveService object here is equivelant to the drive object used in all the Node.js snippets in the Google Drive API V3 documentation

slidesService

import { API } from 'google-slides'

(async function() {
    const api = new API('path/to/credentials.json')
    (await api.slidesService).doSomething()
})()

The slidesService object here is equivelant to the slides or this.slidesService objects used in all the Node.js snippets in the Google Slides API documentation

why await?

When new API('path/to/credentials.json') is called, the API logs in with the provided credentials, and initialized the underlying services. Since logging in happens asynchronously, the services may not yet exist by the time they are used. These services are awaited every time they are used in the built in methods. You only need to await each service the first time you use it in any single promise chain.