Skip to main content

PyDrive

PyDrive is a wrapper library of google-api-python-client that simplifies many common Google Drive API tasks.

Project Info

Features of PyDrive

  • Simplifies OAuth2.0 into just few lines with flexible settings.

  • Wraps Google Drive API into classes of each resource to make your program more object-oriented.

  • Helps common operations else than API calls, such as content fetching and pagination control.

How to install

You can install PyDrive with regular pip command.

$ pip install PyDrive

OAuth made easy

Download client_secrets.json from Google API Console and OAuth2.0 is done in two lines. You can customize behavior of OAuth2 in one settings file settings.yaml.

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

gauth = GoogleAuth()
gauth.LocalWebserverAuth()

drive = GoogleDrive(gauth)

File management made easy

Upload/update the file with one method. PyDrive will do it in the most efficient way.

file1 = drive.CreateFile({'title': 'Hello.txt'})
file1.SetContentString('Hello')
file1.Upload() # Files.insert()

file1['title'] = 'HelloWorld.txt'  # Change title of the file
file1.Upload() # Files.patch()

content = file1.GetContentString()  # 'Hello'
file1.SetContentString(content+' World!')  # 'Hello World!'
file1.Upload() # Files.update()

file2 = drive.CreateFile()
file2.SetContentFile('hello.png')
file2.Upload()
print 'Created file %s with mimeType %s' % (file2['title'], file2['mimeType'])
# Created file hello.png with mimeType image/png

file3 = drive.CreateFile({'id': file2['id']})
print 'Downloading file %s from Google Drive' % file3['title'] # 'hello.png'
file3.GetContentFile('world.png')  # Save Drive file as a local file

File listing pagination made easy

PyDrive handles file listing pagination for you.

# Auto-iterate through all files that matches this query
file_list = drive.ListFile({'q': "'root' in parents"}).GetList()
for file1 in file_list:
  print 'title: %s, id: %s' % (file1['title'], file1['id'])

# Paginate file lists by specifying number of max results
for file_list in drive.ListFile({'maxResults': 10}):
  print 'Received %s files from Files.list()' % len(file_list) # <= 10
  for file1 in file_list:
    print 'title: %s, id: %s' % (file1['title'], file1['id'])

Metadata

Release files for PyDrive 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyDrive 1.0.0
File Size Uploaded Provenance Actions
PyDrive-1.0.0.tar.gz 155.1 kB Without provenance Details for PyDrive-1.0.0.tar.gz

Release files / PyDrive-1.0.0.tar.gz

Download URL PyDrive-1.0.0.tar.gz
Size 155.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a593a4227f4b37644db6d34c08a504a8fdda737f7854a7e24b739d5cb92172c0
BLAKE2b-256 checksum
How to use checksums
61e1b5242f7219d6db1f52025e686b9f4d625d584ab012e42e2a38fbb58c515f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for PyDrive 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page