Google API Client Library for Python
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
- deprecated The google-api-python-client library is in maintenance mode and will not add new features. For new development, consider using Cloud Client Libraries for Python.
- gotcha Ensure that the 'build' function is imported from 'googleapiclient.discovery' to avoid ImportError.
Install
-
pip install google-api-python-client
Imports
- build
from googleapiclient.discovery import build
Quickstart
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']})')