Web service API functions
From MoodleDocs
Moodle 2.0
Implemented |
Must be implemented |
Suggested |
Web service protocols
Name | Moodle Ver. | Description | Issue |
---|---|---|---|
AMF | 2.0 | Adobe protocol to communicate with Flash/Flex apps | |
REST (returning XML) | 2.0 | XML data accessed through a REST API (not restful) | |
REST (returning JSON) | 2.2 | JSON data accessed through a REST API (not restful) | MDL-29242 |
REST (returning JSONP) | 2.X | Would be very useful for client-side JavaScript | MDL-29913 |
JSON | 2.X | JSON server receives a JSON encoded params and return JSON encoded values. | MDL-21341 |
SOAP | 2.0 | Very important for interoperating with Java and .Net applications. There was a partial implementation JAVA/.Net in Moodle 2.0, but it does not work for anything but the most trivial functions. It is fully working with PHP clients. | MDL-20804, MDL-28988, MDL-28989 |
XMLRPC | 2.0 | XML remote-procedure call. |
Web service functions
Naming convention
We updated (regularised) the naming convention in Moodle 2.2. See MDL-29106 for those details.
All functions should be named as follows:
- wsfunction = fullcomponent_methodname
- fullcomponent = frankenstyle (eg core_xxxx or mod_xxx etc)
- methodname = verb_noun(s)
- verb = get|create|delete|update
- noun = moodle objects, usually plural (eg posts, discussions, users, courses etc)
Core web service functions
Area | Moodle 2.2 name | Moodle 2.0/2.1 name | Introduced in | Description | Issue |
---|---|---|---|---|---|
user | core_user_create_users() | moodle_user_create_users() | 2.0 | Create users - admin function | |
user | core_user_delete_users() | moodle_user_delete_users() | 2.0 | Delete users - admin function | |
user | core_user_update_users() | moodle_user_update_users() | 2.0 | Update users | |
user | core_user_get_users_by_id() | moodle_user_get_users_by_id() | 2.0 | Get users by id | |
user | core_user_get_course_user_profiles() | moodle_user_get_course_participants_by_id() | 2.1 | Get course user profiles by id | |
cohort | core_cohort_create_cohorts() | 2.4 | Create cohorts | MDL-29472 | |
cohort | core_cohort_update_cohorts() | 2.4 | Update cohorts | MDL-29472 | |
cohort | core_cohort_delete_cohorts() | 2.4 | Delete cohorts | MDL-29472 | |
cohort | core_cohort_get_cohorts() | 2.4 | Get cohorts | MDL-29472 | |
cohort | core_cohort_add_cohort_members() | 2.4 | Add members to cohort | MDL-29472 | |
cohort | core_cohort_delete_cohort_members() | 2.4 | Delete members from cohort | MDL-29472 | |
cohort | core_cohort_get_cohort_members() | 2.4 | Get cohort members | MDL-29472 | |
course | core_course_get_courses() | moodle_course_get_courses() | 2.0 | Return course details | |
course | core_course_create_courses() | moodle_course_create_courses() | 2.0 | Create new courses | |
course | core_course_search_courses | 3.0 | Search courses by (name, module, block, tag). | MDL-49942 | |
group | core_group_create_groups() | moodle_group_create_groups() | 2.0 | Creates new groups | |
group | core_group_get_groups() | moodle_group_get_groups() | 2.0 | Returns group details. | |
group | core_group_get_course_groups() | moodle_group_get_course_groups() | 2.0 | Returns all groups in specified course | |
group | core_group_delete_groups() | moodle_group_delete_groups() | 2.0 | Deletes all specified groups | |
group | core_group_get_group_members() | moodle_group_get_groupmembers() | 2.0 | Returns group members | |
group | core_group_add_group_members() | moodle_group_add_groupmembers() | 2.0 | Adds group members | |
group | core_group_delete_group_members() | moodle_group_delete_groupmembers() | 2.0 | Deletes group members | |
role | core_role_assign_roles() | moodle_role_assign() | 2.0 | Manual role assignments | |
role | core_role_unassign_roles() | moodle_role_unassign() | 2.0 | Manual role unassignments | |
enrol | NONE | moodle_enrol_get_enrolled_users() | 2.0 | get some minimal information about the users enrolled in a course (DEPRECATED) | |
enrol | core_enrol_get_enrolled_users() | moodle_user_get_users_by_courseid() | 2.1 | Get enrolled users by course id | |
enrol | core_enrol_get_users_courses() | moodle_enrol_get_users_courses() | 2.0 | get list of course ids that a user is enrolled in (if you are allowed to see that) | |
enrol/manual | enrol_manual_enrol_users() | moodle_enrol_manual_enrol_users() | 2.0 | Manual enrol users | |
webservice | core_webservice_get_site_info() | moodle_webservice_get_siteinfo() | 2.1 | Return some site info / user info / list web service functions | |
message | core_message_send_instant_messages() | moodle_message_send_instantmessages() | 2.1 | Send instant messages | |
notes | core_notes_create_notes() | moodle_notes_create_notes() | 2.1 | Create notes | |
notes | core_notes_delete_notes() | 2.5 | Delete Notes | MDL-30072 | |
notes | core_notes_get_notes() | 2.5 | Retrieve Notes | MDL-30072 | |
notes | core_notes_update_notes() | 2.5 | Update Notes | MDL-30072 | |
files | core_files_get_files() | moodle_file_get_files() | 2.0 | browse moodle files | |
files | core_files_upload() | moodle_file_upload() | 2.0 | upload a file to moodle (DEPRECATED) | |
course | core_course_get_contents() | 2.2 | get course content (modules + web service file urls) | MDL-28646 | |
course | core_course_delete_courses() | 2.3 | delete courses | MDL-13130 | |
course | core_course_duplicate_course() | 2.3 | duplicate a course | MDL-32233 | |
course | core_course_get_categories() | 2.3 | get categories | MDL-32941 | |
course | core_course_update_categories() | 2.3 | update categories | MDL-32941 | |
course | core_course_create_categories() | 2.3 | create categories | MDL-32941 | |
course | core_course_delete_categories() | 2.3 | delete categories | MDL-32941 | |
group | core_group_create_groupings() | 2.3 | create groupings | MDL-32662 | |
group | core_group_update_groupings() | 2.3 | update groupings | MDL-32662 | |
group | core_group_get_groupings() | 2.3 | get groupings | MDL-32662 | |
group | core_group_delete_groupings() | 2.3 | delete groupings | MDL-32662 | |
group | core_group_assign_grouping() | 2.3 | assign groups from groupings | MDL-32662 | |
group | core_group_unassign_grouping() | 2.3 | unassign groups from groupings | MDL-32662 | |
group | core_group_get_course_groupings() | 2.3 | get all groupings in specified course | MDL-32662 | |
user | core_user_get_users_by_field() | 2.5 | Retrieve users information for a specified unique field - If you want to do a user search, use core_user_get_users() | MDL-35543 | |
enrol | core_enrol_get_enrolled_users_with_capability() | 2.4 | For each course and capability specified, return a list of the users that are enrolled in the course and have that capability | MDL-31859 | |
course | core_course_import_course() | 2.4 | Import course data from a course into another course. Does not include any user data. | MDL-32919 | |
message | core_message_create_contacts() | 2.5 | Add contacts to the contact list | MDL-30070 | |
message | core_message_delete_contacts() | 2.5 | Remove contacts from the contact list | MDL-30070 | |
message | core_message_block_contacts() | 2.5 | Block contacts | MDL-30070 | |
message | core_message_unblock_contacts() | 2.5 | Unblock contacts | MDL-30070 | |
message | core_message_get_contacts() | 2.5 | Retrieve the contact list | MDL-30070 | |
message | core_message_search_contacts() | 2.5 | Search for contacts | MDL-30070 | |
external | core_get_string() | 2.4 | Return a translated string - similar to core get_string() call | MDL-35997 | |
external | core_get_component_strings() | 2.4 | Return all raw strings (with {$a->xxx}) for a specific component - similar to core get_component_strings() call | MDL-35997 | |
external | core_get_strings() | 2.4 | Return some translated strings - like several core get_string() calls | MDL-35997 | |
calendar | core_calendar_delete_calendar_events() | 2.5 | Delete calendar events | MDL-37077 | |
calendar | core_calendar_get_calendar_events() | 2.5 | Get calendar events | MDL-37100 | |
calendar | core_calendar_create_calendar_events() | 2.5 | Create calendar events | MDL-37101 | |
mod_assign | mod_assign_get_grades() | 2.4 | Returns grades from the assignment | MDL-31873 | |
mod_assign | mod_assign_get_assignments() | 2.4 | Returns the courses and assignments for the users capability | MDL-31873 | |
mod_assign | mod_assign_get_submissions | 2.5 | Returns the submissions for assignments | MDL-31682 | |
mod_assign | mod_assign_get_user_flags | 2.6 | Returns the user_flags for assignments | MDL-40548 | |
mod_assign | mod_assign_set_user_flags | 2.6 | Sets the specified user_flags for an assignment | MDL-41738 | |
mod_assign | mod_assign_get_user_mappings | 2.6 | Returns the user_mappings for assignments | MDL-40548 | |
mod_assign | mod_assign_revert_submissions_to_draft | 2.6 | Reverts the list of submissions to draft status | MDL-37148 | |
mod_assign | mod_assign_lock_submissions | 2.6 | Prevent students from making changes to a list of submissions | MDL-37148 | |
mod_assign | mod_assign_unlock_submissions | 2.6 | Allow students to make changes to a list of submissions | MDL-37148 | |
mod_assign | mod_assign_save_submission | 2.6 | Update the current students submission | MDL-37148 | |
mod_assign | mod_assign_submit_for_grading | 2.6 | Submit the current students assignment for grading | MDL-37148 | |
mod_assign | mod_assign_save_grade | 2.6 | Save a grade update for a single student. | MDL-37148 | |
mod_assign | mod_assign_save_grades | 2.7 | Save grade updates for one or more students. | MDL-42425 | |
mod_assign | mod_assign_save_user_extensions | 2.6 | Save a list of assignment extensions | MDL-37148 | |
mod_assign | mod_assign_reveal_identities | 2.6 | Reveal the identities for a blind marking assignment | MDL-37148 | |
mod_book | mod_book_view_book | 3.0 | Trigger the course module viewed event and update the module completion status. | MDL-50013 | |
mod_chat | mod_chat_get_chats_by_courses | 3.0 | Returns a list of chat instances in a provided set of courses. | MDL-50537 | |
mod_chat | mod_chat_view_chat | 3.0 | Trigger the course module viewed event and update the module completion status. | MDL-50853 | |
mod_chat | mod_chat_login_user | 3.0 | Log a user into a chat room in the given chat. | MDL-50853 | |
mod_chat | mod_chat_get_chat_users | 3.0 | Get the list of users in the given chat session. | MDL-50853 | |
mod_chat | mod_chat_send_chat_message | 3.0 | Send a message on the given chat session. | MDL-50853 | |
mod_chat | mod_chat_get_chat_latest_messages | 3.0 | Get the latest messages from the given chat sessio. | MDL-50853 | |
mod_choice | mod_choice_get_choices_by_courses | 3.0 | Returns a list of choice instances in a provided set of courses. | MDL-50132 | |
mod_choice | mod_choice_get_choice_results | 3.0 | Retrieve users results for a given choice. | MDL-50944 | |
mod_choice | mod_choice_get_choice_options | 3.0 | Retrieve options for a specific choice. | MDL-50944 | |
mod_choice | mod_choice_submit_choice_response | 3.0 | Submit responses to a specific choice item. | MDL-50944 | |
mod_choice | mod_choice_view_choice | 3.0 | Trigger the course module viewed event and update the module completion status.. | MDL-50944 | |
mod_choice | mod_choice_delete_choice_responses | 3.0 | Delete the given submitted responses in a choice. | MDL-50944 | |
mod_data | mod_data_get_databases_by_courses() | 2.9 | Returns a list of database instances in a provided set of courses, if no courses are provided then all the database instances the user has access to will be returned. | MDL-49337 | |
mod_folder | mod_folder_view_folder | 3.0 | Trigger the course module viewed event and update the module completion status. | MDL-50008 | |
mod_forum | mod_forum_get_forums_by_courses | 2.5 | Returns a list of forum instances in a provided set of courses, if no courses are provided then all the forum instances the user has access to will be returned. | MDL-37247 | |
mod_forum | mod_forum_get_forum_discussion_posts() | 2.7 | Returns a list of forum posts for a discussion. | MDL-30106 | |
mod_forum | mod_forum_get_forum_discussions_paginated() | 2.8 | Returns a list of forum discussions optionally sorted and paginated. | MDL-46458 | |
mod_forum | mod_forum_view_forum() | 2.9 | Trigger the course_module_viewed event when a user view a forum (this web service will be initially used by the mobile app so information can be logged in the Moodle side when a user see the same page in the app). | MDL-49502 | |
mod_forum | mod_forum_view_forum_discussion() | 2.9 | Trigger the discussion_viewed event when a user view a forum discussion (this web service will be initially used by the mobile app so information can be logged in the Moodle side when a user see the same page in the app). | MDL-49503 | |
mod_forum | mod_forum_get_forum_discussions | 2.5 | Returns a list of forum discussions in a provided set of forums. (DEPRECATED use mod_forum_get_forum_discussions_paginated instead) | MDL-30102 | |
mod_imscp | mod_imscp_view_imscp | 3.0 | Trigger the course module viewed event and update the module completion status. | MDL-50015 | |
mod_page | mod_page_view_page | 3.0 | Trigger the course module viewed event and update the module completion status. | MDL-49791 | |
mod_resource | mod_resource_view_resource | 3.0 | Trigger the course module viewed event and update the module completion status. | MDL-49792 | |
mod_scorm | mod_scorm_get_scorms_by_courses | 3.0 | Returns a list of scorm instances in a provided set of courses. | MDL-50349 | |
mod_scorm | mod_scorm_view_scorm | 3.0 | Trigger the course module viewed event and update the module completion status.. | MDL-50427 | |
mod_scorm | mod_scorm_get_scorm_attempt_count | 3.0 | Return the number of attempts done by a user in the given SCORM. | MDL-51017 | |
mod_scorm | mod_scorm_get_scorm_sco_tracks | 3.0 | Retrieves SCO tracking data for the given user id and attempt number. | MDL-50557 | |
mod_scorm | mod_scorm_insert_scorm_tracks | 3.0 | Saves a scorm tracking record. | MDL-50353 | |
mod_scorm | mod_scorm_get_scorm_user_data | 3.0 | Retrieves user tracking and SCO data and default SCORM values. | MDL-50352 | |
mod_scorm | mod_scorm_get_scorm_scoes | 3.0 | Returns a list containing all the scoes data related to the given scorm id. | MDL-50351 | |
mod_url | mod_url_view_url | 3.0 | Trigger the course module viewed event and update the module completion status. | MDL-49793 | |
course | core_course_update_courses() | 2.5 | Update courses. | MDL-30062 | |
user | core_user_get_users() | 2.5 | Search users. - If you want to get multiple users for one specific field, use core_user_get_users_by_field(), it's designed for this purpose and it should be faster. | MDL-29938 | |
grade | core_grade_get_definitions() | 2.5 | Returns grading definitions for the course module ids and areaname provided as parameters. An optionall activeonly parameter can be provided so that only the active grading method is returned. Will be deprecated and replaced by core_grading_get_definitions in 2.6 | MDL-31681 | |
grade | core_grade_get_grades() | 2.7 | Returns student course total grade and grades for activities. This function does not return category or manual items. This function is suitable for managers or teachers not students. | MDL-30085 | |
grade | core_grade_update_grades() | 2.7 | Update a grade item and associated student grades. | MDL-30085 | |
grading | core_grading_get_definitions() | 2.6 | Returns grading definitions for the course module ids and areaname provided as parameters. An optionall activeonly parameter can be provided so that only the active grading method is returned. | MDL-31890 | |
grading | core_grading_get_gradingform_instances() | 2.6 | Returns the instances and fillings for the requested definition id. An optional since parameter allows the number of records returned to be reduced so that only those with a timemodified value >= since are returned | MDL-31890 | |
grading | core_grading_save_definitions() | 2.8 | Accepts an array of areas as a parameter. The areas contain grading definitions with criteria for inserting and updating | MDL-31861 | |
comment | core_comment_get_comments() | 2.9 | Return all the comments for an specific component, context. | MDL-49203 | |
completion | core_completion_get_activities_completion_status() | 2.9 | Return the activities completion status for a user in a course. | MDL-49314 | |
completion | core_completion_get_course_completion_status() | 2.9 | Returns course completion status. | MDL-49313 | |
completion | core_completion_update_activity_completion_status_manually() | 2.9 | Update completion status for the current user in an activity, only for activities with manual tracking. | MDL-49444 | |
course | core_course_view_course() | 2.9 | Log that the course was viewed | MDL-49453 | |
group | core_group_get_course_user_groups() | 2.9 | Returns all groups in specified course for the specified user. | MDL-48730 | |
message | core_message_get_messages() | 2.8 | Retrieve a list of messages sent and received by a user (conversations, notifications or both) | MDL-45374 | |
message | core_message_mark_message_read() | 2.9 | Mark a single message as read, trigger message_viewed event. | MDL-49501 | |
notes | core_notes_view_notes() | 2.9 | Simulates the web interface view of notes/index.php: trigger events. | MDL-49504 | |
rating | core_rating_get_item_ratings() | 2.9 | Retrieve all the ratings for an item. | MDL-49347 | |
user | core_user_add_user_device() | 2.6 | Store mobile user devices information for PUSH Notifications. | MDL-41914 | |
user | core_user_remove_user_device() | 2.9 | Remove a user device from the Moodle database. | MDL-48716 | |
user | core_user_view_user_list() | 2.9 | Simulates the web-interface view of user/index.php (triggering events). | MDL-49498 | |
user | core_user_view_user_profile() | 2.9 | Simulates the web-interface view of user/view.php and user/profile.php (triggering events). | MDL-49499 | |
grade_report | gradereport_user_get_grades_table() | 2.9 | Get the user/s report grades table for a course | MDL-49036 | |
grade_report | gradereport_user_view_grade_report() | 2.9 | Trigger the grade_report_viewed event when a user view his grade report (this web service will be initially used by the mobile app so information can be logged in the Moodle side when a user see the same page in the app). | MDL-49500 | |
message | core_message_get_blocked_users() | 2.9 | Retrieve a list of users blocked | MDL-48719 | |
course | core_course_delete_modules() | 2.5 | Deletes all specified module instances | MDL-30098 | |
notes | core_notes_get_course_notes() | 2.9 | Returns all notes in specified course (or site) for the specified user. | MDL-49330 |
This is the list of the integrated core functions. To see the roadmap, see to the tracker issue in the section bellow.
API Roadmap
Tracker issue: MDL-29934