General developer forum

An RRA: Real RESTful API

Picture of Frédéric Massart
An RRA: Real RESTful API
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developersGroup Testers

Those who use and have used the Moodle Webservices will know that it can be rather painful. Amongst other things, the lack of use of HTTP methods (GET, POST, DELETE, ...) and the lack of HTTP status codes. Getting a "200 OK" response when a resource does not exist, or when the token is invalid is not quite right.

It has been a while since I thought I could hack something together which would define decent URLs while using the existing external API functions. And so I did! I spent the last two days playing with this. The plan was to put together a working prototype in order to assess whether my plans were realistic, and if yes, have a proof of concept to show.

Can't wait? Check out the README on Github.

Essentially, the plugin defines routes and HTTP methods which call existing external API functions. It's slightly more challenging than this, it's unfortunately not a one to one operation. Parameters need to be mapped to fit with the external API. The external API may not return the data in the format that we need. And most importantly, the HTTP status codes must be hand-picked for each operation and result in order to be useful.

I've put together some operations for courses and would love to hear your feedback.

> The repo is here <

Average of ratings: Useful (4)