For the complete documentation index, see llms.txt. This page is also available as Markdown.

Getting Started

How to get the library up and running in your project.

The library has been configured to work in multiple environments:

  • UMD (Browser, client-side applications)

  • ESM (Browser, client-side applications)

  • CJS (Server-side applications)

UMD (Browser, client-side applications)

For browser-based applications you can link the UMD package directly from unpkg.com in a script tag.

<script src="https://unpkg.com/@xapi/xapi"></script>

<script type="text/javascript">
  // Create LRS connection
  const endpoint = "https://my-lms.com/endpoint";
  const username = "username";
  const password = "password";
  const auth = XAPI.toBasicAuth(username, password);
  const xapi = new XAPI({
    endpoint: endpoint,
    auth: auth
  });

  // Create your statement
  const myStatement = { ... };

  // Send your statement
  xapi.sendStatement({
    statement: myStatement
  });
</script>

ES Module (Browser, client-side applications)

For client-side applications built using imports, an ES Module is available for you to install and import into your project.

CJS (Server-side applications)

For server-side applications built using require, a CommonJS module is available for you to install and require into your project.

Alternatively, the module can also be imported using .mjs.

Last updated