Moodle has a number of core APIs that provide tools for Moodle scripts.
They are essential when writing Moodle plugins.
- 1 Most-used General APIs
- 2 Other General APIs
- 2.1 Backup API (backup)
- 2.2 Calendar API (calendar)
- 2.3 Comment API (comment)
- 2.4 Data definition API (ddl)
- 2.5 Events API (event)
- 2.6 External functions API (external)
- 2.7 Message API (message)
- 2.8 Preference API (preference)
- 2.9 Portfolio API (portfolio)
- 2.10 Rating API (rating)
- 2.11 RSS API (rss)
- 2.12 Tag API (tag)
- 2.13 Time API (time)
- 2.14 Unit test API (test)
- 2.15 Web services API (webservice)
- 3 Activity module APIs
- 4 See also
Most-used General APIs
These APIs are very 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 allow 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 Logging API allows you to add new entries to the Moodle log and define how they get displayed in reports.
The Navigation API allows you to manipulate the navigation tree to add and remove items as you wish.
Page API (page)
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 it's own version.
Other General APIs
Backup API (backup)
Calendar API (calendar)
The Calendar API allows you to add and modify events in the calendar for user, groups, courses, or the whole 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.
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.
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.
External functions API (external)
Message API (message)
The Message API lets you post messages to users. They decide how they want to receive them.
Preference API (preference)
The Preference API is a simple way to store and retrieve preferences for individual users.
Portfolio API (portfolio)
The Portfolio API allows you to add portfolio interfaces on your pages and allows users to package up data to send to their portfolios.
Rating API (rating)
The Rating API lets you create AJAX rating interfaces so that users can rate items in your plugin. In an activity module, you may choose to aggregate ratings to form grades.
RSS API (rss)
The RSS API allows you to create secure RSS feeds of data in your module.
Tag API (tag)
The Tag API allows you to store tags (and a tag cloud) to items in your module.
Time API (time)
The Time API takes care of translating and displaying times between users in the site.
Unit test API (test)
The Unit test API is based on Simpletest (shortly we are switching to PHP unit). Ideally all new code should have unit tests written FIRST.
Web services API (webservice)
The Web services API allows you to expose particular functions (usually external functions) as web services.
Activity module APIs
Activity modules are the most important plugin in Moodle. There are several core APIs that service only Activity modules.
Activity completion API (completion)
The Activity completion API is to indicate to the system how activities are completed.
Advanced grading API (grading)
The Advanced grading API allows you to add more advanced grading interfaces (such as rubrics) that can produce simple grades for the gradebook.
Conditional activities API (condition)
The Conditional activities API is so you can tell the system how to show or hide the activity automatically.
Groups API (group)
The Groups API allows you to check the current activity group mode and set the current group.
Gradebook API (grade)
The Gradebook API allows you to read and write from the gradebook. It also allows you to provide an interface for detailed grading information.
Plagiarism API (plagiarism)
The Plagiarism API allows your activity module to send files and data to external services to have them checked for plagiarism.
Question API (question)
The Question API (which can be divided into the Question bank API and the Question engine API), can be used by activities that want to use questions from the question bank.