Node.js Google Calendar: Get Instances of a Recurring Event

Back to Index

Returns instances of the specified recurring event.
This example gets instances for an event from the calendar having the ID = "support@chilkatcloud.com", where the event ID equals "6li3bfqqq65edprt4ms6vdld2j"

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


var os = require('os');
if (os.platform() == 'win32') {  
    var chilkat = require('chilkat_node6_win32'); 
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('chilkat_node6_arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('chilkat_node6_linux32');
    } else {
        var chilkat = require('chilkat_node6_linux64');
    }
} else if (os.platform() == 'darwin') {
    var chilkat = require('chilkat_node6_macosx');
}

function chilkatExample() {

    var rest = new chilkat.Rest();
    var success;

    //   Provide a previously obtained OAuth2 access token.
    var oauth2 = new chilkat.OAuth2();
    oauth2.AccessToken = "OAUTH2_ACCESS_TOKEN";
    rest.SetAuthOAuth2(oauth2);

    success = rest.Connect("www.googleapis.com",443,true,true);
    if (success !== true) {
        console.log(rest.LastErrorText);
        return;
    }

    var sbJson = new chilkat.StringBuilder();
    success = rest.FullRequestNoBodySb("GET","/calendar/v3/calendars/support@chilkatcloud.com/events/6li3bfqqq65edprt4ms6vdld2j/instances",sbJson);
    if (success !== true) {
        console.log(rest.LastErrorText);
        return;
    }

    if (rest.ResponseStatusCode !== 200) {
        console.log("Received error response code: " + rest.ResponseStatusCode);
        console.log("Response body:");
        console.log(sbJson.GetAsString());
        return;
    }

    var json = new chilkat.JsonObject();
    json.LoadSb(sbJson);

    //  The following code parses the JSON response.
    //  A sample JSON response is shown below the sample code.
    var kind;
    var etag;
    var summary;
    var updated;
    var timeZone;
    var accessRole;
    var nextSyncToken;
    var i;
    var count_i;
    var method;
    var minutes;
    var id;
    var status;
    var htmlLink;
    var created;
    var description;
    var location;
    var creatorEmail;
    var creatorSelf;
    var organizerEmail;
    var organizerSelf;
    var startDateTime;
    var startTimeZone;
    var endDateTime;
    var endTimeZone;
    var recurringEventId;
    var originalStartTimeDateTime;
    var originalStartTimeTimeZone;
    var iCalUID;
    var sequence;
    var hangoutLink;
    var remindersUseDefault;
    var j;
    var count_j;

    kind = json.StringOf("kind");
    etag = json.StringOf("etag");
    summary = json.StringOf("summary");
    updated = json.StringOf("updated");
    timeZone = json.StringOf("timeZone");
    accessRole = json.StringOf("accessRole");
    nextSyncToken = json.StringOf("nextSyncToken");
    i = 0;
    count_i = json.SizeOfArray("defaultReminders");
    while (i < count_i) {
        json.I = i;
        method = json.StringOf("defaultReminders[i].method");
        minutes = json.IntOf("defaultReminders[i].minutes");
        i = i+1;
    }

    i = 0;
    count_i = json.SizeOfArray("items");
    while (i < count_i) {
        json.I = i;
        kind = json.StringOf("items[i].kind");
        etag = json.StringOf("items[i].etag");
        id = json.StringOf("items[i].id");
        status = json.StringOf("items[i].status");
        htmlLink = json.StringOf("items[i].htmlLink");
        created = json.StringOf("items[i].created");
        updated = json.StringOf("items[i].updated");
        summary = json.StringOf("items[i].summary");
        description = json.StringOf("items[i].description");
        location = json.StringOf("items[i].location");
        creatorEmail = json.StringOf("items[i].creator.email");
        creatorSelf = json.BoolOf("items[i].creator.self");
        organizerEmail = json.StringOf("items[i].organizer.email");
        organizerSelf = json.BoolOf("items[i].organizer.self");
        startDateTime = json.StringOf("items[i].start.dateTime");
        startTimeZone = json.StringOf("items[i].start.timeZone");
        endDateTime = json.StringOf("items[i].end.dateTime");
        endTimeZone = json.StringOf("items[i].end.timeZone");
        recurringEventId = json.StringOf("items[i].recurringEventId");
        originalStartTimeDateTime = json.StringOf("items[i].originalStartTime.dateTime");
        originalStartTimeTimeZone = json.StringOf("items[i].originalStartTime.timeZone");
        iCalUID = json.StringOf("items[i].iCalUID");
        sequence = json.IntOf("items[i].sequence");
        hangoutLink = json.StringOf("items[i].hangoutLink");
        remindersUseDefault = json.BoolOf("items[i].reminders.useDefault");
        j = 0;
        count_j = json.SizeOfArray("items[i].reminders.overrides");
        while (j < count_j) {
            json.J = j;
            method = json.StringOf("items[i].reminders.overrides[j].method");
            minutes = json.IntOf("items[i].reminders.overrides[j].minutes");
            j = j+1;
        }

        i = i+1;
    }

    console.log("Example Completed.");

}

chilkatExample();

Sample JSON Response Body

{
  "kind": "calendar#events",
  "etag": "\"p33se7k7armnte0g\"",
  "summary": "support@chilkatcloud.com",
  "updated": "2017-11-08T19:40:49.131Z",
  "timeZone": "America/Chicago",
  "accessRole": "owner",
  "defaultReminders": [
    {
      "method": "popup",
      "minutes": 10
    }
  ],
  "nextSyncToken": "CPjj0Ordr9cCEPjj0Ordr9cCGAU=",
  "items": [
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171111T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzExMTFUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-11-10T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-11-10T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-11-10T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    },
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171118T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzExMThUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-11-17T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-11-17T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-11-17T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    },
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171125T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzExMjVUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-11-24T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-11-24T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-11-24T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    },
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171202T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzEyMDJUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-12-01T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-12-01T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-12-01T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    }
  ]
}