Skip to main content

Simple API for Google Calendar management with slots extension (dates and times available for scheduling)

Project description

Google Calendar Simple API Slots or gcsa-slots is an extension for Google Calendar Simple API library with slots (dates and times available for scheduling).

Installation

pip install gcsa-slots

See Getting started page for more details and installation options.

Example usage

List slots from free ranges (dates and times without events, available for scheduling)

from gcsa_slots.google_calendar import GoogleCalendar

calendar = GoogleCalendar("your_email@gmail.com")
for slot in calendar.get_slots(60):  # 60 minutes
    print(slot)

# 2023-03-06 09:00:00-03:00 - 2023-03-06 10:00:00-03:00
# 2023-03-06 11:00:00-03:00 - 2023-03-06 12:00:00-03:00
# 2023-03-06 14:00:00-03:00 - 2023-03-06 15:00:00-03:00
# 2023-03-06 15:00:00-03:00 - 2023-03-06 16:00:00-03:00
# 2023-03-07 09:00:00-03:00 - 2023-03-07 10:00:00-03:00
# 2023-03-07 10:00:00-03:00 - 2023-03-07 11:00:00-03:00
# 2023-03-07 11:00:00-03:00 - 2023-03-07 12:00:00-03:00
# 2023-03-08 09:00:00-03:00 - 2023-03-08 10:00:00-03:00
# 2023-03-08 10:00:00-03:00 - 2023-03-08 11:00:00-03:00
# 2023-03-08 14:00:00-03:00 - 2023-03-08 15:00:00-03:00
# 2023-03-08 15:00:00-03:00 - 2023-03-08 16:00:00-03:00
# ...

List slots from slot-event ranges (an event that determines availability for scheduling)

from gcsa_slots.google_calendar import GoogleCalendar

calendar = GoogleCalendar("your_email@gmail.com")
for slot in calendar.get_slots(60, slot_summary="Free"):  # 60 minutes
    print(slot)

# 2023-03-06 09:00:00-03:00 - 2023-03-06 10:00:00-03:00
# 2023-03-06 11:00:00-03:00 - 2023-03-06 12:00:00-03:00
# 2023-03-06 14:00:00-03:00 - 2023-03-06 15:00:00-03:00
# 2023-03-06 15:00:00-03:00 - 2023-03-06 16:00:00-03:00
# 2023-03-07 09:00:00-03:00 - 2023-03-07 10:00:00-03:00
# 2023-03-07 10:00:00-03:00 - 2023-03-07 11:00:00-03:00
# 2023-03-07 11:00:00-03:00 - 2023-03-07 12:00:00-03:00
# 2023-03-08 09:00:00-03:00 - 2023-03-08 10:00:00-03:00
# 2023-03-08 10:00:00-03:00 - 2023-03-08 11:00:00-03:00
# 2023-03-08 14:00:00-03:00 - 2023-03-08 15:00:00-03:00
# 2023-03-08 15:00:00-03:00 - 2023-03-08 16:00:00-03:00
# ...

List slots specifying time range, slot interval, max events per slot and calendar ID

from gcsa_slots.google_calendar import GoogleCalendar

calendar = GoogleCalendar("your_email@gmail.com")
calendar_id = "your calendar id"
for slot in calendar.get_slots(
    45,
    slot_summary="fReE",
    case_sensitive=False,
    time_min=datetime(2023, 3, 6),
    time_max=datetime(2023, 3, 7),
    events_per_slot=3,
    calendar_id=calendar_id,
):
    print(slot)

Create event in first available slot

from gcsa_slots.google_calendar import GoogleCalendar

calendar = GoogleCalendar("your_email@gmail.com")
slots = calendar.get_slots(90, slot_summary="Free")
slot = next(slots)
slot.summary = "This is a test!"
calendar.add_event(slot)

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

gcsa-slots-0.1.1.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

gcsa_slots-0.1.1-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

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