In order for data interoperability with xAPI to be effective, xAPI data regardless of where it is coming from must conform to the xAPI specification. Additionally, Learning Record Stores must also conform to the xAPI specification. The Advanced Distributed Learning Initiative provides the xAPI LRS Test Suite, a series of over 1300 tests that an LRS must pass to be conformant. The list of xAPI conformant LRSes can be found here. While there are only a few steps necessary to perform xAPI statement forwarding from one xAPI conformant LRS to another xAPI conformant LRS, the automation of these steps will require some knowledge of programming.
Step 1, Get data from an xAPI conformant xAPI LRS
To get started, we need to identify and retrieve the data we care about. There are several ways we can identify the xAPI data we care about but typically we are going to want to identify our data by when the xAPI statement occurred. By identifying our data by its timestamp, we can ensure we do not accidentally send duplicate data. This will also allow us to programmatically increment the date ranges we are looking for when the process becomes automated.
To actually get the data out of an xAPI conformant LRS like the Yet xAPI LRS, we are going to utilize the statement resource endpoint (http(s)://.../xapi/statements). We need to perform a GET request in which we specify the “since” and “until” query parameter. These parameters should be ISO 8601 timestamps as required by the xAPI specification. We will also need the appropriate information for communicating with an LRS via RESTful requests. For the Yet Analytics LRS, here is a walkthrough on how this information can be found. Once you have your endpoint URL, API key, API key secret and have determined your time range, we can make a request to the LRS to get our xAPI statements. Below is an example of making a GET request using the application Postman.
The screenshot below uses the application Postman to make the GET request from a trial instance of the Yet xAPI LRS.
Step 2, Send data to an xAPI conformant LRS
Now that we have our data, we can send it to another xAPI conformant LRS. This is done by making a POST request to the receiving LRS. To create our POST request, we will need our endpoint, API key, API key secret and our xAPI data. The array of statements we received from our GET request will be used as the body of our POST request. We only want to send the array, this means we will need to reach into the JSON object and get the data located at the “statements” key.
The screenshot below uses the application Postman to make the POST request from a production instance of the Yet xAPI LRS. You’ll notice the difference in the endpoint after the scheme where you’ll see “trial-lrs.yet” vs. “lrs.yet.”
Step 3, Programmatically repeat step 1 and 2 as necessary
The previous two steps are the only things required to get data from one xAPI conformant LRS to another xAPI conformant LRS. In order to make this an automated process, a program will need to work like this:
- Make the first GET request with since and until parameters set.
- Parse the body of the response, grabbing the array containing the statements.
- The response of the first GET request will contain a “more” key with an IRI fragment within the body of the response. Your program will need to update the endpoint to account for this. The IRI fragment will look similar to “/xapi/statements?as-of=2105&page=1.”
- The new endpoint for the second GET request will then be similar to “https://(trial-)lrs.yetanalytics.io/xapi/statements?as-of=2105&page=1”
- This process will need to be repeated until the value of the “more” key is an empty string. This indicates that all statements for a given time range have been retrieved.
- If too large of a time range is specified, all statements within that time range will not be returned within the body, only a subset of them. To get the rest of the statements, your program will need to make another GET request.
- Once you have all your statements for the starting time range, you will need to create the POST request as outlined here under Step 2 “Send data to an xAPI conformant LRS.” This will conclude the transfer of the first batch of statements from the Yet LRS to another xAPI conformant LRS.
- To automate this process, your program will need to increment the since and until parameters by some unit of time. The amount is up to you and the best value to increment by is determined by how spread out your statements are over time. You will then need to repeat steps 1-3, including following all more links to ensure no data is lost in the transfer.
If you have any questions about this process, please reach out to firstname.lastname@example.org.