Add an event via API

Hello all.
I need to add event to a nextcloud calendar via an API. I know how to build my event with python and icalender. But how to add it to the calendar :thinking:? Should I add it directly to the database on the server?

Thanks for your help

There is an official API: CalDAV.
Just create yourself an app-password in the personal settings and create events directly via CalDAV. I can’t give you any recommendation, but there are plenty of caldav libs for Python.

Please don’t. Whenever you create events, it’s not just added to the calendarobjects table, but there are modifications in many other tables. The c-tag in the calendars table is incremented, it adds a record to calendar changes, plenty new rows are added to calendarobjects_props, the activity app saves a change, etc etc.
If you insert it directly, you will only end up with inconsistencies in the database.

In the meantime I’ve look at the database and see it would be very difficult to add event into it.
And I discover CalDAV too. And find python’s lib.
Thanks for your reply
Have a nice day

I ask here, we have company app for vacations. How connect to caldav api as admin to create calendar vacations (if doesnt exist) and add event to all users?
thanx for answer

did u happen to find an answer to this? Adding an event for all users

Will you share some example code or links to documentation? I’m trying to do something similar.

1 Like