In a terminalAvailable · 0.4.1

Moodle Core CLI

Automate Moodle through its standard web services, with nothing to install on Moodle.

The npm package moodle-core-cli is a Node.js library and command for Moodle's own web services. It offers friendly operations such as create_course and handles Moodle function names, parameters, and version differences for you. Use it when your site cannot install the MoodlIA plugin.

What it does

  • Friendly operations for courses, users, enrolments, groups, grades, and more, on Moodle 4.5 to 5.3.
  • Read-only by default: writes need --allow-write and deletions also --yes.
  • JSON output and stable exit codes for automation.

What you need

  • Node.js 22.13 or newer.
  • Web services and REST enabled, and an external service with the Moodle functions you will use.
  • A token for a dedicated user with only the permissions it needs.

Installation

Prepare Moodle (administrator)

  1. Enable web services and the REST protocol.

  2. Create an external service and add the core functions you need, plus core_webservice_get_site_info for version detection.

  3. Create a dedicated user with the required permissions and a token for that service.

Install and configure

  1. Install the package, or run it directly with npx:

    npm install moodle-core-cli
  2. Set the Moodle address and token:

    export MOODLE_BASE_URL=https://moodle.example.com
    export MOODLE_TOKEN=your-token

First use

  1. Read before you write:

    npx moodle-core-cli get-courses
    npx moodle-core-cli get-course --course-id 42
  2. Writing requires an explicit flag:

    npx moodle-core-cli create-course --allow-write \
      --fullname "Introduction to Biology" --shortname BIO101 --category-id 3

Good to know

  • It can only do what the Moodle service exposes and what the token's user is allowed to do.

Other apps

On your Moodle siteAvailable · 0.1.215

MoodlIA Moodle Plugin

Let AI assistants and scripts work with Moodle safely, within Moodle's own permissions.

In a terminalAvailable · 0.4.1

MoodlIA CLI

Run every MoodlIA plugin operation from a terminal, a script, or an AI agent's shell.

In a terminalPreview · 0.1.1

MoodlIA Sync

Copy course content from one Moodle site to another without backups, after you approve a plan.

Need help?

Questions about installing or using any MoodlIA app, or ideas for new ones: write to us.

contact@moodlia.com