Using Learnosity's Data API requires initializing the API with a JSON security object, an action to perform, and an optional request JSON packet of filter options and/or data.
1. Prepare the Request
This page contains a PHP example of how to setup security parameters for authentication. Learnosity supplies an SDK available in PHP, Java, ASP.Net, Python, NodeJS, or Ruby. You can add one of these to your codebase and get going quickly by following the readme and examples in each SDK.
$security = array(
'consumer_key' => 'INSERT_CONSUMER_KEY_HERE',
'domain' => 'my.domain.com'
);
$consumer_secret = 'INSERT_CONSUMER_SECRET_HERE';
$request = array(
'limit' => 50,
'types' => array('unit', 'module')
);
$action = 'get';
2. Send Request
Once you have prepared your security and request details, use them to make an API resource request. Be certain to target an appropriate Long Term Release version number in your request URL as shown in the example.
use LearnositySdk\Request\DataApi;
$dataApi = new DataApi();
$dataApi->requestRecursive(
'https://data.learnosity.com/v2022.1.LTS/itembank/items',
$security,
$consumer_secret,
$request,
$action,
function ($data) {
$this->myCallback($data);
}
);
3. Handle Response
Once we have the response, which is a JSON Object, we can do a number of things - persist this information to a backend DB, present it to a front-end webpage for rendering via JavaScript, or make use of the SDK to pass a callback for data processing.
function myCallback($data)
{
// Do something with $data
}