📅 Microsoft Graph Calendar APIs: calendarView vs events (Explained Simply)

📅 Microsoft Graph Calendar APIs: calendarView vs events (Explained Simply)

If you’re working with Microsoft Graph calendars, especially shared mailboxes, you’ve probably come across these two endpoints:

  • /calendar/calendarView

  • /calendar/events

At first glance, they look like they do the same thing.

But in reality… they don’t — and choosing the wrong one can break your calendar logic 😅

Let’s break this down in a simple, visual, and practical way.

🤔 The Big Question

“I just want to fetch calendar events — which API should I use?”

Answer:

👉 It depends on what kind of calendar experience you’re building.

🧩 Understanding the Core Difference

🟢 calendarView → “Show me what’s on the calendar”

🔵 events → “Show me event records”

That’s it.

1️⃣ Using /calendar/calendarView

const response = await client
.api(`/users/${sharedMailboxUPN}/calendar/calendarView`)
.query({
startDateTime,
endDateTime,
})
.filter("isCancelled eq false")
.orderby("start/dateTime")
.top(500)
.get();

🧠 What it does

  • Returns events that occur within a specific time range

  • Expands recurring events into individual occurrences

  • Behaves exactly like Outlook Calendar

Think of this as:

“Show me what actually appears on the calendar between these dates.”

✅ Why this is powerful

  • ✔ Handles recurring meetings correctly

  • ✔ Only shows events inside your date range

  • ✔ Perfect for day / week / month views

  • ✔ Ideal for shared mailboxes & room calendars

📌 Real-world example

If a meeting repeats every day, you’ll get:

  • Monday meeting

  • Tuesday meeting

  • Wednesday meeting

    …each as a separate event

✨ Just like Outlook.

2️⃣ Using /calendar/events

const response = await client
.api(`/users/${sharedMailboxUPN}/calendar/events`)
.filter(`end/dateTime ge '${startDateTime}'`)
.orderby("start/dateTime")
.top(500)
.get();

🧠 What it does

  • Returns event definitions

  • Does NOT expand recurring events

  • Ignores real calendar boundaries

Think of this as:

“Show me the event objects stored in the mailbox.”

⚠️ Why this can be dangerous

  • ❌ Recurring meetings appear only once

  • ❌ You don’t get individual occurrences

  • ❌ Filtering by date gives misleading results

  • ❌ Not suitable for calendar UI

📌 Real-world problem

A meeting repeats daily for 1 year.

Using /events:

  • You get one event

Using /calendarView:

  • You get each daily meeting

Big difference 🚨

🆚 Side-by-Side Comparison

FeaturecalendarViewevents
Time range filtering✅ Accurate❌ Partial
Recurring events✅ Expanded❌ Not expanded
Calendar UI support✅ Perfect❌ Poor
Outlook-like behavior✅ Yes❌ No
Best for shared mailbox✅ Yes⚠️ Risky

🎯 When Should You Use What?

✅ Use calendarView if:

  • You are building a calendar UI

  • You need correct recurring meetings

  • You are working with shared mailboxes

  • You care about date & time accuracy

👉 This is the correct choice for 90% of calendar apps

✅ Use events only if:

  • You want to update or delete events

  • You need series-level metadata

  • You are building admin or maintenance tools

👉 Not recommended for displaying calendars.

🧠 Pro Tip: Timezone Matters

Always set timezone explicitly when using calendarView:

.headers({
 Prefer: 'outlook.timezone="Asia/Kolkata"'
})

This avoids:

  • ❌ Events shifting time

  • ❌ Midnight surprises

  • ❌ “Why is this meeting at 3 AM?” bugs 😄

✅ Final Recommendation

If your question is:

“Which API should I use to show calendar events?”

Answer:

🟢 Use /calendar/calendarView

It’s accurate, reliable, and behaves exactly like Outlook.