Skip to content

Getting Started

After you installed this package and get the Google credentials file, the next step is to import the package into your code and start using the functions.

from botcity.plugins.googledrive import BotGoogleDrivePlugin

As a demonstration of the library, let's build a simple example together that will do something cool .

Step 1 of Example

To make the example we will instantiate the plugin and search for a file by name.

# Set the path of the credentials json file
credentials = './resources/credentials.json'

# Instantiate the plugin
googledrive = BotGoogleDrivePlugin(credentials)

# Get the id of the file named "my_image.png" stored on the drive
file_id = googledrive.search_file_by_name("my_image.png")

Step 2 of Example

Now we will download the file which we search at Step 1.

# With the obtained id, download the file
googledrive.download_file(file_id, './images/my_image_from_drive.png')

Complete code

Let's take a look into the complete code:

# Import the plugin
from botcity.plugins.googledrive import BotGoogleDrivePlugin

# Set the path of the credentials json file
credentials = './resources/credentials.json'

# Instantiate the plugin
googledrive = BotGoogleDrivePlugin(credentials)

# Get the id of the file named "my_image.png" stored on the drive
file_id = googledrive.search_file_by_name("my_image.png")

# With the obtained id, download the file
googledrive.download_file(file_id, './images/my_image_from_drive.png')

Next Steps

Check our examples and experiment with the API. Let us know where it can be improved.

Have fun automating!

Back to top