Google API Client Library for Python

2.193.0 · maintenance · verified Sat Mar 28

A Python client library for Google's discovery-based APIs, currently at version 2.193.0, with weekly releases. Note: This library is in maintenance mode; for new development, consider using Cloud Client Libraries for Python.

Warnings

Install

Imports

Quickstart

Quickstart example to list files from Google Drive using the API client.

import os
from googleapiclient.discovery import build

# Set up the API client
service = build('drive', 'v3', developerKey=os.environ.get('API_KEY'))

# Call the API
results = service.files().list(pageSize=10, fields='files(id, name)').execute()
items = results.get('files', [])

if not items:
    print('No files found.')
else:
    print('Files:')
    for item in items:
        print(f'{item['name']} ({item['id']})')

view raw JSON →