gcal-fetcher
Fetch events from the Google Calendar JSON API using only an API key — no OAuth required.
Prerequisites
- Google Calendar Api Key
- Google Calendar ID (The Calendar ID looks like
your_email@gmail.comfor a primary calendar orxxxx@group.calendar.google.comfor other calendars.)
Notes
- Only works for public Google Calendars (no support for private calendars with auth)
- All timestamps are in
chrono::Utc, the client will have to take care of timezones. - This crate exposes
chrono::DateTime<Utc>in its public API. Thechronocrate is re-exported asgcal-fetcher::chronoso you don't need a direct dependency on it. If you do depend onchronodirectly, pin a version compatible with0.4to avoid type-mismatch errors. - DateTime is accessible as gcal_fetcher::DateTime/gcal_fetcher::Utc, so if not needed otherwise you don't need to import chrono yourself.
Installation
[]
= "0.1"
Usage
use NonZeroI32;
use fetch_events;
API
Functions
fetch_events
Fetches all events from now up to fetch_days days into the future. Recurring events are expanded server-side (singleEvents=true). Results are sorted by start time. Negative values for fetch_days are technically supported to fetch past events.
fetch_events_starting_from
Same as fetch_events, but accepts an explicit now timestamp. Useful for testing or when you need a reproducible time window.
CalendarEvent
Encompasses the interesting information from a Google Calendar Event:
| Field | Description |
|---|---|
id |
Unique event ID from the Google Calendar API |
etag |
Entity tag for cache-validation; changes whenever the event is edited |
summary |
Event title ("(No title)" if absent) |
start |
Start time in UTC. All-day events are normalised to 00:00:00 UTC on their start date |
end |
End time in UTC. All-day events are normalised to 00:00:00 UTC on their end date |
description |
Optional event description |
location |
Optional location string |
is_whole_day_event |
true if the event is an all-day event (Google provided a date only, not a date-time) |
Note on all-day events: Google represents all-day events with a plain date (
2026-05-01) rather than a date-time.gcal-fetcherconverts these to2026-05-01T00:00:00Z. Keep this in mind when displaying or comparing times for all-day events.
FetchError
| Variant | Cause |
|---|---|
Http |
The HTTP request failed (network error, non-2xx status, invalid API key, etc.) |
Io |
Failed to read the response body |
Parse |
The response body could not be parsed as JSON |
License
MIT — see LICENSE or https://opensource.org/licenses/MIT.