Skip to content

AJAX Endpoint

Sebastian Rettig edited this page Sep 4, 2019 · 4 revisions

The Ajax-Endpoint is the endpoint that the Editor uses to load and save data from the server. Instead of providing different endpoints the H5P-Team used one endpoint which can be configured via the ajaxPath-field in the Editor-Integration-Object

As far as my research goes, it works like this:

GET or POST /ajaxPath?action=

1. Get Content-Type-Cache

Method: GET /ajaxPath?action=content-type-cache

Response:

{
"outdated": boolean,
"libraries": Array<Library>
}

Example

2. Get Libraries

Method: GET /ajaxPath?action=libraries?machineName=<machine_name>&majorVersion=<major_version>&minorVersion=<minor_version>

Response:

{
"semantics": LibrarySemantics,
"language": LibraryLanguage,
"javascript": Array<JSDependency>,
"css": Array<CSSDependency>,
"translation": LibraryTranslation
}

3. Post Libraries

Method: POST /ajaxPath?action=libraries

Body:

Array<LibraryName>

Example: ["H5P.AdvancedText 1.1", "H5P.AppearIn 1.0"]

Response:

Array<Library>

4. Post files

Method: POST /ajaxPath?action=files

Body: file

Response:

{
mime: MimeType,
path: Path
}

I hope this makes it a little bit clearer and helps you understand how the H5P-Editor works. There might be other mechanisms that I am not aware of, so please feel free to contribute and share your knowledge about the H5P-Structure.