Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 15, 2026·3 min de lecture

google-api-python-client — Official Python Client for Google APIs

The official Python client library for Google's discovery-based APIs, supporting Gmail, Drive, Sheets, Calendar, YouTube, and hundreds more Google services.

Prêt pour agents

Staging sûr pour cet actif

Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.

Stage only · 29/100Policy : staging
Surface agent
Tout agent MCP/CLI
Type
CLI Tool
Installation
Single
Confiance
Confiance : Established
Point d'entrée
google-api-python-client Overview
Commande de staging sûr
npx -y tokrepo@latest install 5d4d23f4-808e-11f1-9bc6-00163e2b0d79 --target codex

Stage les fichiers d'abord; l'activation exige la revue du README et du plan staged.

Introduction

google-api-python-client is Google's official Python library for accessing discovery-based Google APIs. Rather than shipping a separate SDK for each of Google's hundreds of services, it dynamically constructs API client objects from service discovery documents, giving you typed access to Gmail, Google Drive, Sheets, Calendar, YouTube Data, and more through a single library.

What google-api-python-client Does

  • Dynamically builds Python client objects for any Google API using service discovery
  • Handles OAuth 2.0 and service account authentication via the google-auth companion library
  • Supports batch requests to combine multiple API calls into a single HTTP request
  • Manages media upload and download with resumable transfer support
  • Provides automatic retry and exponential backoff for transient errors

Architecture Overview

The library revolves around the build() function, which fetches a JSON discovery document describing an API's endpoints, parameters, and schemas. From this document, it dynamically creates a Resource object with methods matching each API endpoint. Authentication is plugged in via google-auth credentials objects. HTTP transport uses httplib2 or the requests library. Media operations support chunked, resumable uploads for large files.

Self-Hosting & Configuration

  • Requires Python 3.7 or newer
  • Install core library: pip install google-api-python-client
  • Install auth helpers: pip install google-auth-oauthlib google-auth-httplib2
  • Create a project in Google Cloud Console, enable the desired APIs, and download credentials
  • Use OAuth 2.0 for user-facing apps or service accounts for server-to-server access

Key Features

  • Single library covers hundreds of Google APIs (Drive, Gmail, Sheets, Calendar, BigQuery, YouTube, etc.)
  • Discovery-based design means new API features work without library updates
  • Resumable media uploads for files of any size
  • Batch request support to reduce HTTP round trips
  • Compatible with both synchronous and async workflows

Comparison with Similar Tools

  • google-cloud-python — Handwritten client libraries for specific GCP services (Storage, BigQuery); google-api-python-client covers a broader range of consumer and workspace APIs
  • gspread — Specialized Google Sheets library with a simpler API; google-api-python-client is more general
  • PyDrive2 — Wrapper around google-api-python-client focused on Drive operations
  • googleapis/google-api-go-client — Go equivalent with the same discovery-based architecture

FAQ

Q: Which Google APIs does this library support? A: Any API that publishes a discovery document, which includes Gmail, Drive, Sheets, Calendar, YouTube, Cloud services, and many more.

Q: How do I authenticate? A: Use google-auth for OAuth 2.0 flows (desktop, web, service account) and pass the credentials object to the build() function.

Q: Can I use this for Google Cloud services like BigQuery? A: Yes, though Google recommends their dedicated cloud client libraries (google-cloud-bigquery) for GCP services, as those offer better ergonomics.

Q: What license is it under? A: Apache License 2.0.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires