Skip to main content

Python package to interact with Google Suite APIs

Project description

Google Suite

Python library to automate handling of various Google Suite APIs such as Gmail, Blogger, etc.

Setup

  • Make sure you have your Google token and credentials for your project from Google Cloud. You can follow the steps here to get started. You'll have to enable the Blogger api also.

gmail.py

Quick overview of the methods:

Name Description Arguments
list_labels List of labels (returns a dict) None
create_label Creates a label label_name: str
update_label Updates a label label_name: str, new_label_name: str, label_visibility: LabelListVisibility, message_visibility: MessageListVisibility
delete_label Deletes a label label_name: str
label_by_id Gets a label by id label_name: str
label_by_name Gets a label by name msg_label_list: list
mark_read Marks an email as read by id msg_id: str
mark_all_read Marks all emails as read given a label or sender or both label_id: str = None, sender: str = None
mark_unread Marks an email as unread by id msg_id: str
list_messages List of messages None
send_message Sends a message that can have with or without an attachment. If provided a threadId it will also reply within the email thread chain. from_sender: str, to: str, subject: str, message_text: str, file: str = None, thread_id: str = None
download_attachment Downloads an attachment and puts it in the attachments directory. Returns the path of the attachment. Also marks the email as read label_name: str = None, sender: str = None
download_attachments Download attachments from a list of messages using a ThreadPool and puts it in the attachments directory. Returns the path of the attachment. Also marks the email as read messages: list[Message]
list_filters List of filters None
get_filter Get a filter by id filter_id: str
create_filter Creates a filter label_name: str = None, remove_from_inbox: bool = None, filter_from: str = None, subject: str = None, query: str = None, negatedQuery: str = None
update_filter Updates a filter label_name: str, new_label_name: str = None, label_visibility: LabelListVisibility = None, message_visibility: MessageListVisibility = None
delete_filter Deletes a filter filter_id: str
from google_suite import Gmail

Gmail.list_labels()

# {'CHAT': 'CHAT',
#  'SENT': 'SENT',
#  'INBOX': 'INBOX',
#   etc...
#  'Unwanted': 'Label_9'}

blogger.py

The blogger.py file contains methods to interact with the Blogger API:

Method Description Arguments
list_blogs Lists all blogs by the user. None
list_posts Lists all posts in a specific blog. None
get_post_content Retrieves the content of a specific post. post_id: str
search_post Searches for posts based on a query. query: str
insert_post Inserts a new post in the blog. title: str, content: str
delete_post_by_id Deletes a post by its ID. post_id: str
delete_post_by_title Deletes a post by its title. title: str
list_comments Lists comments for a specific post. post_id: str
get_comment_by_id Retrieves a comment by its ID. post_id: str, comment_id: str
list_comments_by_blog Lists comments for the entire blog. None
mark_as_spam Marks a comment as spam. post_id: str, comment_id: str
mark_as_not_spam Marks a comment as not spam. post_id: str, comment_id: str
from google_suite import Blogger
Blogger.list_blogs()
# {'kind': 'blogger#blogList',
#  'items': [{'kind': 'blogger#blog',
#    'id': '63.....',
#    'status': 'LIVE',
#    'name': 'The coolest blog ever',
#    'description': '',
#    'published': '2023-10-18T06:58:29-07:00',
#    'updated': '2024-03-12T10:20:35-07:00',
#    'url': 'http://tedfulk.blogspot.com/',
#    'selfLink': 'https://blogger.googleapis.com/v3/blogs/63.....',
#    'posts': {'totalItems': 2,
#     'selfLink': 'https://blogger.googleapis.com/v3/blogs/63...../posts'},
#    'pages': {'totalItems': 0,
#     'selfLink': 'https://blogger.googleapis.com/v3/blogs/63...../pages'},
#    'locale': {'language': 'en', 'country': '', 'variant': ''}}]}

Utilizing the Service Object

The util.py file builds the service object to interact with the Google APIs. Ensure that the project is set up in the Google Cloud Platform, and the necessary permissions and correct access to the scopes for the APIs are granted.

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_suite-0.1.3.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

google_suite-0.1.3-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file google_suite-0.1.3.tar.gz.

File metadata

  • Download URL: google_suite-0.1.3.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.13 Darwin/23.4.0

File hashes

Hashes for google_suite-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7879644d483628f3e28f4aba375be46d247de71c06dfbdb76cc8f9e169ab2caa
MD5 beffa5e37eeab7f8e0c5bc622e60aac2
BLAKE2b-256 61b34fec5b69a27761e8fba429b7006afd6f0f3ee21c6db53b8b395c89ac5435

See more details on using hashes here.

File details

Details for the file google_suite-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: google_suite-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.13 Darwin/23.4.0

File hashes

Hashes for google_suite-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 63131629150e43c28480baeb654680ad5bc593d373ce973b695ee98b1172db65
MD5 b98ff939d630863c1ccdc98f954b7f5e
BLAKE2b-256 9ea7162b68a303c60429819cba8640458277698d22fb3bb9fc1a51321376af0b

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