Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-slides

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-slides

NPM package for some simple Google Slides operations

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by66.67%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Presentation.replaceAllText

See API.replaceAllText. 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 = 'wpbdry@gmail.com'
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}!`))
API.replaceAllText
api.replaceAllText(presentationId, {
    text: '{{title}}',
    replaceText: 'My Presentation'
})
.catch(error => doSomething(error))

or

api.replaceAllText(presentationId, [{
    text: 'Cape',
    replaceText: 'Cape Town'
    matchCase: true
}, {
    text: 'bandana',
    replaceText: 'shawl'
}])
.catch(error => doSomething(error))

TextReplacement

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

const api = new API('path/to/credentials.json')
api.replaceAllText(presentationId, [
    new TextReplacement('Cape', 'Cape Town', true),
    new TextReplacement('bandana', 'shawl')
])
.catch(error => doSomething(error))

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.

Keywords

FAQs

Package last updated on 23 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc