SlideShare a Scribd company logo
Exploring Google (Cloud) APIs
with Python & JavaScript
Wesley Chun
Developer Advocate, Google
Adjunct CS Faculty, Foothill College
G Suite Dev Show
goo.gl/JpBQ40
About the speaker
Developer Advocate, Google Cloud
● Mission: enable current and future
developers everywhere to be
successful using Google Cloud and
other Google developer tools & APIs
● Videos: host of the G Suite Dev Show
on YouTube
● Blogs: developers.googleblog.com &
gsuite-developers.googleblog.com
● Twitters: @wescpy, @GoogleDevs,
@GSuiteDevs
Previous experience / background
● Software engineer & architect for 20+ years
● One of the original Yahoo!Mail engineers
● Author of bestselling "Core Python" books
(corepython.com)
● Technical trainer, teacher, instructor since
1983 (Computer Science, C, Linux, Python)
● Fellow of the Python Software Foundation
● AB (Math/CS) & CMP (Music/Piano), UC
Berkeley and MSCS, UC Santa Barbara
● Adjunct Computer Science Faculty, Foothill
College (Silicon Valley)
Agenda
1
Introduction
2
Google Cloud
(GCP + G Suite)
3
Google APIs
4
Inspiration
5
Wrap-up
01
Introduction to
APIs
Why are you here?
Exploring Google (Cloud) APIs with Python & JavaScript
&
Google APIs client
libraries for many
languages; demos in
developers.google.com/api-
client-library
cloud.google.com/apis/docs
/cloud-client-libraries
02
Google Cloud
Google Compute Engine, Google Cloud Storage
AWS EC2 & S3; Rackspace; Joyent
SaaS
Software as a Service
PaaS
Platform as a Service
IaaS
Infrastructure as a Service
Google Apps Script
Salesforce1/force.com
G Suite (Google Apps)
Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365
Google App Engine, Cloud Functions
Heroku, Cloud Foundry, Engine Yard, AWS Lambda
Google BigQuery, Cloud SQL,
Cloud Datastore, NL, Vision, Pub/Sub
AWS Kinesis, RDS; Windows Azure SQL, Docker
Google Cloud Platform vs. G Suite
G Suite
APIs
GCP
APIs
03
Google APIs &
developer tools
(focusing on Cloud)
GCP data & storage services
Build, innovate, and scale with Google Cloud Platform
Storing Data: Cloud SQL
SQL servers in the cloud
High-performance, fully-managed
600MB to 416GB RAM; up to 64 vCPUs
Up to 10 TB storage; 40,000 IOPS
Types:
MySQL
Postgres
SQLServer (2019)
cloud.google.com/sql
Storing Data: Cloud Datastore
Cloud Datastore: a fully-
managed, highly-scalable
NoSQL database for your web
and mobile applications
cloud.google.com/datastore
Storing Data: Firebase
Firebase data is stored
as JSON & synchronized in
real-time to every
connected client; other
tools + FB == v2 mobile
development platform
firebase.google.com
Storing Data: Cloud Firestore
The best of both worlds: the
next generation of Cloud
Datastore (w/product rebrand)
plus features from the
Firebase realtime database
(For choosing between Firebase & Cloud Firestore: see
firebase.google.com/docs/firestore/rtdb-vs-firestore)
cloud.google.com/firestore
Cloud Firestore data model
collections subcollections
Cloud Firestore straightforward querying
github.com/GoogleCloudPlatform/python-docs-samples/blob/master/firestore/cloud-client/snippets.py
BigQuery: querying Shakespeare words
from google.cloud import bigquery
TITLE = "The most common words in all of Shakespeare's works"
QUERY = '''
SELECT LOWER(word) AS word, sum(word_count) AS count
FROM `bigquery-public-data.samples.shakespeare`
GROUP BY word ORDER BY count DESC LIMIT 10
'''
rsp = bigquery.Client().query(QUERY).result()
print('n*** Results for %r:n' % TITLE)
print('t'.join(col.name.upper() for col in rsp.schema)) # HEADERS
print('n'.join('t'.join(str(x) for x in row.values()) for row in rsp)) # DATA
Top 10 most common Shakespeare words
$ python bq_shake.py
*** Results for "The most common words in all of Shakespeare's works":
WORD COUNT
the 29801
and 27529
i 21029
to 20957
of 18514
a 15370
you 14010
my 12936
in 11722
that 11519
● BigQuery public data sets: cloud.google.com/bigquery/public-data
● Other public data sets: cloud.google.com/public-datasets (Google
Cloud) and research.google/tools/datasets (Google Research)
● COVID-19
○ Read the blog post announcement
○ How to use our data sets
○ JHU Coronavirus COVID-19 Global Cases data set
○ List of all COVID-19 data sets
● BigQuery sandbox (1TB/mo): cloud.google.com/bigquery/docs/sandbox
● Cloud Healthcare API: cloud.google.com/healthcare (read blog post)
BigQuery public data sets
GCP machine learning
Bringing AI/ML to developers of all skillsets
ML "building block" APIs
● Gain insights from data using GCP's
pre-trained machine learning models
● Leverage the same technology as Google
Translate, Photos, and Assistant
● Requires ZERO prior knowledge of ML
● If you can call an API, you can use AI/ML!
● cloud.google.com/products/ai/building-blocks
Vision Video
Intelligence
Speech
(S2T & T2S)
Natural
Language
Translation
from google.cloud import vision
image_uri = 'gs://cloud-samples-data/vision/using_curl/shanghai.jpeg'
client = vision.ImageAnnotatorClient()
image = vision.types.Image()
image.source.image_uri = image_uri
response = client.label_detection(image=image)
print('Labels (and confidence score):')
print('=' * 30)
for label in response.label_annotations:
print(f'{label.description} ({label.score*100.:.2f}%)')
Vision: label annotation/object detection
$ python3 label-detect.py
Labels (and confidence score):
==============================
People (95.05%)
Street (89.12%)
Mode of transport (89.09%)
Transport (85.13%)
Vehicle (84.69%)
Snapshot (84.11%)
Urban area (80.29%)
Infrastructure (73.14%)
Road (72.74%)
Pedestrian (68.90%)
Vision: label annotation/object detection
g.co/codelabs/vision-python
Cloud Vision
exercise
g.co/codelabs/vision-
python
(others at gcplab.me)
● What is it, and how does it work?
○ Google Cloud ML APIs use pre-trained models
○ Perhaps those models less suitable for your data
○ Further customize/train our models for your data
○ Without sophisticated ML background
○ Translate, Vision, Natural Language, Video Intelligence, Tables
○ cloud.google.com/automl
● Steps
a. Prep your training data
b. Create dataset
c. Import items into dataset
d. Create/train model
e. Evaluate/validate model
f. Make predictions
Cloud AutoML
Full Spectrum of AI & ML Offerings
App developer Data scientist,
developer
Data scientist, Researcher
(w/infrastructure access &
DevOps/SysAdmin skills)
ML EngineAuto ML
Build custom models,
use OSS SDK on fully-
managed infrastructure
ML APIs
App developer,
data scientist
Use/customize pre-built
models
Use pre-built/pre-
trained models
Build custom models, use/
extend OSS SDK, self-manage
training infrastructure
Google Cloud compute & serverless
4 opinionated logic-hosting containers in the cloud
>
Google Compute Engine configurable
VMs of all shapes & sizes, from
"micro" to 416 vCPUs, 11.75 TB RAM,
64 TB HDD/SSD plus Google Cloud
Storage for blobs/cloud data lake
(Debian, CentOS, CoreOS, SUSE, Red Hat Enterprise Linux,
Ubuntu, FreeBSD; Windows Server 2008 R2, 2012 R2, 2016)
cloud.google.com/compute
cloud.google.com/storage
Yeah, we got VMs & big disk… but why*?
Serverless: what & why
● What is serverless?
○ Misnomer
○ "No worries"
○ Developers focus on writing code & solving business problems*
● Why serverless?
○ Fastest growing segment of cloud... per analyst research*:
■ $1.9B (2016) and $4.25B (2018) ⇒ $7.7B (2021) and $14.93B (2023)
○ What if you go viral? Autoscaling: your new best friend
○ What if you don't? Code not running? You're not paying.
* in USD; source:Forbes (May 2018), MarketsandMarkets™ & CB Insights (Aug 2018)
Why does App Engine exist?
● Focus on app not DevOps
○ Web app
○ Mobile backend
○ Cloud service
● Enhance productivity
● Deploy globally
● Fully-managed
● Auto-scaling
● Pay-per-use
● Familiar languages
Hello World (Python "MVP")
app.yaml
runtime: python37
main.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World!'
requirements.txt
Flask==1.0.2
Deploy:
$ gcloud app deploy
Access globally:
PROJECT_ID.appspot.com
Quickstart tutorial and open source repo at
cloud.google.com/appengine/docs/standard/python3/quickstart
Why does Cloud Functions exist?
● Don't have entire app?
○ No framework "overhead" (LAMP, MEAN...)
○ Deploy microservices
● Event-driven
○ Triggered via HTTP or background events
■ Pub/Sub, Cloud Storage, Firebase, etc.
○ Auto-scaling & highly-available; pay per use
● Flexible development environment
○ Cmd-line or developer console (in-browser)
● Cloud Functions for Firebase
○ Mobile app use-cases
● Available runtimes
○ JS/Node.js 6, 8, 10
○ Python 3.7
○ Go 1.11, 1.12
○ Java 8
main.py
def hello_world(request):
return 'Hello World!'
Deploy:
$ gcloud functions deploy hello --runtime python37 --trigger-http
Access globally (curl):
curl -X POST https://GCP_REGION-PROJECT_ID.cloudfunctions.net/hello 
-H "Content-Type:application/json"
Access globally (browser):
GCP_REGION-PROJECT_ID.cloudfunctions.net/hello
Hello World (Python "MVP")
Quickstart tutorial and open source repo at
cloud.google.com/functions/docs/quickstart-python
Cloud Run
Fully-managed serverless
ContainerizedApps-aaS
No cluster to manage
Pay for what you use
Cloud Run on GKE
Serverless experience
Access custom nodes, GPUs, VPC
Simplicity of Cloud Run
With flexibility of GKE
Fully-managed Kubernetes cluster
Serverless containers, where you want them
Self-managed
Kubernetes cluster
Cloud Run compatible
With Knative open API
Runs on-prem or in other cloud on
Self-managed Kubernetes cluster
cloud.google.com/run
+JavaScript
-API “flavor”
+built-in
“flavor”
-OAuth2 (you)
!=
Google Apps Script
Apps Script overview
goo.gle/2VF8xeC
“Hello World!” in Apps Script
Sheets-bound “Hello World!”
Apps Script intro
goo.gl/1sXeuD
What can you do with this?
Accessing maps from
spreadsheets?!?
goo.gl/oAzBN9
This… with help from Google Maps & Gmail
function sendMap() {
var sheet = SpreadsheetApp.getActiveSheet();
var address = sheet.getRange("A2").getValue();
var map = Maps.newStaticMap().addMarker(address);
GmailApp.sendEmail('friend@example.com', 'Map',
'See below.', {attachments:[map]});
}
JS
Codelab and open source repo at
g.co/codelabs/apps-script-intro
G Suite & other Google APIs
Collaborate and be more productive with G Suite
G Suite: Google Drive
Drive API allows developers to read,
write, control permissions/sharing,
import/export files, and more!
developers.google.com/drive
Try our Node.js customized reporting tool codelab:
g.co/codelabs/sheets
Why use the Sheets API?
data visualization
customized reports
Sheets as a data source
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()
Migrate SQL data
to Sheets
goo.gl/N1RPwC
G Suite: Google Docs & Slides
Docs & Slides APIs give you access
to read or write documents and
presentations programmatically so
you can auto-generate them with data
integrated from various sources
developers.google.com/docs
developers.google.com/slides
● Not just for conversations
● Create microservice utilities
● Build chat bots to...
○ Automate workflows
○ Query for information
○ Other heavy-lifting
● Plain text or rich UI "cards"
● Very flexible ("any")
development environment
○ POST to HTTP port
Hangouts Chat bots
(bot framework & API)
"Hello World" (echo bot)
JavaScript: Google Apps Script
function onMessage(m) {
return {
'text': 'Hi ' + m.sender.displayName + '. You sent: ' + m.text,
'thread': {'name': m.thread.name}
};
}
Hangouts Chat bots
goo.gl/jt3FqK
Other Google APIs & platforms
● Firebase (mobile development platform + RT DB)
○ firebase.google.com
● Google Data Studio (data visualization, dashboards, etc.)
○ datastudio.google.com/overview
○ goo.gle/datastudio-course
● Actions on Google/Assistant/DialogFlow (voice apps)
○ developers.google.com/actions
● YouTube (Data, Analytics, and Livestreaming APIs)
○ developers.google.com/youtube
● Google Maps (Maps, Routes, and Places APIs)
○ developers.google.com/maps
● Flutter (native apps [Android, iOS, web] w/1 code base[!])
○ flutter.dev
04
All of Cloud
(inspiration)
Build powerful solutions
with GCP and G Suite
Custom intelligence in Gmail
Analyze G Suite data with GCP
Gmail message processing with GCP
Gmail
Cloud
Pub/Sub
Cloud
Functions
Cloud
Vision
G Suite GCP
Star
message
Message
notification
Trigger
function
Extract
images
Categorize
images
Inbox augmented with Cloud Function
● Gmail API: sets up notification forwarding to Cloud Pub/Sub
● developers.google.com/gmail/api/guides/push
● Pub/Sub: triggers logic hosted by Cloud Functions
● cloud.google.com/functions/docs/calling/pubsub
● Cloud Functions: "orchestrator" accessing GCP (and G Suite) APIs
● Combine all of the above to add custom intelligence to Gmail
● Deep dive code blog post
● cloud.google.com/blog/products/application-development/
adding-custom-intelligence-to-gmail-with-serverless-on-gcp
● Application source code
● github.com/GoogleCloudPlatform/cloud-functions-gmail-nodejs
App summary
Big data analysis to slide presentation
Access GCP tools from G Suite
Visualize big data results
Supercharge G Suite with GCP
G Suite GCP
BigQuery
Apps Script
Slides Sheets
Application
request
Big data
analytics
App summary
● Leverage GCP and build the "final mile" with G Suite
● Driven by Google Apps Script
● Google BigQuery for data analysis
● Google Sheets for visualization
● Google Slides for presentable results
● "Glued" together w/G Suite serverless
● Build this app (codelab): g.co/codelabs/bigquery-sheets-slides
● Video and blog post: bit.ly/2OcptaG
● Application source code: github.com/googlecodelabs/bigquery-sheets-slides
● Presented at Google Cloud NEXT (Jul 2018 [DEV229] & Apr 2019 [DEV212])
● cloud.withgoogle.com/next18/sf/sessions/session/156878
● cloud.withgoogle.com/next/sf/sessions?session=DEV212
05
Wrap-up
Summary & resources
Session Summary
● Google provides more than just apps
○ You may know Google for search, YouTube, Android, Chrome, and Gmail, but...
○ We've made much of our technology available to developers through our APIs
○ To help prevent all those wheel reinventions!
● Tour of Google APIs & developer tools
○ G Suite: not just a set of productivity apps… you can code them too!
○ GCP: compute, storage, networking, security, data & machine learning tools
○ Google Cloud serverless frees developers from infrastructure
■ 4 unique solutions so you can focus on building solutions
● Interesting possibilities using both Cloud platforms (GCP + G Suite)
● Many other Google developer products
● Documentation
○ GCP: cloud.google.com/{docs,appengine,functions,vision,automl,sql,compute.storage,
language,speech,text-to-speech,translate,video-intelligence,firestore,bigquery,filestore}
○ G Suite: developers.google.com/{gsuite,drive,calendar,gmail,docs,sheets,slides,apps-script}
● Introductory "codelabs" ([free] self-paced, hands-on tutorials)
○ G Suite REST APIs: g.co/codelabs/gsuite-apis-intro (featuring Drive API)
○ Apps Script: g.co/codelabs/apps-script-intro
○ App Engine: codelabs.developers.google.com/codelabs/cloud-app-engine-python
○ Cloud Vision: g.co/codelabs/vision-python (or C# or Ruby)
○ Cloud Functions: codelabs.developers.google.com/codelabs/cloud-starting-cloudfunctions
○ All others: gcplab.me (GCP) and g.co/codelabs (non-GCP)
● Videos: youtube.com/GoogleCloudPlatform (GCP), goo.gl/JpBQ40 (G Suite), and all others
● Code samples: github.com/GoogleCloudPlatform (GCP) and github.com/gsuitedevs (G Suite)
● GCP Free trial (new users) and Always Free (daily/monthly tier) - cloud.google.com/free
Compare with GCP at cloud.google.com/docs/compare/aws
Online resources
Thank you! Questions?
Wesley Chun
@wescpy
Progress bars: goo.gl/69EJVw
Slides: bit.ly/2SHybQg

More Related Content

PDF
Exploring Google APIs with Python
PDF
Introduction to Cloud Computing with Google Cloud
PDF
Easy path to machine learning (Spring 2020)
PDF
Easy path to machine learning (Spring 2021)
PDF
Serverless Computing with Google Cloud
PDF
Serverless Computing with Python
PDF
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
PDF
Run your code serverlessly on Google's open cloud
Exploring Google APIs with Python
Introduction to Cloud Computing with Google Cloud
Easy path to machine learning (Spring 2020)
Easy path to machine learning (Spring 2021)
Serverless Computing with Google Cloud
Serverless Computing with Python
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Run your code serverlessly on Google's open cloud

What's hot (17)

PDF
Image archive, analysis & report generation with Google Cloud
PDF
Powerful Google Cloud tools for your hack
PDF
Using Google (Cloud) APIs
PDF
How Google Cloud Platform can help in the classroom/lab
PDF
Build with ALL of Google Cloud
PDF
Google App Engine Overview and Update
PDF
How to build Kick Ass Games in the Cloud
PDF
Building Integrated Applications on Google's Cloud Technologies
PDF
Building Kick Ass Video Games for the Cloud
PDF
Google's serverless journey: past to present
PDF
TensorFlow on GCP
PDF
Powerful Google Cloud tools for your hack (2020)
PDF
Building Integrated Applications on Google's Cloud Technologies
PDF
Introduction to serverless computing on Google Cloud
PDF
Serving raster layers on Google Cloud Platform
PDF
Cloud Spin - building a photo booth with the Google Cloud Platform
PPT
GAS Session
Image archive, analysis & report generation with Google Cloud
Powerful Google Cloud tools for your hack
Using Google (Cloud) APIs
How Google Cloud Platform can help in the classroom/lab
Build with ALL of Google Cloud
Google App Engine Overview and Update
How to build Kick Ass Games in the Cloud
Building Integrated Applications on Google's Cloud Technologies
Building Kick Ass Video Games for the Cloud
Google's serverless journey: past to present
TensorFlow on GCP
Powerful Google Cloud tools for your hack (2020)
Building Integrated Applications on Google's Cloud Technologies
Introduction to serverless computing on Google Cloud
Serving raster layers on Google Cloud Platform
Cloud Spin - building a photo booth with the Google Cloud Platform
GAS Session
Ad

Similar to Exploring Google (Cloud) APIs with Python & JavaScript (20)

PDF
Powerful Google developer tools for immediate impact! (2023-24 A)
PDF
Cloud computing overview & running your code on Google Cloud
PDF
Powerful Google developer tools for immediate impact! (2023-24 C)
PDF
Easy path to machine learning (2022)
PDF
Serverless computing with Google Cloud
PDF
Exploring Google APIs with Python
PDF
A Tour of Google Cloud Platform
PPT
Google cloud platform
PDF
Google Cloud Platform Update
PDF
Introduction to App Engine Development
PDF
Easy path to machine learning (2023-2024)
PDF
Intro to new Google cloud technologies: Google Storage, Prediction API, BigQuery
PDF
Building Apps on Google Cloud Technologies
PDF
Intro to Google's Cloud Technologies
PDF
Introduction to Google's Cloud Technologies
PDF
Introduction to Google App Engine
PDF
GDD Brazil 2010 - What's new in Google App Engine and Google App Engine For B...
PDF
Quick Intro to Google Cloud Technologies
PDF
Google app-engine-with-python
PPTX
CloudPlatforms-Cloud PLatforms evaluation
Powerful Google developer tools for immediate impact! (2023-24 A)
Cloud computing overview & running your code on Google Cloud
Powerful Google developer tools for immediate impact! (2023-24 C)
Easy path to machine learning (2022)
Serverless computing with Google Cloud
Exploring Google APIs with Python
A Tour of Google Cloud Platform
Google cloud platform
Google Cloud Platform Update
Introduction to App Engine Development
Easy path to machine learning (2023-2024)
Intro to new Google cloud technologies: Google Storage, Prediction API, BigQuery
Building Apps on Google Cloud Technologies
Intro to Google's Cloud Technologies
Introduction to Google's Cloud Technologies
Introduction to Google App Engine
GDD Brazil 2010 - What's new in Google App Engine and Google App Engine For B...
Quick Intro to Google Cloud Technologies
Google app-engine-with-python
CloudPlatforms-Cloud PLatforms evaluation
Ad

More from wesley chun (14)

PDF
From zero to Google APIs: Beyond search & AI... leverage all of Google
PDF
Deploy Basic AI web apps with Serverless Computing from Google Cloud
PDF
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
PDF
Automating Google Workspace (GWS) & more with Apps Script
PDF
Powerful Google developer tools for immediate impact! (2023-24 B)
PDF
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
PDF
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
PDF
Serverless Computing with Python
PDF
Google... more than just a cloud
PDF
Accessing Google Cloud APIs
PDF
Google Cloud @ Hackathons (2020)
PDF
Google Apps Script: Accessing G Suite & other Google services with JavaScript
PDF
Exploring Google (Cloud) APIs & Cloud Computing overview
PDF
Easy path to machine learning
From zero to Google APIs: Beyond search & AI... leverage all of Google
Deploy Basic AI web apps with Serverless Computing from Google Cloud
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Automating Google Workspace (GWS) & more with Apps Script
Powerful Google developer tools for immediate impact! (2023-24 B)
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Serverless Computing with Python
Google... more than just a cloud
Accessing Google Cloud APIs
Google Cloud @ Hackathons (2020)
Google Apps Script: Accessing G Suite & other Google services with JavaScript
Exploring Google (Cloud) APIs & Cloud Computing overview
Easy path to machine learning

Recently uploaded (20)

PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Big Data Technologies - Introduction.pptx
PPT
Teaching material agriculture food technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Machine learning based COVID-19 study performance prediction
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Reach Out and Touch Someone: Haptics and Empathic Computing
Programs and apps: productivity, graphics, security and other tools
Per capita expenditure prediction using model stacking based on satellite ima...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
“AI and Expert System Decision Support & Business Intelligence Systems”
Digital-Transformation-Roadmap-for-Companies.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
sap open course for s4hana steps from ECC to s4
Advanced methodologies resolving dimensionality complications for autism neur...
Big Data Technologies - Introduction.pptx
Teaching material agriculture food technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
Machine learning based COVID-19 study performance prediction
Spectral efficient network and resource selection model in 5G networks
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...

Exploring Google (Cloud) APIs with Python & JavaScript

  • 1. Exploring Google (Cloud) APIs with Python & JavaScript Wesley Chun Developer Advocate, Google Adjunct CS Faculty, Foothill College G Suite Dev Show goo.gl/JpBQ40 About the speaker Developer Advocate, Google Cloud ● Mission: enable current and future developers everywhere to be successful using Google Cloud and other Google developer tools & APIs ● Videos: host of the G Suite Dev Show on YouTube ● Blogs: developers.googleblog.com & gsuite-developers.googleblog.com ● Twitters: @wescpy, @GoogleDevs, @GSuiteDevs Previous experience / background ● Software engineer & architect for 20+ years ● One of the original Yahoo!Mail engineers ● Author of bestselling "Core Python" books (corepython.com) ● Technical trainer, teacher, instructor since 1983 (Computer Science, C, Linux, Python) ● Fellow of the Python Software Foundation ● AB (Math/CS) & CMP (Music/Piano), UC Berkeley and MSCS, UC Santa Barbara ● Adjunct Computer Science Faculty, Foothill College (Silicon Valley)
  • 2. Agenda 1 Introduction 2 Google Cloud (GCP + G Suite) 3 Google APIs 4 Inspiration 5 Wrap-up 01 Introduction to APIs Why are you here?
  • 4. & Google APIs client libraries for many languages; demos in developers.google.com/api- client-library cloud.google.com/apis/docs /cloud-client-libraries 02 Google Cloud
  • 5. Google Compute Engine, Google Cloud Storage AWS EC2 & S3; Rackspace; Joyent SaaS Software as a Service PaaS Platform as a Service IaaS Infrastructure as a Service Google Apps Script Salesforce1/force.com G Suite (Google Apps) Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365 Google App Engine, Cloud Functions Heroku, Cloud Foundry, Engine Yard, AWS Lambda Google BigQuery, Cloud SQL, Cloud Datastore, NL, Vision, Pub/Sub AWS Kinesis, RDS; Windows Azure SQL, Docker Google Cloud Platform vs. G Suite G Suite APIs GCP APIs
  • 6. 03 Google APIs & developer tools (focusing on Cloud) GCP data & storage services Build, innovate, and scale with Google Cloud Platform
  • 7. Storing Data: Cloud SQL SQL servers in the cloud High-performance, fully-managed 600MB to 416GB RAM; up to 64 vCPUs Up to 10 TB storage; 40,000 IOPS Types: MySQL Postgres SQLServer (2019) cloud.google.com/sql Storing Data: Cloud Datastore Cloud Datastore: a fully- managed, highly-scalable NoSQL database for your web and mobile applications cloud.google.com/datastore
  • 8. Storing Data: Firebase Firebase data is stored as JSON & synchronized in real-time to every connected client; other tools + FB == v2 mobile development platform firebase.google.com Storing Data: Cloud Firestore The best of both worlds: the next generation of Cloud Datastore (w/product rebrand) plus features from the Firebase realtime database (For choosing between Firebase & Cloud Firestore: see firebase.google.com/docs/firestore/rtdb-vs-firestore) cloud.google.com/firestore
  • 9. Cloud Firestore data model collections subcollections Cloud Firestore straightforward querying github.com/GoogleCloudPlatform/python-docs-samples/blob/master/firestore/cloud-client/snippets.py
  • 10. BigQuery: querying Shakespeare words from google.cloud import bigquery TITLE = "The most common words in all of Shakespeare's works" QUERY = ''' SELECT LOWER(word) AS word, sum(word_count) AS count FROM `bigquery-public-data.samples.shakespeare` GROUP BY word ORDER BY count DESC LIMIT 10 ''' rsp = bigquery.Client().query(QUERY).result() print('n*** Results for %r:n' % TITLE) print('t'.join(col.name.upper() for col in rsp.schema)) # HEADERS print('n'.join('t'.join(str(x) for x in row.values()) for row in rsp)) # DATA Top 10 most common Shakespeare words $ python bq_shake.py *** Results for "The most common words in all of Shakespeare's works": WORD COUNT the 29801 and 27529 i 21029 to 20957 of 18514 a 15370 you 14010 my 12936 in 11722 that 11519
  • 11. ● BigQuery public data sets: cloud.google.com/bigquery/public-data ● Other public data sets: cloud.google.com/public-datasets (Google Cloud) and research.google/tools/datasets (Google Research) ● COVID-19 ○ Read the blog post announcement ○ How to use our data sets ○ JHU Coronavirus COVID-19 Global Cases data set ○ List of all COVID-19 data sets ● BigQuery sandbox (1TB/mo): cloud.google.com/bigquery/docs/sandbox ● Cloud Healthcare API: cloud.google.com/healthcare (read blog post) BigQuery public data sets GCP machine learning Bringing AI/ML to developers of all skillsets
  • 12. ML "building block" APIs ● Gain insights from data using GCP's pre-trained machine learning models ● Leverage the same technology as Google Translate, Photos, and Assistant ● Requires ZERO prior knowledge of ML ● If you can call an API, you can use AI/ML! ● cloud.google.com/products/ai/building-blocks Vision Video Intelligence Speech (S2T & T2S) Natural Language Translation from google.cloud import vision image_uri = 'gs://cloud-samples-data/vision/using_curl/shanghai.jpeg' client = vision.ImageAnnotatorClient() image = vision.types.Image() image.source.image_uri = image_uri response = client.label_detection(image=image) print('Labels (and confidence score):') print('=' * 30) for label in response.label_annotations: print(f'{label.description} ({label.score*100.:.2f}%)') Vision: label annotation/object detection
  • 13. $ python3 label-detect.py Labels (and confidence score): ============================== People (95.05%) Street (89.12%) Mode of transport (89.09%) Transport (85.13%) Vehicle (84.69%) Snapshot (84.11%) Urban area (80.29%) Infrastructure (73.14%) Road (72.74%) Pedestrian (68.90%) Vision: label annotation/object detection g.co/codelabs/vision-python Cloud Vision exercise g.co/codelabs/vision- python (others at gcplab.me)
  • 14. ● What is it, and how does it work? ○ Google Cloud ML APIs use pre-trained models ○ Perhaps those models less suitable for your data ○ Further customize/train our models for your data ○ Without sophisticated ML background ○ Translate, Vision, Natural Language, Video Intelligence, Tables ○ cloud.google.com/automl ● Steps a. Prep your training data b. Create dataset c. Import items into dataset d. Create/train model e. Evaluate/validate model f. Make predictions Cloud AutoML Full Spectrum of AI & ML Offerings App developer Data scientist, developer Data scientist, Researcher (w/infrastructure access & DevOps/SysAdmin skills) ML EngineAuto ML Build custom models, use OSS SDK on fully- managed infrastructure ML APIs App developer, data scientist Use/customize pre-built models Use pre-built/pre- trained models Build custom models, use/ extend OSS SDK, self-manage training infrastructure
  • 15. Google Cloud compute & serverless 4 opinionated logic-hosting containers in the cloud > Google Compute Engine configurable VMs of all shapes & sizes, from "micro" to 416 vCPUs, 11.75 TB RAM, 64 TB HDD/SSD plus Google Cloud Storage for blobs/cloud data lake (Debian, CentOS, CoreOS, SUSE, Red Hat Enterprise Linux, Ubuntu, FreeBSD; Windows Server 2008 R2, 2012 R2, 2016) cloud.google.com/compute cloud.google.com/storage Yeah, we got VMs & big disk… but why*?
  • 16. Serverless: what & why ● What is serverless? ○ Misnomer ○ "No worries" ○ Developers focus on writing code & solving business problems* ● Why serverless? ○ Fastest growing segment of cloud... per analyst research*: ■ $1.9B (2016) and $4.25B (2018) ⇒ $7.7B (2021) and $14.93B (2023) ○ What if you go viral? Autoscaling: your new best friend ○ What if you don't? Code not running? You're not paying. * in USD; source:Forbes (May 2018), MarketsandMarkets™ & CB Insights (Aug 2018) Why does App Engine exist? ● Focus on app not DevOps ○ Web app ○ Mobile backend ○ Cloud service ● Enhance productivity ● Deploy globally ● Fully-managed ● Auto-scaling ● Pay-per-use ● Familiar languages
  • 17. Hello World (Python "MVP") app.yaml runtime: python37 main.py from flask import Flask app = Flask(__name__) @app.route('/') def hello(): return 'Hello World!' requirements.txt Flask==1.0.2 Deploy: $ gcloud app deploy Access globally: PROJECT_ID.appspot.com Quickstart tutorial and open source repo at cloud.google.com/appengine/docs/standard/python3/quickstart Why does Cloud Functions exist? ● Don't have entire app? ○ No framework "overhead" (LAMP, MEAN...) ○ Deploy microservices ● Event-driven ○ Triggered via HTTP or background events ■ Pub/Sub, Cloud Storage, Firebase, etc. ○ Auto-scaling & highly-available; pay per use ● Flexible development environment ○ Cmd-line or developer console (in-browser) ● Cloud Functions for Firebase ○ Mobile app use-cases ● Available runtimes ○ JS/Node.js 6, 8, 10 ○ Python 3.7 ○ Go 1.11, 1.12 ○ Java 8
  • 18. main.py def hello_world(request): return 'Hello World!' Deploy: $ gcloud functions deploy hello --runtime python37 --trigger-http Access globally (curl): curl -X POST https://GCP_REGION-PROJECT_ID.cloudfunctions.net/hello -H "Content-Type:application/json" Access globally (browser): GCP_REGION-PROJECT_ID.cloudfunctions.net/hello Hello World (Python "MVP") Quickstart tutorial and open source repo at cloud.google.com/functions/docs/quickstart-python Cloud Run Fully-managed serverless ContainerizedApps-aaS No cluster to manage Pay for what you use Cloud Run on GKE Serverless experience Access custom nodes, GPUs, VPC Simplicity of Cloud Run With flexibility of GKE Fully-managed Kubernetes cluster Serverless containers, where you want them Self-managed Kubernetes cluster Cloud Run compatible With Knative open API Runs on-prem or in other cloud on Self-managed Kubernetes cluster cloud.google.com/run
  • 19. +JavaScript -API “flavor” +built-in “flavor” -OAuth2 (you) != Google Apps Script Apps Script overview goo.gle/2VF8xeC “Hello World!” in Apps Script
  • 20. Sheets-bound “Hello World!” Apps Script intro goo.gl/1sXeuD What can you do with this?
  • 21. Accessing maps from spreadsheets?!? goo.gl/oAzBN9 This… with help from Google Maps & Gmail function sendMap() { var sheet = SpreadsheetApp.getActiveSheet(); var address = sheet.getRange("A2").getValue(); var map = Maps.newStaticMap().addMarker(address); GmailApp.sendEmail('friend@example.com', 'Map', 'See below.', {attachments:[map]}); } JS Codelab and open source repo at g.co/codelabs/apps-script-intro
  • 22. G Suite & other Google APIs Collaborate and be more productive with G Suite G Suite: Google Drive Drive API allows developers to read, write, control permissions/sharing, import/export files, and more! developers.google.com/drive
  • 23. Try our Node.js customized reporting tool codelab: g.co/codelabs/sheets Why use the Sheets API? data visualization customized reports Sheets as a data source 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() Migrate SQL data to Sheets goo.gl/N1RPwC
  • 24. G Suite: Google Docs & Slides Docs & Slides APIs give you access to read or write documents and presentations programmatically so you can auto-generate them with data integrated from various sources developers.google.com/docs developers.google.com/slides ● Not just for conversations ● Create microservice utilities ● Build chat bots to... ○ Automate workflows ○ Query for information ○ Other heavy-lifting ● Plain text or rich UI "cards" ● Very flexible ("any") development environment ○ POST to HTTP port Hangouts Chat bots (bot framework & API)
  • 25. "Hello World" (echo bot) JavaScript: Google Apps Script function onMessage(m) { return { 'text': 'Hi ' + m.sender.displayName + '. You sent: ' + m.text, 'thread': {'name': m.thread.name} }; } Hangouts Chat bots goo.gl/jt3FqK Other Google APIs & platforms ● Firebase (mobile development platform + RT DB) ○ firebase.google.com ● Google Data Studio (data visualization, dashboards, etc.) ○ datastudio.google.com/overview ○ goo.gle/datastudio-course ● Actions on Google/Assistant/DialogFlow (voice apps) ○ developers.google.com/actions ● YouTube (Data, Analytics, and Livestreaming APIs) ○ developers.google.com/youtube ● Google Maps (Maps, Routes, and Places APIs) ○ developers.google.com/maps ● Flutter (native apps [Android, iOS, web] w/1 code base[!]) ○ flutter.dev
  • 26. 04 All of Cloud (inspiration) Build powerful solutions with GCP and G Suite Custom intelligence in Gmail Analyze G Suite data with GCP
  • 27. Gmail message processing with GCP Gmail Cloud Pub/Sub Cloud Functions Cloud Vision G Suite GCP Star message Message notification Trigger function Extract images Categorize images
  • 28. Inbox augmented with Cloud Function ● Gmail API: sets up notification forwarding to Cloud Pub/Sub ● developers.google.com/gmail/api/guides/push ● Pub/Sub: triggers logic hosted by Cloud Functions ● cloud.google.com/functions/docs/calling/pubsub ● Cloud Functions: "orchestrator" accessing GCP (and G Suite) APIs ● Combine all of the above to add custom intelligence to Gmail ● Deep dive code blog post ● cloud.google.com/blog/products/application-development/ adding-custom-intelligence-to-gmail-with-serverless-on-gcp ● Application source code ● github.com/GoogleCloudPlatform/cloud-functions-gmail-nodejs App summary
  • 29. Big data analysis to slide presentation Access GCP tools from G Suite
  • 31. Supercharge G Suite with GCP G Suite GCP BigQuery Apps Script Slides Sheets Application request Big data analytics App summary ● Leverage GCP and build the "final mile" with G Suite ● Driven by Google Apps Script ● Google BigQuery for data analysis ● Google Sheets for visualization ● Google Slides for presentable results ● "Glued" together w/G Suite serverless ● Build this app (codelab): g.co/codelabs/bigquery-sheets-slides ● Video and blog post: bit.ly/2OcptaG ● Application source code: github.com/googlecodelabs/bigquery-sheets-slides ● Presented at Google Cloud NEXT (Jul 2018 [DEV229] & Apr 2019 [DEV212]) ● cloud.withgoogle.com/next18/sf/sessions/session/156878 ● cloud.withgoogle.com/next/sf/sessions?session=DEV212
  • 32. 05 Wrap-up Summary & resources Session Summary ● Google provides more than just apps ○ You may know Google for search, YouTube, Android, Chrome, and Gmail, but... ○ We've made much of our technology available to developers through our APIs ○ To help prevent all those wheel reinventions! ● Tour of Google APIs & developer tools ○ G Suite: not just a set of productivity apps… you can code them too! ○ GCP: compute, storage, networking, security, data & machine learning tools ○ Google Cloud serverless frees developers from infrastructure ■ 4 unique solutions so you can focus on building solutions ● Interesting possibilities using both Cloud platforms (GCP + G Suite) ● Many other Google developer products
  • 33. ● Documentation ○ GCP: cloud.google.com/{docs,appengine,functions,vision,automl,sql,compute.storage, language,speech,text-to-speech,translate,video-intelligence,firestore,bigquery,filestore} ○ G Suite: developers.google.com/{gsuite,drive,calendar,gmail,docs,sheets,slides,apps-script} ● Introductory "codelabs" ([free] self-paced, hands-on tutorials) ○ G Suite REST APIs: g.co/codelabs/gsuite-apis-intro (featuring Drive API) ○ Apps Script: g.co/codelabs/apps-script-intro ○ App Engine: codelabs.developers.google.com/codelabs/cloud-app-engine-python ○ Cloud Vision: g.co/codelabs/vision-python (or C# or Ruby) ○ Cloud Functions: codelabs.developers.google.com/codelabs/cloud-starting-cloudfunctions ○ All others: gcplab.me (GCP) and g.co/codelabs (non-GCP) ● Videos: youtube.com/GoogleCloudPlatform (GCP), goo.gl/JpBQ40 (G Suite), and all others ● Code samples: github.com/GoogleCloudPlatform (GCP) and github.com/gsuitedevs (G Suite) ● GCP Free trial (new users) and Always Free (daily/monthly tier) - cloud.google.com/free Compare with GCP at cloud.google.com/docs/compare/aws Online resources Thank you! Questions? Wesley Chun @wescpy Progress bars: goo.gl/69EJVw Slides: bit.ly/2SHybQg