Get JSON from a public Google Calendar
Solution 1
Your calendar have to be shared publicly! This one works if you have shared only free/busy status:
http://www.google.com/calendar/feeds/{calendarId}@group.calendar.google.com/public/basic?orderby=starttime&sortorder=ascending&futureevents=true&alt=json
Full details - this one works only if calendar is shared fully publicly
http://www.google.com/calendar/feeds/{calendarId}@group.calendar.google.com/public/full?orderby=starttime&sortorder=ascending&futureevents=true&alt=json
Or just free-busy
http://www.google.com/calendar/feeds/{calendarId}@group.calendar.google.com/public/free-busy?orderby=starttime&sortorder=ascending&futureevents=true&alt=json
Parameters orderby, sortorder and futureevents are optional but might help you later :)
Solution 2
Since November 17th 2014, v1 and v2 of the Google Calendar API have been disabled.
Google Calendar API V3 requires oauth authentication for almost all of its operations. As near as I can tell, this also requires user interaction.
However, for public calendars, it is still possible to use a single link to get JSON data (this is not currently documented by Google - I don't know if it's oversight on their part or private API that might disappear tomorrow).
- Register your application with the Google Developers Console
- Activate the Google Calendar API in the Google Developers Console.
- Under Credentials, create a new Public API access key (you may want to leave referrers blank for testing)
-
The JSON url now looks like this
https://www.googleapis.com/calendar/v3/calendars/{calendarid}/events?key={Your Public API Key}
(The curly braces {} should not present in the actual url).
The API documentation describes additional parameters you can include (except that you can also include the parameter &callback=, as with most JSON requests, to create a JSONP response for javascript).
Related videos on Youtube
Rikard
Updated on September 22, 2020Comments
-
Rikard over 3 years
How can I get a
JSON
with the events of a public Google Calendar? I have it'sID
but no acess to it. I don't want to change its events, nor log in.I would like get a
JSON
from it to sync with myPHP
/MySql
database.Tried
https://www.googleapis.com/calendar/v3/calendars/{calendarId}
but got login error:
{ "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Login Required", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Login Required" } }
-
admdrew over 10 yearsI feel like this question was just asked...
-
Bugs over 10 years
-
Rikard over 10 years@admdrew, true. I asked a similar one, bad formulated. So I deleted that one, improved my text and posted again.
-
admdrew over 10 yearsAhh ok. Good, I was feeling crazy for a second!! (not that this makes me not crazy...)
-
Rikard over 10 years@Bugs, thanks for the link. Had also checked it. But didn't get it to work. That links example require
OAuth 2.0
authentication. I don't need to edit the calendar, just get data from it. -
Bugs over 10 yearsThat's not the point. You aren't required to authenticate as the owner of the calendar. "Every request your application sends to the Google Calendar API must include an authorization token. The token also identifies your application to Google."
-
Rikard over 10 years@Bugs, is that the
ID
of the calender or I have to register my domain/php at Google and get akey
from them? -
Bugs over 10 yearsIt has nothing to do with the calendar itself. You're required to register your app so Google can control the use of their APIs.
-
Rikard over 10 years@Bugs, but I can get a iCal from Google with a url with the ID on it, why not a JSON string?
-
Rikard over 10 years@admdrew, sorry if this makes you crazy :) Do you have any input about this?
-
Bugs over 10 years@Rikard I don't know. I'm merely interpreting the documentation. I would guess that the API providers more comprehensive info, and so it's more likely to be misused.
-
-
Code cracker about 9 yearsthis is not my question but your answer is very helpful to me, thanks @laky
-
Laky about 9 yearsSince November 2014 free-busy link does not work. To get start and end time you have to use Google Calendar API V3 described below.
-
Shajeel Afzal over 8 yearsFull detail URL is also not working, I assume that
{calendarId}
is needed to be replaced with email address -
royco about 8 yearsI don't see how to create a Public API access key. Has something changed?
-
hktang over 7 yearsIt seems there's a daily limit for this use. On my server, it returns 403 with the message "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup." But from my browser, it works fine. I can't find any documentation about the maximum requests allowed per day.
-
Akin Hwan over 6 yearsI am getting a forbidden 403 response, is this approach still valid? I find that the answer below with 43 upvotes is actually giving back a response.
-
Akin Hwan over 6 yearsHow would I get freebusy query for everyone that has shared their calendars with me. In other words, is it possible to view freebusy query for all employees at a company domain, via one calendarID (my email address), as long as everyone's calendar is shared within the same company?