How to Query an LRS to get xAPI Statements

30 June 2016 by Ryan Smith

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.



Authorization:Basic YOUR_BASIC_AUTH




{    “actor”:{        “objectType”:”Agent”,        “name”:”John Smith”,        “account”:{            “name”:”123″,            “homePage”:””        }    },    “verb”:{        “id”:””,        “display”:{            “en-GB”:”completed”        }    },    “object”:{        “objectType”:”Activity”,        “id”:”″    } }





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.



Authorization:Basic YOUR_BASIC_AUTH


Multiple Statement Queries

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



Authorization:Basic YOUR_BASIC_AUTH


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

Ryan Smith
Software Development Team Lead

Starting as a placement student in 2014, Ryan re-joined the Learning Locker team after graduating from Oxford Brookes University where he won the John Birch prize for the highest grade average in the University.

From his minimalist desk, Ryan leads the Learning Locker team and consults with people on all things xAPI to conscientiously craft products and services that sustain and evolve training and performance.

When he’s not swimming or injuring himself on the cricket field, Ryan enjoys playing funny (and usually inappropriate) games with his family.

Read more about Learning Pool
Visit our Learn and Connect section

Get a free demo

Get in touch to find out how we can help

Start your journey to extraordinary

Your time is valuable, so the more information you can give us, the better we can make your first contact.