+Wesley Chun
Developer Advocate
G Suite
Programming Google apps with the G Suite APIs
Contribute
questions at:
goo.gl/Rq6ABI
2017
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides, Apps Script & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides, Apps Script & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides, Apps Script & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides, Apps Script & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides, Apps Script & more
Proprietary + Confidential
Google APIs client
libraries for many
languages, not just
Proprietary + Confidential
● Launched API v3 (Dec 2015)
○ v2 not deprecated (yet)
● WhatsApp integration (I/O 2016)
● Coming soon: Team Drives
(announced Sep 2016;
launched EAP: Mar 2017)
Drive
List (first 100) files in Google Drive
from __future__ import print_function
from apiclient import discovery
from httplib2 import Http
from oauth2client import file, client, tools
SCOPES = 'https://www.googleapis.com/auth/drive.readonly.metadata'
store = file.Storage('storage.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
creds = tools.run_flow(flow, store)
DRIVE = discovery.build('drive', 'v3', http=creds.authorize(Http()))
files = DRIVE.files().list().execute().get('files', [])
for f in files:
print(f['name'], f['mimeType'])
● API preview (I/O 2016)
● Launched API v1 (Nov 2016)
● Enhancements “v1.1” (Feb 2017)
Slides
Confidential & Proprietary
Confidential & Proprietary
Try our Node.js Markdown-to-Google-Slides generator:
github.com/googlesamples/md2googleslides
Replace text & images from template deck
requests = [
# (global) search-and-replace text
{'replaceAllText': {
'findText': '{{TITLE}}',
'replaceText': 'Hello World!',
}},
# replace text-based image placeholders (global)
{'replaceAllShapesWithImage': {
'imageUrl': IMG_URL, # link to product logo
'replaceMethod': 'CENTER_INSIDE',
'containsText': {'text': '{{LOGO}}'},
}},
]
SLIDES.presentations().batchUpdate(body={'requests': requests},
presentationId=DECK_ID, fields='').execute()
Proprietary + Confidential
● Launched API v4 (I/O 2016)
● Support text rotation (Mar 2017)
Sheets
Powerful API: expect UI features available programmatically
● Create new sheets within
spreadsheets
● Add data to sheets
● Create new spreadsheets
● Set frozen rows
● Text+number formatting
● Enforce cell validation
● Adjust column sizes
● Apply formulas
● Build pivot tables
● Create charts
● … and more!
BEFORE
(<= v3)
AFTER
(>= v4)
Import/Export: Customized reports, “database,” or both!
Try our Node.js customized reporting tool codelab:
g.co/codelabs/sheets
Migrate SQL data to a Sheet
# read SQL data then create new spreadsheet & add rows into it
FIELDS = ('ID', 'Customer Name', 'Product Code',
'Units Ordered', 'Unit Price', 'Status')
cxn = sqlite3.connect('db.sqlite')
cur = cxn.cursor()
rows = cur.execute('SELECT * FROM orders').fetchall()
cxn.close()
rows.insert(0, FIELDS)
DATA = {'properties': {'title': 'Customer orders'}}
SHEET_ID = SHEETS.spreadsheets().create(body=DATA,
fields='spreadsheetId').execute().get('spreadsheetId')
SHEETS.spreadsheets().values().update(spreadsheetId=SHEET_ID, range='A1',
body={'values': rows}, valueInputOption='RAW').execute()
Format cells (frozen & bold row)
requests = [
# freeze row 1
{'updateSheetProperties': {
'properties': {'gridProperties': {'frozenRowCount': 1}},
'fields': 'gridProperties.frozenRowCount',
}},
# bold row 1
{'repeatCell': {
'range': {'startRowIndex': 0, 'endRowIndex': 1},
'cell': {'userEnteredFormat': {'textFormat': {'bold': True}}},
'fields': 'userEnteredFormat.textFormat.bold',
}},
]
SHEETS.spreadsheets().batchUpdate(body={'requests': requests},
spreadsheetId=SHEET_ID, fields='').execute()
Proprietary + Confidential
● Settings endpoints launch (Jul 2016)
● New metadata scope (Nov 2016)
● Gmail add-ons (Mar 2017)
● Admin SDK Email Settings
deprecation (Jul 2017)
Gmail
Display Gmail threads (& # of messages)
# get all non-empty mail threads, display Subject & # of msgs in each
threads = GMAIL.users().threads().list(userId='me',
fields='threads').execute().get('threads', [])
for thread in threads:
tdata = GMAIL.users().threads().get(userId='me', id=thread['id'],
format='metadata', metadataHeaders=['subject'],
fields='messages/payload/headers(name,value)').execute()
if 'messages' not in tdata:
continue
msg = tdata['messages'][0]['payload'] # get 1st msg in thread
subject = ''
for header in msg['headers']: # get Subject line
if header['name'] == 'Subject':
subject = header['value']
break
if subject: # display if non-blank Subject
print('%2d message(s) in thread: %s' % (
len(tdata['messages']), subject))
Proprietary + Confidential
● Reminders on the web (Apr 2016)
● Events on Google Maps (Sep 2016)
● Find a time” on iOS (Sep 2016)
● New Calendar iOS app (Nov 2016)
Calendar
Create events in Calendar
# define event data, then create event
TIMEZONE = 'America/Los_Angeles'
EVENT = {
'summary': 'Dinner with friends',
'start': {'dateTime': '2017-06-14T19:00:00', 'timeZone': TIMEZONE},
'end': {'dateTime': '2017-06-14T22:00:00', 'timeZone': TIMEZONE},
'attendees': [
{'email': 'friend1@example.com'},
{'email': 'friend2@example.com'},
],
}
GCAL.events().insert(calendarId='primary', body=EVENT,
sendNotifications=True, fields='').execute()
Proprietary + Confidential
● Execution API allows external apps
to call Apps Script apps (Sep 2015)
● Android add-ons (Jul 2016)
● Advanced Services for Sheets &
Slides (Mar 2017)
● Quizzes in Forms support (Apr 2017)
Apps
Script
Sheets-bound “Hello World!”
Sheets-bound “Hello World!”
What can you do with this?
This… with help from Google Maps
AND this… with help from Maps and Gmail
Proprietary + Confidential
● Mobile Audit in Reports API
launched (May 2016)
● OAuth 1.0 deprecated (Oct 2016)
● New Drive metrics in Reports API
(Apr 2017)
● GData Admin Settings API
deprecated (Aug 2017)
Admin
SDK
Programmatically manage your domain
Proprietary + Confidential
● Classroom share button callbacks
(Dec 2015)
● Coursework access & improved Drive
integration (May 2016)
● Improved teachers & guardian
support (Aug 2016)
● Create+update questions,
modify+delete coursework, add Drive
items+YouTube videos (Jan 2017)
Classroom
Blog & video references
● G Suite APIs
○ Drive: goo.gl/ZIgf8k and goo.gl/EySSQV
○ Gmail: goo.gl/pFYUQ2
○ Calendar: goo.gl/KuYMiq
○ Sheets: goo.gl/N1RPwC and goo.gl/U6Oljn
○ Slides: developers.google.com/slides/videos
○ Sheets & Slides: goo.gl/Yb06ZC
● Google Apps Script
○ developers.google.com/apps-script/guides/videos
(intro, Google Maps & Gmail, YouTube, Google Forms)
Thank you!
Questions?
+Wesley Chun
google.com/+WesleyChun
@wescpy
twitter.com/wescpy
slide deck
goo.gl/Hs0IIR
Contribute
questions at:
goo.gl/Rq6ABI
CODELAB: Sat,
May 6, 10a-1230p
Great Falls room

More Related Content

PDF
G Suite & Google APIs coding workshop
PDF
Google Apps Script: Accessing G Suite & other Google services with JavaScript
PDF
Exploring Google APIs with Python
PDF
Exploring Google (Cloud) APIs with Python & JavaScript
PPTX
EOY Project Pitch - Elaine Yeung
PPTX
PDF
Argocd up and running
G Suite & Google APIs coding workshop
Google Apps Script: Accessing G Suite & other Google services with JavaScript
Exploring Google APIs with Python
Exploring Google (Cloud) APIs with Python & JavaScript
EOY Project Pitch - Elaine Yeung
Argocd up and running

What's hot (9)

PDF
Google Summer of Code and BeagleBoard.org
PDF
A GitOps Kubernetes Native CICD Solution with Argo Events, Workflows, and CD
PDF
Introduction à GWT
PDF
Gradle enabled android project
PPT
MVP with GWT and GWTP
PDF
A week in the Life of Kubernetes
PDF
Gophercon 2018: Kubernetes api golang
PPTX
Cloud Study Jam Exploring the Cloud
PDF
Drupal content automation with migrate 2.6
Google Summer of Code and BeagleBoard.org
A GitOps Kubernetes Native CICD Solution with Argo Events, Workflows, and CD
Introduction à GWT
Gradle enabled android project
MVP with GWT and GWTP
A week in the Life of Kubernetes
Gophercon 2018: Kubernetes api golang
Cloud Study Jam Exploring the Cloud
Drupal content automation with migrate 2.6
Ad

Viewers also liked (7)

PDF
Exploring Google APIs with Python & JavaScript
PDF
Coding Google... you can do it!
PDF
What is Python? (Silicon Valley CodeCamp 2015)
PDF
What is the Google Cloud Platform?
PDF
Power & flexibility of the Google Sheets API
PDF
Google Cloud Platform & APIs Overview
PDF
What is Python?
Exploring Google APIs with Python & JavaScript
Coding Google... you can do it!
What is Python? (Silicon Valley CodeCamp 2015)
What is the Google Cloud Platform?
Power & flexibility of the Google Sheets API
Google Cloud Platform & APIs Overview
What is Python?
Ad

Similar to Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides, Apps Script & more (20)

PDF
Exploring MORE Google (Cloud) APIs with Python
PDF
Using Google (Cloud) APIs
PDF
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
PPTX
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
PPTX
APIs, APIs Everywhere!
PPTX
SharePoint Conference 2018 - APIs, APIs everywhere!
PDF
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
PPTX
Cnam azure 2014 mobile services
PDF
Google Apps Script: Accessing G Suite & other Google services with JavaScript
PPTX
Goa tutorial
PDF
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
PPTX
Microsoft Graph: Connect to essential data every app needs
PPTX
Microsoft Graph: Connect to essential data every app needs
PDF
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
PDF
The Big Picture and How to Get Started
PPTX
Intro to Parse
PDF
Image archive, analysis & report generation with Google Cloud
PDF
Node.js and Parse
PDF
Building an Android app with Jetpack Compose and Firebase
PDF
From zero to Google APIs: Beyond search & AI... leverage all of Google
Exploring MORE Google (Cloud) APIs with Python
Using Google (Cloud) APIs
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
APIs, APIs Everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
Cnam azure 2014 mobile services
Google Apps Script: Accessing G Suite & other Google services with JavaScript
Goa tutorial
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Microsoft Graph: Connect to essential data every app needs
Microsoft Graph: Connect to essential data every app needs
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
The Big Picture and How to Get Started
Intro to Parse
Image archive, analysis & report generation with Google Cloud
Node.js and Parse
Building an Android app with Jetpack Compose and Firebase
From zero to Google APIs: Beyond search & AI... leverage all of Google

More from wesley chun (20)

PDF
Deploy Basic AI web apps with Serverless Computing from Google Cloud
PDF
Powerful Google developer tools for immediate impact! (2023-24 C)
PDF
Automating Google Workspace (GWS) & more with Apps Script
PDF
Easy path to machine learning (2023-2024)
PDF
Powerful Google developer tools for immediate impact! (2023-24 B)
PDF
Exploring Google APIs with Python
PDF
Powerful Google developer tools for immediate impact! (2023-24 A)
PDF
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
PDF
Serverless Computing with Python
PDF
Easy path to machine learning (2022)
PDF
Google... more than just a cloud
PDF
Accessing Google Cloud APIs
PDF
Serverless computing with Google Cloud
PDF
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
PDF
Easy path to machine learning (Spring 2021)
PDF
Exploring Google APIs with Python
PDF
Serverless Computing with Google Cloud
PDF
Run your code serverlessly on Google's open cloud
PDF
Serverless Computing with Python
PDF
Introduction to Cloud Computing with Google Cloud
Deploy Basic AI web apps with Serverless Computing from Google Cloud
Powerful Google developer tools for immediate impact! (2023-24 C)
Automating Google Workspace (GWS) & more with Apps Script
Easy path to machine learning (2023-2024)
Powerful Google developer tools for immediate impact! (2023-24 B)
Exploring Google APIs with Python
Powerful Google developer tools for immediate impact! (2023-24 A)
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Serverless Computing with Python
Easy path to machine learning (2022)
Google... more than just a cloud
Accessing Google Cloud APIs
Serverless computing with Google Cloud
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Easy path to machine learning (Spring 2021)
Exploring Google APIs with Python
Serverless Computing with Google Cloud
Run your code serverlessly on Google's open cloud
Serverless Computing with Python
Introduction to Cloud Computing with Google Cloud

Recently uploaded (20)

PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
August Patch Tuesday
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Getting Started with Data Integration: FME Form 101
PPTX
observCloud-Native Containerability and monitoring.pptx
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPT
Geologic Time for studying geology for geologist
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Architecture types and enterprise applications.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
O2C Customer Invoices to Receipt V15A.pptx
Taming the Chaos: How to Turn Unstructured Data into Decisions
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
WOOl fibre morphology and structure.pdf for textiles
August Patch Tuesday
sustainability-14-14877-v2.pddhzftheheeeee
Final SEM Unit 1 for mit wpu at pune .pptx
Benefits of Physical activity for teenagers.pptx
Getting Started with Data Integration: FME Form 101
observCloud-Native Containerability and monitoring.pptx
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Geologic Time for studying geology for geologist
Group 1 Presentation -Planning and Decision Making .pptx
Architecture types and enterprise applications.pdf
Tartificialntelligence_presentation.pptx
Developing a website for English-speaking practice to English as a foreign la...
Assigned Numbers - 2025 - Bluetooth® Document
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx

Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides, Apps Script & more

  • 1. +Wesley Chun Developer Advocate G Suite Programming Google apps with the G Suite APIs Contribute questions at: goo.gl/Rq6ABI 2017
  • 7. Proprietary + Confidential Google APIs client libraries for many languages, not just Proprietary + Confidential ● Launched API v3 (Dec 2015) ○ v2 not deprecated (yet) ● WhatsApp integration (I/O 2016) ● Coming soon: Team Drives (announced Sep 2016; launched EAP: Mar 2017) Drive
  • 8. List (first 100) files in Google Drive from __future__ import print_function from apiclient import discovery from httplib2 import Http from oauth2client import file, client, tools SCOPES = 'https://www.googleapis.com/auth/drive.readonly.metadata' store = file.Storage('storage.json') creds = store.get() if not creds or creds.invalid: flow = client.flow_from_clientsecrets('client_secret.json', SCOPES) creds = tools.run_flow(flow, store) DRIVE = discovery.build('drive', 'v3', http=creds.authorize(Http())) files = DRIVE.files().list().execute().get('files', []) for f in files: print(f['name'], f['mimeType']) ● API preview (I/O 2016) ● Launched API v1 (Nov 2016) ● Enhancements “v1.1” (Feb 2017) Slides
  • 9. Confidential & Proprietary Confidential & Proprietary Try our Node.js Markdown-to-Google-Slides generator: github.com/googlesamples/md2googleslides
  • 10. Replace text & images from template deck requests = [ # (global) search-and-replace text {'replaceAllText': { 'findText': '{{TITLE}}', 'replaceText': 'Hello World!', }}, # replace text-based image placeholders (global) {'replaceAllShapesWithImage': { 'imageUrl': IMG_URL, # link to product logo 'replaceMethod': 'CENTER_INSIDE', 'containsText': {'text': '{{LOGO}}'}, }}, ] SLIDES.presentations().batchUpdate(body={'requests': requests}, presentationId=DECK_ID, fields='').execute() Proprietary + Confidential ● Launched API v4 (I/O 2016) ● Support text rotation (Mar 2017) Sheets
  • 11. Powerful API: expect UI features available programmatically ● Create new sheets within spreadsheets ● Add data to sheets ● Create new spreadsheets ● Set frozen rows ● Text+number formatting ● Enforce cell validation ● Adjust column sizes ● Apply formulas ● Build pivot tables ● Create charts ● … and more! BEFORE (<= v3) AFTER (>= v4) Import/Export: Customized reports, “database,” or both! Try our Node.js customized reporting tool codelab: g.co/codelabs/sheets
  • 12. Migrate SQL data to a Sheet # read SQL data then create new spreadsheet & add rows into it FIELDS = ('ID', 'Customer Name', 'Product Code', 'Units Ordered', 'Unit Price', 'Status') cxn = sqlite3.connect('db.sqlite') cur = cxn.cursor() rows = cur.execute('SELECT * FROM orders').fetchall() cxn.close() rows.insert(0, FIELDS) DATA = {'properties': {'title': 'Customer orders'}} SHEET_ID = SHEETS.spreadsheets().create(body=DATA, fields='spreadsheetId').execute().get('spreadsheetId') SHEETS.spreadsheets().values().update(spreadsheetId=SHEET_ID, range='A1', body={'values': rows}, valueInputOption='RAW').execute() Format cells (frozen & bold row) requests = [ # freeze row 1 {'updateSheetProperties': { 'properties': {'gridProperties': {'frozenRowCount': 1}}, 'fields': 'gridProperties.frozenRowCount', }}, # bold row 1 {'repeatCell': { 'range': {'startRowIndex': 0, 'endRowIndex': 1}, 'cell': {'userEnteredFormat': {'textFormat': {'bold': True}}}, 'fields': 'userEnteredFormat.textFormat.bold', }}, ] SHEETS.spreadsheets().batchUpdate(body={'requests': requests}, spreadsheetId=SHEET_ID, fields='').execute()
  • 13. Proprietary + Confidential ● Settings endpoints launch (Jul 2016) ● New metadata scope (Nov 2016) ● Gmail add-ons (Mar 2017) ● Admin SDK Email Settings deprecation (Jul 2017) Gmail Display Gmail threads (& # of messages) # get all non-empty mail threads, display Subject & # of msgs in each threads = GMAIL.users().threads().list(userId='me', fields='threads').execute().get('threads', []) for thread in threads: tdata = GMAIL.users().threads().get(userId='me', id=thread['id'], format='metadata', metadataHeaders=['subject'], fields='messages/payload/headers(name,value)').execute() if 'messages' not in tdata: continue msg = tdata['messages'][0]['payload'] # get 1st msg in thread subject = '' for header in msg['headers']: # get Subject line if header['name'] == 'Subject': subject = header['value'] break if subject: # display if non-blank Subject print('%2d message(s) in thread: %s' % ( len(tdata['messages']), subject))
  • 14. Proprietary + Confidential ● Reminders on the web (Apr 2016) ● Events on Google Maps (Sep 2016) ● Find a time” on iOS (Sep 2016) ● New Calendar iOS app (Nov 2016) Calendar Create events in Calendar # define event data, then create event TIMEZONE = 'America/Los_Angeles' EVENT = { 'summary': 'Dinner with friends', 'start': {'dateTime': '2017-06-14T19:00:00', 'timeZone': TIMEZONE}, 'end': {'dateTime': '2017-06-14T22:00:00', 'timeZone': TIMEZONE}, 'attendees': [ {'email': 'friend1@example.com'}, {'email': 'friend2@example.com'}, ], } GCAL.events().insert(calendarId='primary', body=EVENT, sendNotifications=True, fields='').execute()
  • 15. Proprietary + Confidential ● Execution API allows external apps to call Apps Script apps (Sep 2015) ● Android add-ons (Jul 2016) ● Advanced Services for Sheets & Slides (Mar 2017) ● Quizzes in Forms support (Apr 2017) Apps Script Sheets-bound “Hello World!”
  • 16. Sheets-bound “Hello World!” What can you do with this?
  • 17. This… with help from Google Maps AND this… with help from Maps and Gmail
  • 18. Proprietary + Confidential ● Mobile Audit in Reports API launched (May 2016) ● OAuth 1.0 deprecated (Oct 2016) ● New Drive metrics in Reports API (Apr 2017) ● GData Admin Settings API deprecated (Aug 2017) Admin SDK Programmatically manage your domain
  • 19. Proprietary + Confidential ● Classroom share button callbacks (Dec 2015) ● Coursework access & improved Drive integration (May 2016) ● Improved teachers & guardian support (Aug 2016) ● Create+update questions, modify+delete coursework, add Drive items+YouTube videos (Jan 2017) Classroom Blog & video references ● G Suite APIs ○ Drive: goo.gl/ZIgf8k and goo.gl/EySSQV ○ Gmail: goo.gl/pFYUQ2 ○ Calendar: goo.gl/KuYMiq ○ Sheets: goo.gl/N1RPwC and goo.gl/U6Oljn ○ Slides: developers.google.com/slides/videos ○ Sheets & Slides: goo.gl/Yb06ZC ● Google Apps Script ○ developers.google.com/apps-script/guides/videos (intro, Google Maps & Gmail, YouTube, Google Forms)
  • 20. Thank you! Questions? +Wesley Chun google.com/+WesleyChun @wescpy twitter.com/wescpy slide deck goo.gl/Hs0IIR Contribute questions at: goo.gl/Rq6ABI CODELAB: Sat, May 6, 10a-1230p Great Falls room