xAPI Statements

xAPI Statements HTTP Interface

The table below describes the routes that the HTTP interface provides, all of the URLs are relative to http://www.example.org/data/xAPI where http://www.example.org is the URL of your Learning Locker instance. To access this interface, you must additionally supply your Basic Auth details with each request in the Authorization header. Your Basic Auth details can be found under Settings > Clients.

If you receive an "unauthorised error" from this API, you can use the three checks below via the Client UI. To remove the need for these checks, Learning Locker will automatically create a new client when a new store is created, the new client is enabled by default, with the "All" scope, and the LRS set to the new store. To avoid unauthorised errors, try to use the new client and remember the checks below if you edit or create a client manually.

  1. Check that the client is enabled.

  2. Check that the "All" scope is selected under the "xAPI" heading.

  3. Check that an LRS is selected.

Go to the xAPI HTTP interface documentation to see the rest of the xAPI routes.

Route

Description

Route

Description

PUT /statements

Stores a single statement.

POST /statements

Stores a single statement or multiple statements.

GET /statements

Retrieves statements.

PUT /statements

This route allows you to create a single statement with a statement identifier in the URL parameters and the statement itself in the JSON body. A request to this API would look something like the request below.

PUT http://www.example.org/data/xAPI/statements?statementId=dfb7218c-0fc9-4dfc-9524-d497097de027 Authorization: YOUR_BASIC_AUTH X-Experience-API-Version: 1.0.3 Content-Type: application/json { "id": "dfb7218c-0fc9-4dfc-9524-d497097de027", "actor": { "mbox": "mailto:test@example.org" }, "verb": { "id": "http://www.example.org/verb" }, "object": { "id": "http://www.example.org/activity" } }

This route returns a 204 response with no content when the statement is successfully created, like the example response below.

HTTP/1.1 204 NO CONTENT X-Experience-API-Version: 1.0.3 X-Experience-API-Consistent-Through: 2017-08-31T15:16:29.709Z

For more information, view the PUT /statements route in the xAPI specification.

POST /statements

This route allows you to create a multiple statements with or without statement identifiers. A request to this API would look something like the request below.

POST http://www.example.org/data/xAPI/statements Authorization: YOUR_BASIC_AUTH X-Experience-API-Version: 1.0.3 Content-Type: application/json; charset=utf-8 [{ "id": "dfb7218c-0fc9-4dfc-9524-d497097de027", "actor": { "mbox": "mailto:test1@example.org" }, "verb": { "id": "http://www.example.org/verb" }, "object": { "id": "http://www.example.org/activity" } }, { "actor": { "mbox": "mailto:test2@example.org" }, "verb": { "id": "http://www.example.org/verb" }, "object": { "id": "http://www.example.org/activity" } }]

This route returns a 200 response with an array of statement identifiers when the statements are successfully created. A response from this route would look something like the response below.

For more information, view the POST /statements route in the xAPI specification.

GET /statements

This route allows you to retrieve a single statement or multiple statements. If the statementId or voidedStatementId URL parameters are set, it will retrieve a single statement with the given identifier, otherwise it will retrieve many statements. For more information, view the GET /statements route in the xAPI specification.

<iframe src="https://player.vimeo.com/video/168960744" width="80%" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="padding-left: 15%;"></iframe>

Single Statement

In addition to the statementId and voidedStatementId URL parameters (one of which must be set to retrieve a single statement), there are two additional optional parameters in the form of format and attachments. The format parameter defaults to "exact" if it's not set, the other options are "ids" (only includes minimal information) and "canonical" (only includes one language per language map). The attachments parameter is a boolean that determines if the statement's attachments are returned with the statement.

When getting a single statement successfully, this route will return a 200 response as shown below with the statement as the body of the request. If the single statement cannot be found, then this route will return a 404 response.

Many Statements

When retrieving multiple statements there are a number of optional URL parameters listed below that can be used to filter statements. All of the URL parameters should be URL encoded (after JSON encoding if JSON encoding is required).

Parameter

Description

Parameter

Description

agent

JSON encoded object containing an IFI to match an agent or group.

verb

String matching the statement's verb identifier.

activity

String matching the statement's object identifier.

registration

String matching the statement's registration from the context.

related_activities

Applies the activity filter to any activity in the statement when true. Defaults to false.

related_agents

Applies the activity filter to any agent/group in the statement when true. Defaults to false.

since

String that returns statements stored after the given timestamp (exclusive).

until

String that returns statements stored before the given timestamp (inclusive).

limit

Number of statements to return. Defaults to 0 which returns the maximum the server will allow.

format

String ("exact"/"ids"/"canonical") determining how much of the statement is returned. Defaults to "exact" to return the full statement.

attachments

Boolean determining if the statements' attachments should be returned. Defaults to false.

ascending

Boolean determining if the statements should be returned in ascending stored order. Defaults to false.

Below is an example of a request containing each of the URL parameters.

This route will return a 200 response as shown below where the JSON body of the response contains a more link and an array of statements that match the URL parameters. The more link can be used to retrieve the next page of statements, if there aren't any more pages of statements the more link will be an empty string.

 

Learning Locker and the Squirrel logo are trademark of Learning Pool 2020 | Learning Locker is licensed under GPL 3.0.