API Guides
Moodle has a number of core APIs that provide tools for Moodle scripts.
They are essential when writing Moodle plugins.
Most-used General API
These APIs are critical and will be used by nearly every Moodle plugin.
Access API (access)
The Access API gives you functions so you can determine what the current user is allowed to do, and it allows modules to extend Moodle with new capabilities.
Data manipulation API (dml)
The Data manipulation API allows you to read/write to databases in a consistent and safe way.
File API (files)
The File API controls the storage of files in connection to various plugins.
Form API (form)
The Form API defines and handles user data via web forms.
Logging API (log)
The Events API allows you to log events in Moodle, while Logging 2 describes how logs are stored and retrieved.
Navigation API (navigation)
The Navigation API allows you to manipulate the navigation tree to add and remove items as you wish.
Page API (page)
The Page API is used to set up the current page, add JavaScript, and configure how things will be displayed to the user.
Output API (output)
The Output API is used to render the HTML for all parts of the page.
String API (string)
The String API is how you get language text strings to use in the user interface. It handles any language translations that might be available.
Upgrade API (upgrade)
The Upgrade API is how your module installs and upgrades itself, by keeping track of its own version.
Moodlelib API (core)
The Moodlelib API is the central library file of miscellaneous general-purpose Moodle functions. Functions can over the handling of request parameters, configs, user preferences, time, login, mnet, plugins, strings and others. There are plenty of defined constants too.
Other General API
Admin settings API (admin)
The Admin settings API deals with providing configuration options for each plugin and Moodle core.
Admin presets API (adminpresets)
The Admin presets API allows plugins to make some decisions/implementations related to the Site admin presets.
Analytics API (analytics)
The Analytics API allow you to create prediction models and generate insights.
Availability API (availability)
The Availability API controls access to activities and sections.
Backup API (backup)
The Backup API defines exactly how to convert course data into XML for backup purposes, and the Restore API describes how to convert it back the other way.
Cache API (cache)
The The Moodle Universal Cache (MUC) is the structure for storing cache data within Moodle. Cache API explains some of what is needed to use a cache in your code.
Calendar API (calendar)
The Calendar API allows you to add and modify events in the calendar for user, groups, courses, or the whole site.
Check API (check)
The Check API allows you to add security, performance or health checks to your site.
Comment API (comment)
The Comment API allows you to save and retrieve user comments, so that you can easily add commenting to any of your code.
Competency API (competency)
The Competency API allows you to list and add evidence of competencies to learning plans, learning plan templates, frameworks, courses and activities.
Data definition API (ddl)
The Data definition API is what you use to create, change and delete tables and fields in the database during upgrades.
Editor API
The Editor API is used to control HTML text editors.
Enrolment API (enrol)
The Enrolment API deals with course participants.
Events API (event)
The Events API allows to define "events" with payload data to be fired whenever you like, and it also allows you to define handlers to react to these events when they happen. This is the recommended form of inter-plugin communication. This also forms the basis for logging in Moodle.
Experience API (xAPI)
The Experience API (xAPI) is an e-learning standard that allows learning content and learning systems to speak to each other. The Experience API (xAPI) allows any plugin to generate and handle xAPI standard statements.
External functions API (external)
The External functions API allows you to create fully parametrised methods that can be accessed by external programs (such as Web services).
Favourites API
The Favourites API allows you to mark items as favourites for a user and manage these favourites. This is often referred to as 'Starred'.
H5P API (h5p)
The H5P API allows plugins to make some decisions/implementations related to the H5P integration.
Lock API (lock)
The Lock API lets you synchronise processing between multiple requests, even for separate nodes in a cluster.
Message API (message)
The Message API lets you post messages to users. They decide how they want to receive them.