Skip to main content

Nextcloud Python Framework

Project description

Nextcloud Python Framework

Analysis & Coverage codecov

NextcloudVersion PythonVersion impl pypi

Python library that provides a robust and well-documented API that allows developers to interact with and extend Nextcloud's functionality.

The key features are:

  • Fast: High performance, and as low-latency as possible.
  • Intuitive: Fast to code, easy to use.
  • Reliable: Minimum number of incompatible changes.
  • Robust: All code is covered with tests as much as possible.
  • Easy: Designed to be easy to use.
  • Async-first: Full async API with sync wrappers available for most modules.

Deprecation notice: sync API

Starting with version 0.30.0, we are gradually removing sync wrappers in favour of the async API. The following modules have already lost their sync counterparts: Activity, Notes, User Status, and Weather Status.

All remaining sync methods will be phased out in future releases. If you are still using the sync Nextcloud / NextcloudApp classes, we recommend migrating to AsyncNextcloud / AsyncNextcloudApp as soon as possible.

Differences between the Nextcloud and NextcloudApp classes

The Nextcloud class functions as a standard Nextcloud client, enabling you to make API requests using a username and password.

On the other hand, the NextcloudApp class is designed for creating applications for Nextcloud.
It uses AppAPI to provide additional functionality allowing applications have their own graphical interface, fulfill requests from different users, and everything else that is necessary to implement full-fledged applications.

Both classes offer most of the same APIs, but NextcloudApp has a broader selection since applications typically require access to more APIs.

Any code written for the Nextcloud class can easily be adapted for use with the NextcloudApp class, as long as it doesn't involve calls that require user password verification.

Nextcloud skeleton app in Python

from contextlib import asynccontextmanager

from fastapi import FastAPI

from nc_py_api import AsyncNextcloudApp
from nc_py_api.ex_app import AppAPIAuthMiddleware, LogLvl, run_app, set_handlers


@asynccontextmanager
async def lifespan(app: FastAPI):
    set_handlers(app, enabled_handler)
    yield


APP = FastAPI(lifespan=lifespan)
APP.add_middleware(AppAPIAuthMiddleware)


async def enabled_handler(enabled: bool, nc: AsyncNextcloudApp) -> str:
    if enabled:
        await nc.log(LogLvl.WARNING, "Hello from nc_py_api.")
    else:
        await nc.log(LogLvl.WARNING, "Bye bye from nc_py_api.")
    return ""


if __name__ == "__main__":
    run_app("main:APP", log_level="trace")

Support

You can support us in several ways:

  • ⭐️ Star our work (it really motivates)
  • ❗️ Create an Issue or feature request (bring to us an excellent idea)
  • 💁 Resolve some Issue or create a Pull Request (contribute to this project)
  • 🙏 Write an example of its use or help improve the project.

More Information

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nc_py_api-0.30.0.tar.gz (82.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nc_py_api-0.30.0-py3-none-any.whl (103.1 kB view details)

Uploaded Python 3

File details

Details for the file nc_py_api-0.30.0.tar.gz.

File metadata

  • Download URL: nc_py_api-0.30.0.tar.gz
  • Upload date:
  • Size: 82.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for nc_py_api-0.30.0.tar.gz
Algorithm Hash digest
SHA256 691c8bbc9764c1319b7294a3c74112eb027f97de2fdd8c93ccbf820e8c2565a0
MD5 36af8032d9ae896e338d09b30cbec5f7
BLAKE2b-256 9e1fae62de8c88334ad4049dea41d5101e07f5a69f09f5eda29bef618bb8454b

See more details on using hashes here.

File details

Details for the file nc_py_api-0.30.0-py3-none-any.whl.

File metadata

  • Download URL: nc_py_api-0.30.0-py3-none-any.whl
  • Upload date:
  • Size: 103.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for nc_py_api-0.30.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ea4678450e87bfeb7145f279511f6f7863b9331a47d61bfc51a9358dae1805b
MD5 22400ad0d0d6ca1371f8037f2bf26d00
BLAKE2b-256 8be429a47d9ce53c49b1589693c6dc83f1b9c82880b25bd605c2d6607b29e58f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page