Need good example: Google Calendar API in Javascript

Google provides a great JS client library that works with all of Google’s discovery-based APIs (such as Calendar API v3). I’ve written a blog post that covers the basics of setting up the JS client and authorizing a user.

Once you have the basic client enabled in your application, you’ll need to get familiar with the specifics of Calendar v3 to write your application. I suggest two things:

  • The APIs Explorer will show you which calls are available in the API.
  • The Chrome developer tools’ Javascript console will automatically suggest method names when you are manipulating gapi.client. For example, begin typing and you should see a set of possible completions (you’ll need the insert method).

Here’s an example of what inserting an event into JS would look like:

var resource = {
  "summary": "Appointment",
  "location": "Somewhere",
  "start": {
    "dateTime": "2011-12-16T10:00:00.000-07:00"
  "end": {
    "dateTime": "2011-12-16T10:25:00.000-07:00"
var request ={
  'calendarId': 'primary',
  'resource': resource
request.execute(function(resp) {

Hopefully this is enough to get you started.

Leave a Comment