API access to content bank

API access to content bank

by Sebastian Rettig -
Number of replies: 4

Hi,

I‘m wondering if it is possible to access the H5P content bank through an API. I‘d like to upload content from an external application, but 8 haven’t found anything in the docs...

Sebastian

Average of ratings: -
In reply to Sebastian Rettig

Re: API access to content bank

by Daniel Thies -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Hi Sebastian,

The internal API for interacting with the content bank from a Moodle plugin is fairly well documented along with a tutorial for writing new content bank plugins that access that API. You can see how in is used in contentbank/upload.php. However, I do not know if that is what you mean.

If you are trying to access the content bank from an external system, you may be interested in the web services API. It looks like there are services for deleting and renaming a content, but not creating one. That could be added by means of a plugin or possibly a command line script could be made with the API above.

Daniel
In reply to Daniel Thies

Re: API access to content bank

by Sebastian Rettig -
Hi Daniel,

Thank you for your answer!

Yes, I was hoping for something like the Webservices API. I develop Lumi, which is a tool that allows creating H5P content offline in a desktop application. Being able to upload H5P content directly into the Moodle content bank would be a great new feature. As we are an external application, we can't change the code of the Moodle installation that would be accessed by our application. The idea would be to ask administrators, to enable the required webservices so that Lumi can access them. So I can only use standard webservice calls that already exist and can't customize any application.

However, I couldn't find any calls for the content bank in the list of API calls for the webservices. I see a few call that seem to work on regular content, but not on the content bank.

Sebastian
In reply to Sebastian Rettig

Re: API access to content bank

by Daniel Thies -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
That looks very cool. The web services do not exist, but it would not be hard to add as a plugin. Typically Moodle integrates with third party apps by means of adding a plugin and that plugin can be hosted in the Moodle plugin database that serves as the official store. The plugin could help with setting up the credentials (probably give users a token to enter on the desktop).

Before starting on that it would be worth thinking about what other services would be part of the integration. I might expect that you would also want download as well so that you would have the Moodle content bank available to open in the desktop app as well.
In reply to Sebastian Rettig

Re: API access to content bank

by Daniel Thies -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Actually I realized that there are services to add files to a user's Private files area that were created for the Moodle App. Those could be used to upload the H5P to the user's Private files area and then the user could add them from there to either the content bank or as an activity on a course page. That may be a good place to start.