LilxAPI (or Lil' xAPI) is a simpler, flat version of an xAPI statement that allows it to be easily stored in a finite data structure, such as a spreadsheet or single table of a SQL database. In this simplified approach, each statement is required to have only three properties: actor, verb, and object. Each property is limited to a single value. Statements may be represented either as a JSON object with name-value pairs or as an array of values (using the numeric array keys provided in Table 1).
Table 1
Overview of the LilxAPI structure
name | description | value format | default | example | array key |
---|---|---|---|---|---|
actor | The identity of the actor. | string | required | "janedoe@fake.com, Jane Doe" "janedoe@fake.com" "Jane Doe" or "janedoe1234" or "1234" | 0 |
verb | The action performed by the actor. | human-readable term | required | "completed", "clicked", "interacted", "viewed", "answered", etc. | 1 |
object | The target of the statement or what the actor interacted with. | url | required | "https://edtechbooks.org/education_research/research" | 2 |
result | The outcome of the action. | float boolean string | null | .75 true "success" | 3 |
context | Contextual information about the action. | string | null | "web" "app" | 4 |
language_id | The language of the schema. | ISO 639-1 Format | en | "en" or "fr" or "sp" | 5 |
timestamp | The time of the interaction. | ISO 8601 format | current time | "2023-11-10T12:34:56Z" | 6 |
xapi | The fully rendered xAPI statement. | json | null | - | 7 |
{
"actor": "janedoe@fake.com",
"verb": "viewed",
"object": "https://edtechbooks.org/education_research/research"
}
["janedoe@fake.com", "viewed", "https://edtechbooks.org/education_research/research"]
{
"actor": "janedoe@fake.com",
"verb": "viewed",
"object": "https://edtechbooks.org/education_research/research#question1",
"result": true}
["janedoe@fake.com", "answered", "https://edtechbooks.org/education_research/research#question1", true]
You can create an ETB API key for your project by logging in and going to the Developer
dashboard in the top-right menu. This requires developer access, which you can request by contacting a site admin.
You can build charts and graphs in Google Sheets for dashboards and reports and then automate the download of LilxAPI statements using the ImportData
function and appending the &format=csv
value to your endpoint. An example endpoint for this purpose follows:
https://edtechbooks.org/api.v2.php?action=lilxapi_get&format=csv&api_key=YOURAPIKEY
You can build charts and graphs in Excel for dashboards and reports and then automate the download of LilxAPI statements. Here is an example automation script that can be included in Excel to pull data directly from ETB:
const apiKey = "YOURAPIKEYHERE";
interface ExcelRow {
statement_id: number;
author_id: number;
actor: string;
verb: string;
object: string;
result: string;
context: string;
language_id: string;
timestamp: string;
xapi: string
}
async function main(workbook: ExcelScript.Workbook) {
const data = await fetchData();
console.log(JSON.parse(data.json));
const json: ExcelRow[] = JSON.parse(data.json);
const newWorksheet = workbook.getActiveWorksheet();
newWorksheet.activate();
const headingRange = newWorksheet.getRangeByIndexes(
0,
0,
1,
Object.keys(json[0]).length);
console.log(Object.keys(json[0]));
headingRange.setValues([Object.keys(json[0])]);
const dataRange = newWorksheet.getRangeByIndexes(
1,
0,
json.length,
Object.keys(json[0]).length);
dataRange.setValues(json.map(row => Object.values(row)));
}
async function fetchData(): Promise<string[][]> {
const apiUrl = "https://edtechbooks.org/api.v2.php?action=lilxapi_get&api_key=" + apiKey;
const response = await fetch(apiUrl);
if (!response.ok) {
throw new Error(`Failed to fetch data. Status: ${response.status}`);
}
const jsonData: ExcelRow[] = await response.json();
return jsonData;
}
This content is provided to you freely by EdTech Books.
Access it online or download it at https://edtechbooks.org/elearning_hacker/lilxapi.