So you’ve got your LRS set up, and it’s doing a great job of storing your activity data, and your dashboards are looking great. But how do you actually gain more detailed insights into the data? Well, in this post we’ll be having a quick look at ways in which you can query xAPI statements – or more specifically the Statement API.

Before you get started, you’ll need a suitable API query builder such as Postman.  You might also find it useful to watch along with this video if you’re unfamiliar with the interface.

Querying the Statement API

The statement API allows you to create statements and retrieve one or many statements that you previously created.

Creating a Statement

You can create a statement with the following request.

POST https://v2.learninglocker.net/v1/data/xAPI/statements

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

Content-Type:application/json

Body

{    “actor”:{        “objectType”:”Agent”,        “name”:”John Smith”,        “account”:{            “name”:”123″,            “homePage”:”http://www.example.com/users/”        }    },    “verb”:{        “id”:”http://adlnet.gov/expapi/verbs/completed”,        “display”:{            “en-GB”:”completed”        }    },    “object”:{        “objectType”:”Activity”,        “id”:”http://www.example.com/activities/1″    } }

Response

[

 “af2f7cc3-5b4f-4032-8449-6edaf8f98fb7”

]

Querying Known Statement IDs

Using the statement ID that the LRS provides you in response to creating a statement, you can query the statement from the API, with the following request.

GET https://v2.learninglocker.net/v1/data/xAPI/statements?statementId=af2f7cc3-5b4f-4032-8449-6edaf8f98fb7

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

Multiple Statement Queries

If you want to query multiple statements, you can create the following request.

GET https://v2.learninglocker.net/v1/data/xAPI/statements?verb=http://adlnet.gov/expapi/verbs/completed

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

Additional xAPI Queries

So there you have just 3 example queries that you can run on your xAPI data. For further details on which parts of a statement can be queried, check out the official specification documentation.  

Next up, we’ll be taking a look at how to void xAPI Statements.

– – –

For more practical tips on the xAPI, check out our free Learning Technology Manager’s Guide to xAPI