There is a documentation about the APIs:
https://docs.nextcloud.com/server/latest/developer_manual/client_apis/index.html
There was a basic client that lets you handle files and create shares in python, perhaps it helps for some inspiration: GitHub - owncloud/pyocclient: ownCloud client library for Python