/google

Google developer code samples (mainly Python or Node.js)

Primary LanguageJavaScriptApache License 2.0Apache-2.0

Google developer code samples

Introduction

This repo contains developer code samples from the Coding #Python and #Google with @wescpy blog as well as older but still relevant content such as posts from the old G Suite blog as well as my old Python and Google API blog.

Content structure

Samples demonstrating only one product group are prefixed under the product group name (see table below) while cross-product samples will go into multi.

Directory API families
apps Google Workspace ("GWS"; formerly G Suite and Google Apps)
cloud Google Cloud (Platform; "GCP")
gemini Gemini API
maps Google Maps (Platform; "GMP")
youtube YouTube
multi (multi-product sample apps) [N/A at this time]
Code sample categories

Initial samples

The chart below identifies the current samples available:

App Sample Blog post
apps/export-doc-pdf Export Google Docs as PDF Google Docs as PDF
apps/sheets_display.py Display contents of public Sheet API keys 2
apps/drive_list.py (other repo) Display first 100 files/folders in Google Drive (Python old auth) OAuth client ID 3
apps/drive_list-new.py (other repo) Display first 100 files/folders in Google Drive (Python new auth) OAuth client ID 3
apps/drive_list.js (other repo) Display first 100 files/folders in Google Drive (Node.js CommonJS [require]) OAuth client ID 3
apps/drive_list.mjs (other repo) Display first 100 files/folders in Google Drive (Node.js ES Module [import]) OAuth client ID 3
     
cloud/language/nlp_sent_query.py Sentiment analysis of text using Natural Language API w/lower-level platform Google APIs client library API keys 2
cloud/language/nlp_sent_query-gcp.py Sentiment analysis of text using Natural Language API w/higher-level product GCP client library API keys 2
cloud/appengine/nodejs Node.js App Engine "Hello World!" Exploring GAE (TBD)
cloud/appengine/python3 Python 3 App Engine "Hello World!" Exploring GAE (TBD)
cloud/transnatlang/transnatlang-svcacct-gcp.py Python ADC sample Text-based language processing
cloud/transnatlang/transnatlang-svcacct-gcp.js Node.js/CommonJS sample Text-based language processing
cloud/transnatlang/transnatlang-svcacct-gcp.mjs Node.js/ECMAscript module Text-based language processing
cloud/transnatlang/transnatlang-apikey-old.py Python API key sample Text-based language processing
     
gemini/gemtxt-simple-gai.py Google AI Gemini Pro 1.0 API Python sample Gemini API "Hello World!"
gemini/gemtxt-simple-gai.js Google AI Gemini Pro 1.0 API (CommonJS) Node.js sample Gemini API "Hello World!"
gemini/gemtxt-simple-gai.mjs Google AI Gemini Pro 1.0 API (modern JS/ECMAScript module) Node.js sample Gemini API "Hello World!"
gemini/gemtxt-simple-gcp.py GCP Vertex AI Gemini Pro 1.0 API Python sample Gemini API "Hello World!"
gemini/gemtxt-simple10-gai.py Google AI Gemini 1.0 Pro Latest Gemini 102: Beyond "Hello World!"
gemini/gemtxt-stream10-gai.py Google AI Gemini 1.0 Pro Latest Gemini 102: Beyond "Hello World!"
gemini/gemtxt-simple10-chat-gai.py Google AI Gemini 1.0 Pro Latest Gemini 102: Beyond "Hello World!"
gemini/gemmmd-simple10loc-gai.py Google AI Gemini 1.0 Pro Vision Latest Gemini 102: Beyond "Hello World!"
gemini/gemmmd-simple10url-gai.py Google AI Gemini 1.0 Pro Vision Latest Gemini 102: Beyond "Hello World!"
gemini/webgem/ Google AI Gemini 1.5 Flash web apps (Node.js & Python) Gemini 102a: Creating basic gen AI web apps
     
maps/maps_geocode.py Geolocate address with Maps Geocoding API API keys 2 and Explore the world with Maps APIs
maps/maps_geocode.js Geolocate address with Maps Geocoding API (CommonJS) Node.js Explore the world with Maps APIs
maps/maps_geocode.mjs Geolocate address with Maps Geocoding API (modern JS/ECMAScript module) Node.js Explore the world with Maps APIs
maps/maps_tzone.py Geolocate address & get time zone with Maps Geocoding & Time Zone APIs (Python) Explore the world with Maps APIs
maps/maps_wlkdir.py Walking directions with Maps Directions API Explore the world with Maps APIs
youtube/yt_video_query.py Query for (public) YouTube videos (Python) API keys 2
youtube/yt_video_query.js Query for (public) YouTube videos (CommonJS/Node.js) API keys 2
Code sample table of contents

Support

"Support" will be provided in a "best-effort" manner. Open to fixes and updates to existing samples and affected blog posts. File a "bug" against an existing sample with details. If there is a "missing" sample you are proposing that doesn't exist (whether you write the code and submit the PR or are requesting someone do it), also file a bug and state why it would benefit the community. Currently, only (server-side) Python and JavaScript (Node.js, Apps Script) samples are being considered.