# The XAPI Class

## new XAPI()

To use any of the Resources, you will need to create a new instance of [XAPI](https://github.com/xapijs/xapi/tree/fd040c6f049f68fce317538626906de57ffebf44/src/XAPI.ts) with credentials.

```typescript
const endpoint = "https://my-lms.com/endpoint/";
const auth = XAPI.toBasicAuth(username, password);
const xapi = new XAPI({
  endpoint: endpoint,
  auth: auth
});
```

### **Parameters**

| Parameter | Type                                                                             | Required | Description                                                                                                                                                                       |
| --------- | -------------------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| endpoint  | string                                                                           | true     | The URL of the endpoint.                                                                                                                                                          |
| auth      | string                                                                           | false    | The `Authorization` header value to be appended to all requests. Defaults to `Basic 0g==`, which is equivalent of `Basic` followed by a base64 encoded version of the string `:`. |
| version   | [Versions](https://github.com/xapijs/xapi/blob/master/src/constants/Versions.ts) | false    | The version of xAPI to use. Defaults to  `1.0.3`.                                                                                                                                 |
| adapter   | [Adapter](https://github.com/xapijs/xapi/blob/develop/src/adapters/index.ts#L23) | false    | The underlying adapter to make HTTP requests with. Accepts  `axios`, `fetch` or a custom adapter function. Defaults to `axios`.                                                   |

### **Returns**

This returns an [XAPI](https://github.com/xapijs/xapi/tree/fd040c6f049f68fce317538626906de57ffebf44/src/XAPI.ts) object which you can use to communicate with the LRS.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.xapijs.dev/xapi-wrapper-library/xapi-class.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
