Skip to main content

Crate gcal_fetcher

Crate gcal_fetcher 

Source
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§

pub use chrono::DateTime;
pub use chrono::Utc;
pub use chrono;

Structs§

CalendarEvent
Parsed Google Calendar Event.

Enums§

FetchError
Enum for different potential errors.

Functions§

fetch_events
Fetch events from Google Calendar JSON API. Uses singleEvents=true to expand recurring events server-side. Fetches events from “now” up to the given days in the future.
fetch_events_starting_from
Same as fetch_events but lets you define a “now”.