Expand description
§gcal-fetcher
Fetch events from the Google Calendar JSON API using only an API key — no OAuth required.
Only public Google Calendars are supported. All timestamps are returned as
chrono::DateTime<Utc>; timezone conversion is left to the caller.
This crate exposes chrono::DateTime<Utc> in its public API. The
chrono crate is re-exported as gcal_fetcher::chrono so you don’t
need a direct dependency on it. If you do depend on chrono directly,
pin a version compatible with 0.4 to avoid type-mismatch errors.
Right now only blocking is supported, this was done to keep dependencies small. A future version might include a feature flag to support async execution.
§Usage
use std::num::NonZeroI32;
use gcal_fetcher::fetch_events;
let calendar_id = "your-calendar-id@group.calendar.google.com";
let api_key = "YOUR_GOOGLE_API_KEY";
let fetch_days = NonZeroI32::new(30).unwrap();
match fetch_events(calendar_id, api_key, fetch_days) {
Ok(events) => {
for event in &events {
println!("{} — {} to {}", event.summary, event.start, event.end);
if let Some(loc) = &event.location {
println!(" 📍 {}", loc);
}
}
println!("{} event(s) found.", events.len());
}
Err(e) => eprintln!("Error: {}", e),
}Re-exports§
Structs§
- Calendar
Event - Parsed Google Calendar Event.
Enums§
- Fetch
Error - Enum for different potential errors.
Functions§
- fetch_
events - Fetch events from Google Calendar JSON API.
Uses
singleEvents=trueto expand recurring events server-side. Fetches events from “now” up to the given days in the future. - fetch_
events_ starting_ from - Same as
fetch_eventsbut lets you define a “now”.