Skip to main content

A simple OO wrapper around Google's python API client

Project description

Google Objects

Thin, pythonic OO wrapper around Google's "google-api-python-client" library. Currently supports Python 3+


$ pip install google-objects


Requires a valid Google API Credentials object from Google's excellent oauth2lib library. For more information, visit here.

Google Drive v3

  • Retrieve drive 'About' information:
from google_objects import DriveClient

gdrive = DriveClient(OAUTH2LIB_CREDS)
about = gdrive.get_about()


# prints link to profile photo

# ...
  • List files in drive by type:
files_by_type = {
    'slides': gdrive.list_files('presentation'),
    'folders': gdrive.list_files('folder'),
    'spreadsheets': gdrive.list_files('spreadsheets'),

for file in files_by_type['folders']:

for file in files_by_type['spreadsheets']:
    # prints list of parent folder IDs

# ...
  • Copy and share file:
file = gdrive.get_file('FILE_ID')
new_file = file.copy('NEW_FILE_NAME', ['PARENT_FOLDER_1', 'PARENT_FOLDER_2'])

# allow to view
permission = new_file.add_permission('')

# print newly created permission information
print(permission.role, permission.type,

Google Slides v1

  • Retrieve presentation and loop through elements:
from google_objects import SlidesClient

gslides = SlidesClient(OAUTHLIB_CREDS)
presentation = gslides.get_presentation('PRESENTATION_ID')

# print slides attributes
for slide in presentation:

    for element in slide: # equivalent to 'for element in presentation.elements()'  
        # Shape, Table, etc
  • Check text in shape:
shape = presentation.get_element_by_id('SHAPE_ID')
for segment in shape.text:
  • Batch update every cell in table:
# use with to perform batch updates in block
with presentation as pres:
    table = pres.get_element_by_id('TABLE_ID')
    for cell in table:
        print(cell.location) # tuple containing cell location
        for segment in cell.text:
            # update cell
            segment.text = 'UPDATED_VALUE'

Google Sheets v4

  • Retrieve spreadsheet and loop through sheets:
from google_objects import SheetsClient

gsheets = SheetsClient(OAUTHLIB_CREDS)
spreadsheet = gsheets.get_spreadsheet('SPREADSHEET_ID')

for sheet in spreadsheet:
    print(, sheet.title)
  • Get sheet by name and return its full block of values:
sheet = spreadsheet['Sheet 1']
values = sheet.values() 
  • Get named range value block:
named_ranges = spreadsheet.named_ranges('SHEET_NAME!A:C')
for rng in named_range:
    values = named_range.get_block()
  • Update values block:
values = spreadsheet.get_range('SHEET_NAME!A:C')
# loop through rows
for i, row in enumerate(values):
    values[i] = [1, 2, 3]

# you can also use the slice syntax for updating..
values[2:5] = [[1,2,4], [4, 5, 6], [6, 7, 8]]
  • Append to values block:
to_append = [[1, 2, 3], [4, 5, 6]]

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for google_objects, version 0.0.7
Filename, size File type Python version Upload date Hashes
Filename, size google_objects-0.0.7.tar.gz (16.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page