Delos Chang
Delos Chang

Reputation: 1853

Google Calendar API v3 grab upcoming event

I'd like to craft an API request that will grab the next event on the calendar.

I found a guide for v2, but that's deprecated now. In the documentation here: https://developers.google.com/google-apps/calendar/v3/reference/events/get,

it seems like I need to have some kind of event ID. I was thinking of grabbing the entire event list and then sorting by date.

Any help on this would be appreciated.

Upvotes: 1

Views: 2652

Answers (1)

bvstone
bvstone

Reputation: 607

Yes, you will need an event ID to grab a specific event.

But, like you mentioned you can list events for a specific time period.

For each event returned in the list you'll get pretty much the same information (and event resource).

But you'll need some sort of starting reference to get the "next" event. So, assuming you have an event ID to start with (or something else you can use to identify the event ID), grabbing the "next" event would be the next listed event resource when all resources are sorted by date.

The neat thing is you can have the list events API return the events sorted by start time (note, I've not used this, but assume it works).

https://developers.google.com/google-apps/calendar/v3/reference/events/list

See the orderBy value that is optional.

Upvotes: 2

Related Questions