5

I have been searching for google drive api documentation but have not been able to find a good one. Where can I find the details of its modules and functions to upload, download, get the list of files, etc. ??

2 Answers 2

3

Here is documentation: https://developers.google.com/drive/v3/web/about-sdk But I think you've already found it. There are 3 api's:

  1. For Android
  2. For IOS
  3. HTTP(For everything else)

If you are programming some PC software you shold use HTTP Rest API. You will send http requests to google server instead of calling functions or modules. Here's samples for python

Also there is library for python to use http api

Sign up to request clarification or add additional context in comments.

Comments

2

The Drive API allows you to upload certain types of binary data, or media. The specific characteristics of the data you can upload are specified on the reference page for any method that supports media uploads:

  • Maximum upload file size: The maximum amount of data you can store with this method.
  • Accepted media MIME types: The types of binary data you can store using this method.

You can make upload requests in any of the following ways. Specify the method you are using with the uploadType request parameters - Simple Upload, Multipart upload and Resumable upload.

When creating a file in Google Drive, you can convert some types file into a Google Docs, Sheets or Slides document by specifying the mimeType property of the file. The following sample shows how to upload a CSV file as a spreadsheet:

file_metadata = {
  'name' : 'My Report',
  'mimeType' : 'application/vnd.google-apps.spreadsheet'
}
media = MediaFileUpload('files/report.csv',
                        mimetype='text/csv',
                        resumable=True)
file = drive_service.files().create(body=file_metadata,
                                    media_body=media,
                                    fields='id').execute()
print 'File ID: %s' % file.get('id')

For downloading files, the API allows you to download files that are stored in Google Drive. Also, you can download exported versions of Google Documents (Documents, Spreadsheets, Presentations, etc.) in formats that your app can handle. Drive also supports providing users direct access to a file via the URL in the webViewLink property.

To download files, you make an authorized HTTP GET request to the file's resource URL and include the query parameter alt=media. For example:

GET https://www.googleapis.com/drive/v3/files/0B9jNhSvVjoIVM3dKcGRKRmVIOVU?alt=media
Authorization: Bearer ya29.AHESVbXTUv5mHMo3RYfmS1YJonjzzdTOFZwvyOAUVhrs

Here is an example of performing a file download with our Drive API client libraries.

file_id = '0BwwA4oUTeiV1UVNwOHItT0xfa2M'
request = drive_service.files().get_media(fileId=file_id)
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
    status, done = downloader.next_chunk()
    print "Download %d%%." % int(status.progress() * 100)

Here is a Python Quickstart - simple Python command-line application that makes requests to the Drive API.

1 Comment

To enable the API, do you need to create a project on GCP? I had to shutdown my projects on GCP because of some billings problems, and I don't really want to create a project on GCP. However, this link (below) makes it seem like I need to go through GCP as when I click "ENABLE THE API" I am led to create a project on GCP developers.google.com/drive/api/v3/quickstart/python

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.