Web services FAQ
This document lists some popular questions from the Web Services forum.
What is the difference between web services and MNet
MNet is used to authenticate some users from a Moodle A site into a Moodle B site.
Web services are functions that can be called by external applications (via SOAP, XML-RPC, REST or AMF).
I see the term "Web services" used in different ways, what does it mean?
- The entire system in Moodle is referred to as the Moodle Web Service system.
- A particular action (like creating a user) is known as a Web service function.
- The admin can enable groups of these functions for outside use, and these are known as a "Web service".
Where is the Web Service API documented?
Since different Moodle sites can extend or restrict the API, and the API will evolve over time, the best way to see the exact API for a particular Moodle site is to look at the automatically generated documentation.
Full API documentation
- Connect as admin
- Go to Administration Settings block > Plugins > Web services > API documentation
Specific documentation to a user
- Connect as admin, enable web service, create a service and add some Moodle functions to it. Also see How_to_create_and_enable_a_web_service.
- connect as non admin, and access the service documentation on your security keys page.
Why are there not many functions in the API?
We have been very careful when adding new functions because we don't want to be changing the API functions once they are implemented. The ones we have in Moodle 2.0 are the most commonly requested ones (for users, courses, groups and enrolments).
We will add more functions to core over time, based on contributions from the community and feature requests. See the web service roadmap.
You can also extend the API on your own Moodle site by creating your own API functions (see next question).
How can I create a new web service function?
The easiest and recommended way to add a web service is to write a new Moodle local plugin and to implement the web service functions there. The Moodle administrator will just need to add the plugin in Moodle (copy the files in /local/), the web service functions will be automatically added. Please read /local/readme.txt for more information about plugin development. Finally read how to implement a web service and a web service function.
How can I set up a web service?
- See the document How to create and enable a web service.
- Settings > Site administration > Plugins > Web services > Overview explains two use cases.
- Finally ask questions on the Web Services forum
Does the Moodle SOAP server work with JAVA or .NET?
How to get a user token from an external application?
In Moodle 2.2 you can generate and retrieve user tokens with the /login/token.php file => How to get a user token
The condition being that the service need a shortname. At the moment a service can have a shortname if you:
- create the service as a built-in service (in db/services.php files)
- add the shortname manually in the DB. Note: we'll add the admin UI for shortname later (MDL-30229)
Just for the info, the file login/token.php exists since 2.1 but for this Moodle version it can only generate token for the mobile service.
- Using Moodle Web Services forum