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.

@georgehrke
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

Hi
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

Well, this also seems like a pain in the ass. I suppose, the two biggest reasons for that is the laughably inaccurate Nextcloud documentation & the atrocious general API to begin with.

Not through CalDAV, but our documentation has a whole section on how to interact and manage calendar events through public interfaces: Calendar integration โ€” Nextcloud latest Developer Manual latest documentation

For CalDAV any generic CalDAV library will do.