codingJoe
codingJoe

Reputation: 4953

Looking for a better python Google Calendar API example

I am trying to write an application that can add events to a google calendar.
There is this really neat site that lets you play with the API. http://code.google.com/apis/explorer/#_s=calendar&_v=v3&_m=events.insert

Using that site, I was able to build a calendar event using the following stuff. I am having difficulty translating that into python. Assuming that I've already authenticated with oauth, How do I do this with python code? It looks I have to build a json string and somehow turn that into an http request. I have no clue how to do that.

Can anyone provide an example of how to accomplish the same thing with the Python API?

Many Thanks!

POST
https://www.googleapis.com/calendar/v3/calendars/my_calendar_id_string/events?pp=1&key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.ANOTHERBIGSLONGTRINGHEREFfxCTiKMIR_bDui
X-JavaScript-User-Agent:  Google APIs Explorer

{
"start": {
"dateTime": "2012-05-24T14:00:00-06:00"
},
"end": {
"dateTime": "2012-05-24T18:00:00-06:00"
},
"description": "My Description"
}

Upvotes: 12

Views: 29011

Answers (3)

Yevhen Kuzmovych
Yevhen Kuzmovych

Reputation: 12140

Just a self-plug:

There is the Google Calendar Simple API (gcsa) for Python (developed by me). It is much simpler, more Pythonic, and object-oriented. It handles credentials, JSON formatting, datetimes/timezones, recurrence, etc. for you. Here is the Documentation.

Upvotes: 14

whatf
whatf

Reputation: 6468

Came across this article shows with ample screenshots.

Also, this GitHub repo has ample examples.

Upvotes: 1

Claudio Cherubino
Claudio Cherubino

Reputation: 15024

Check the docs for all Python samples, for instance here is one showing how to create an event: https://developers.google.com/google-apps/calendar/v3/reference/events/insert

Upvotes: 6

Related Questions