davila7 avatar

Moodle External Api Development

If you need to expose Moodle LMS functionality through REST or AJAX endpoints, this walks you through the framework's strict three-method pattern: define your input parameters with proper validation types, implement the business logic with capability checks and database operations, then define your return structure. It covers the full registration process in services.php and includes practical error handling with file-based logging. The parameter validation and context checking here are non-negotiable in Moodle development, so following this pattern saves you from security headaches. Most useful when building custom plugin APIs, mobile app backends, or external integrations that need to pull course data, manage users, or handle quiz operations while respecting Moodle's permission system.

skills.sh installs
177
GitHub stars
33.2K
last updated
Aug 21, 2026

Install

$ npx -y skills add davila7/claude-code-templates --skill moodle-external-api-development --agent claude-code

Installs into .claude/skills of the current project.

Files

Moodle External API Development

This skill guides you through creating custom external web service APIs for Moodle LMS, following Moodle's external API framework and coding standards.

When to Use This Skill

  • Creating custom web services for Moodle plugins
  • Implementing REST/AJAX endpoints for course management
  • Building APIs for quiz operations, user tracking, or reporting
  • Exposing Moodle functionality to external applications
  • Developing mobile app backends using Moodle

Core Architecture Pattern

Moodle external APIs follow a strict three-method pattern:

  1. execute_parameters() - Defines input parameter structure
  2. execute() - Contains business logic
  3. execute_returns() - Defines return structure

Step-by-Step Implementation

Step 1: Create the External API Class File

Location: /local/yourplugin/classes/external/your_api_name.php

<?php
namespace local_yourplugin\external;

defined('MOODLE_INTERNAL') || die();
require_once("$CFG->libdir/externallib.php");

use external_api;
use external_function_parameters;
use external_single_structure;
use external_value;

Sponsors

Details

Repository
github.com/davila7/claude-code-templates
Categories
Backend & APIs, Debugging, Databases
First seen
Jun 3, 2026

More from davila7/claude-code-templates

All 618
1personamanagmentlayer avatargraphql-expertpersonamanagmentlayer/pclExpert-level GraphQL API development with schema design, resolvers, and subscriptions167skills.sh installs
2andrelandgraf avatarauthenticationandrelandgraf/fullstackrecipesComplete authentication system with Better Auth, email verification, password reset, protected routes, and account management.132skills.sh installs
3andrelandgraf avatarneon-drizzle-setupandrelandgraf/fullstackrecipesConnect a Next.js app to Neon Postgres using Drizzle ORM with optimized connection pooling for Vercel serverless functions.128skills.sh installs
4huangjia2019 avatarapi-conventionshuangjia2019/claude-code-engineeringAPI design patterns and conventions for this project. Covers RESTful URL naming, response format standards, error handling, and authentication requirements. Use0skills.sh installs
5supabase avatarsupabase-postgres-best-practicessupabase/agent-skillsPostgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres data479.8Kskills.sh installs
6prisma avatarprisma-computeprisma/skillsPrisma Compute deployment and hosting guide. Use whenever the user mentions Prisma Compute, `prisma.compute.ts`, `defineComputeConfig`, deploying or hosting a P399.3Kskills.sh installs