Skip to main content

help python developper to use some of the Google Drive API v3 easily

Project description

google_api_v3_helper- Automate your google drive process easily

Detailed usage documentation is still in progress The objective of this package is to help python developper to use some of the Google Drive API v3 easily. As of now, 5 functions are available. This package is embedding very nicely with Google API libraries.

This is how you can install it on your machine:

pip install google_api_v3_helper

All of the functionnalities of google_api_helper require you to build the the service class using google ServiceAccountCredentials. For instance, you can use the ServiceAccountCredentials from json keyfile name as such:

from googleapiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials

def get_service():
    scopes = ['https://www.googleapis.com/auth/drive'
              , 'https://www.googleapis.com/auth/drive.file']

    key_file_location = 'pathtokeyfile.json'

    creds = ServiceAccountCredentials.from_json_keyfile_name(key_file_location, scopes=scopes)

    service = build('drive', 'v3', credentials=creds)
    print('connection OK')
    return service

service = get_service()

Once set, you can use our library and get, for instance, the folder tree of a specific file as such:

from google_api_v3_helper import find_google_fileid_tree
fileId = 'XXXXXXXXXXX' #id of the file you wish to get the folder tree for.
tree = find_google_fileid_tree(service, fileId)

List of the functions available [last update: 5/14/2020]:

get_google_folder_id(service, folder_name)

Get folder id of a folder in Google Drive

Arguments: service: in order to use any of this library, the user needs to first build the service class using google ServiceAccountCredentials. folder_name: name of the folder you wish to get the ID of.

get_google_folders_in_folder(service, folder_id)

Get a list of folders in a folder in Google Drive

Arguments: service: in order to use any of this library, the user needs to first build the service class using google ServiceAccountCredentials. folder_id: id of the folder you wish to get the folders list of.

get_google_files_in_folder(service, folder_id)

Get a list of files and folders in a folder in Google Drive

Arguments: service: in order to use any of this library, the user needs to first build the service class using google ServiceAccountCredentials. folder_id: id of the folder you wish to get the folders list of.

uplaod_google_file(service, MediaFileUpload, parent_id, file_name)

Upload a file in a folder in Google Drive

Arguments: service: in order to use any of this library, the user needs to first build the service class using google ServiceAccountCredentials. MediaFileUpload: function of oauth2client.service_account. see www.pypi.com for a full example. parent_id: id of the folder you wish to get the folders list of. file_name: local path to the file. If the file is in the same folder as your script, then you should only enter here the name of your file.

find_google_fileid_tree(service, fileId)

Find the folder tree of a file

Arguments: service: in order to use any of this library, the user needs to first build the service class using google ServiceAccountCredentials. fileId: id of the file you wish to get the tree for.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_api_v3_helper-0.5.dev0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_api_v3_helper-0.5.dev0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file google_api_v3_helper-0.5.dev0.tar.gz.

File metadata

  • Download URL: google_api_v3_helper-0.5.dev0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

File hashes

Hashes for google_api_v3_helper-0.5.dev0.tar.gz
Algorithm Hash digest
SHA256 b317106b4198e039bfb5f1ce8c8e3d7690bd44ccda3d43471fc8d18e4789e752
MD5 6c31a76437c0a602d1d6c4a6162ff0b0
BLAKE2b-256 ccdd33ab5804c1966e04d73918ba3ff21c6887accfcea62b4e463ea24bfbcd70

See more details on using hashes here.

File details

Details for the file google_api_v3_helper-0.5.dev0-py3-none-any.whl.

File metadata

  • Download URL: google_api_v3_helper-0.5.dev0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

File hashes

Hashes for google_api_v3_helper-0.5.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 37e9d931436e409c99a1105c1ad999988903417287fd943054040c9f13d9d94b
MD5 a19a968079eebaa633484a5da06ea4b1
BLAKE2b-256 72098fe8af4ca333bfd00e3916a723a7c43be03d4710ad48c932e168457d4e31

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page