Metadata-Version: 2.5
Name: pymoodle
Version: 0.4.1
Summary: A python client for Moodle web services
Project-URL: Homepage, https://github.com/septatrix/pymoodle
Project-URL: Bug Tracker, https://github.com/septatrix/pymoodle/issues
Author-email: Nils Kattenbeck <nilskemail+pypi@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: httpx<1,>=0.28
Description-Content-Type: text/markdown

# pyMoodle

A python client for Moodle web services still in development.

## Usage

`MoodleClient` (and its asynchronous counterpart `AsyncMoodleClient`)
provides a typed method for every webservice function of Moodle.
Results are returned as `TypedDict`s,
so type checkers and IDEs know which keys are available:

```python
from moodle.session import MoodleClient

with MoodleClient("https://moodle.example.com", "TOKEN") as client:
    info = client.core_webservice_get_site_info()
    print(info["sitename"])

    userid = info["userid"]
    # Moodle declares most return values as nullable, so they need to be checked.
    assert userid is not None
    for course in client.core_enrol_get_users_courses(userid=userid):
        print(course["fullname"])
```

The types of parameters and return values can be imported from `moodle.ws.types`,
e.g. `CoreWebserviceGetSiteInfoReturns`.
Functions which are not covered by the bindings
(e.g. from third-party plugins)
can be called using `client.webservice("function_name", {"param": "value"})`.

The bindings are generated from the source code of the latest Moodle LTS release.
See [`codegen/`](codegen/README.md) for how they are generated
and how to generate bindings for other Moodle versions or additional plugins.

## Development

The development tools are listed in the `dev` dependency group:

```sh
pip install -e . --group dev
ruff check && ruff format --check
mypy && pyright
python -m unittest discover tests
```
