Submit a request
Submit a request

Getting Started with the Data API

This page contains a PHP example of how to setup security parameters for authentication. Learnosity supplies an SDK available in PHPJavaASP.NetPython 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';

Once you have prepared your security and request details, use them to make an API resource request. To call Data API v1, ensure you explicitly specify v1 in your request URL as shown in the example.

use LearnositySdk\Request\DataApi;

$dataApi = new DataApi();
$dataApi->requestRecursive(
    'https://data.learnosity.com/v1/itembank/items',
    $security,
    $consumer_secret,
    $request,
    $action,
    function ($data) {
        $this->myCallback($data);
    }
);

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
}
Was this article helpful?
0 out of 3 found this helpful

Did you arrive here by accident? If so, learn more about Learnosity by clicking here.