Which api should used for list events?

Arora, Nancy 21 Reputation points
2023-03-29T13:21:18.75+00:00

Hi,

Below mention both api returning same data events from default calendar.

GET /users/{id | userPrincipalName}/events

GET /users/{id | userPrincipalName}/calendar/events.

What is the difference between these api? and some of events from default calendar is not returning by these api. But when am using calendar View api data is returning correct.

GET /me/calendar/calendarView?startDateTime={start_datetime}&endDateTime={end_datetime}

Please help me to choose what api i need to use for fetch calendar event which return all the events from default calendar.

Thanks,

Nancy Arora

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,448 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. HarmeetSingh7172 4,811 Reputation points
    2023-03-29T18:52:06.92+00:00

    Hello Arora, Nancy,

    Thanks for reaching out!

    When you list events (GET /me/events), you get a non-expanded list of items in the calendar. What that means is that if you have recurring events, you will only get the series master in your results. It would be up to you to read the recurrence pattern and expand the event.

     GET /users/{id | userPrincipalName}/calendar/events return events from the default calendar of a specific user.

    When you list a calendar view (GET /me/calendarview?...), you get an expanded list of items. That means the server does the work to expand any recurring events and build a "view" of your calendar. So, in this case if you have a recurring event, instead of getting the series master, you will get one or more occurrences of the series (depending on how many times it repeats in your view window). Because of this expansion work, you must provide a start and end time to put some sort of bounds on the call.

    Another way of looking at it is the calendar view is more like what you're used to seeing when you view your calendar in Outlook.

    By default, you're limited to 10 items in the response. You should also see in your response an @odata.nextLink, which is the URL you can use to request the next page of results (again, 10 being the default page size). You can increase your page size by using the $top parameter, up to a maximum of 1000 (IIRC).

    Get /me/calendar/calendarView?startDateTime=2023-03-01T00:00:00.0000000&endDateTime=2023-03-08T00:00:00.0000000&$top=1000

    Recommendations/Best Practices while using CalendarView:

    • The recommended time window used in the CalendarView should ideally be not more than one week. This is because CalendarView API does a lot of processing in the backend before providing the results.
    • Using $skip and/or $top in the API query parameters doesn't necessarily skip the calculations needed for getting the results for this API. Hence, if a larger window of CalendarView is to be queried, the client should make CalendarView API calls with different time windows, rather then using a larger time window and relying on $skip and $top.
    • Server-side time limit for getting the results of any REST API is 2 minutes (120 seconds), after which the API request gets terminated and the client will receive a 500 Status Code. On observing such long delays, the client should reduce the time window being queried for and try again.
    • The $select on the API should preferably contain only on-page properties (list of which can be viewed here named as HardCodedProperties).
      Example : $select=Id,ChangeKey,Categories,OriginalStartTimeZone,OriginalEndTimeZone,iCalUId,HasAttachments,Subject,IsCancelled,IsOrganizer,ResponseRequested,SeriesMasterId,ShowAs,Type,IsDraft,Start,End
      You could exclude properties you don't need for faster responses.
    • If the time window has numerous recurring series events, CalendarView needs to load all the instances in that time frame which makes it less performant. It is recommended for the user to work with EEEs and get their old recurring meetings archived for better performance.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.


  2. Oliver Anthony 0 Reputation points
    2023-05-18T19:32:28.3733333+00:00

    There are several APIs available for listing events, depending on the type of events you are referring to. Here are a few commonly used APIs for different types of events:

    Google Calendar API: If you want to list events from a user's Google Calendar, you can use the Google Calendar API. It provides methods to retrieve events, create new events, update existing events, and more.

    Facebook Graph API: For events created on Facebook, you can use the Facebook Graph API. It allows you to retrieve events from Facebook pages, groups, and user profiles. You can filter events based on various criteria such as location, time, and keywords.

    Meetup API: Meetup is a popular platform for organizing and discovering events. The Meetup API enables you to access event data, including event details, attendees, and RSVP information. You can retrieve events based on location, category, time, and other parameters.

    0 comments No comments

  3. Alvaro Mathis 0 Reputation points
    2023-11-01T08:51:43.37+00:00

    To list events programmatically, you can use the Google Calendar API if you want to work with Google Calendar events, or the Eventbrite API if you're dealing with events on the Eventbrite platform. These APIs allow you to retrieve and manipulate event data, such as listing upcoming events, event details, and more.

    0 comments No comments