> For the complete documentation index, see [llms.txt](https://impoo.gitbook.io/authenticationsystem/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://impoo.gitbook.io/authenticationsystem/developers/authsystemapi.md).

# AuthSystemApi

`AuthSystemApi` is the main entry point to the AuthSystem API. It is a singleton interface that provides access to the `AuthTable` and `AuthManager`.

## Obtaining the API

```java
AuthSystemApi api = AuthSystemApi.get();
```

{% hint style="warning" %}
`AuthSystemApi.get()` returns `null` if AuthSystem is not loaded on the server. Always check for `null` before using the API.
{% endhint %}

## Safe API access pattern

```java
private AuthSystemApi api;

public void initApi() {
    api = AuthSystemApi.get();
    if (api == null) {
        getLogger().warning("AuthSystem is not loaded!");
    }
}
```

## Methods

### getAuthTable()

```java
AuthTable getAuthTable()
```

Returns the `AuthTable` instance for database operations.

**Returns:** `AuthTable` — the database access layer

### getAuthManager()

```java
AuthManager getAuthManager()
```

Returns the `AuthManager` instance for authentication lifecycle operations.

**Returns:** `AuthManager` — the authentication manager

## Example usage

```java
import me.authsystem.api.AuthSystemApi;
import me.authsystem.api.auth.AuthManager;
import me.authsystem.api.database.AuthTable;

public void onEnable() {
    AuthSystemApi api = AuthSystemApi.get();
    if (api == null) return;
    
    AuthManager authManager = api.getAuthManager();
    AuthTable authTable = api.getAuthTable();
    
    // Now you can use authManager and authTable
}
```

***

> :bulb: **Tip**: Cache the API reference in your plugin's main class rather than calling `AuthSystemApi.get()` repeatedly.
