Launch API Tutorial

Learn how to use the Launch API to add SCORM, xAPI, or cmi5 e-learning content playback to your own headless LMS solution, custom application, or other web property. This step-by-step guide walks you through the basic concepts of integrating with the Veracity Launch API.
STEP 1

Setup and Installation

The integration demo is built with Node.js. Start by cloning the repository and installing its dependencies. This demo application acts as your backend, securely communicating with the Veracity Server via the REST API.

git clone https://bitbucket.org/veracitytc/integration-demo.git
cd integration-demo
npm install
npm run dev
STEP 2

API Configuration

Your application connects to the Veracity API using standard HTTP requests. You`ll need an Endpoint URL and a secret API Key. In the demo, these are defined at the top of index.js. In production, always use environment variables instead of hard-coding secrets. You can create an API key for your portal under Admin->Integrations->Launch API.

// The credentials to the Launch server
const API_ENDPOINT = "https://tenant.locallxp.veracity.it:4005/api";
const API_KEY = "YOUR-API-KEY-HERE";

const VERACITY_AUTH_HEADER = {
    "x-veracity-api-key": API_KEY
};
STEP 3

Content Upload and Status Tracking

You can upload SCORM or xAPI Zip packages directly. The demo proxies the HTTP multipart file upload to the Veracity API /content/upload endpoint. Veracity returns a placeholder ID. You can track this ID until its status becomes "ready". For this tutorial, you can also just upload some test content via your portal`s UI, or use one of the sample courses provided by Veracity. You can find the content ID in the URL when you open the course in your portal.

A common integration pattern involves giving your administrators an upload interface, sending that file to Veracity behind the scenes, and silently polling Veracity to know when the course is fully extracted and ready for launch.

STEP 4

Generating a Launch Session

When a learner wants to take a course, your application makes an API call to create a "registration" (a launch session). You pass specific learner data, the content ID, and a "terminateRedirect" URL. The API responds with a secure, single-use launch link.

// Example payload to create a registration
const payload = {
    contentId: "1234-abcd",
    actor: {
        mbox: "mailto:learner@example.com",
        name: "Jane Doe"
    },
    terminateRedirect: "http://localhost:3000/callback_hook/"
};
STEP 5

The Callback Loop

When the user completes the module and closes the player, Veracity redirects their browser to the "terminateRedirect" URL provided during launch. Your application intercepts this route to resume control. From here, you can close any popups and fetch the final score.

app.get("/callback_hook", (req, res) => {
    // Intercept the redirect when the player closes
    // Regain window control, and push the user to a results page
});
STEP 6

Fetching Session Results

Once the session is over, you can query the Veracity API for the unique registration ID to instantly get the session results: Completion, Success, Score, and Duration.

// Fetch results for registration ID
app.get("/callback/:registrationId", async (req, res) => {
    const response = await fetch(`${API_ENDPOINT}/registration/${req.params.registrationId}`);
    const results = await response.json();
    
    // Display the score and duration to the learner
});