# @otrs/client-lib

> A library to help with working with the various OTRS backend APIs

Latest version **0.1.8** (published 2025-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @otrs/client-lib
pnpm add @otrs/client-lib
yarn add @otrs/client-lib
bun add @otrs/client-lib
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.8 |
| Published | 2025-07-08 |
| First published | 2024-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 327.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | OTRS AG |
| Maintainers | marco.buchholz, andreas.hergert, jakemorrisotrs, daniel.golbig, jaroslav.balaz |

## Links

- npm: https://www.npmjs.com/package/@otrs/client-lib
- npm.io page: https://npm.io/package/@otrs/client-lib

## Dependencies (2)

- [emittery](https://npm.io/package/emittery.md) ^1.0.1
- [oidc-client-ts](https://npm.io/package/oidc-client-ts.md) ^2.2.4

## Recent versions

- 0.1.8 (latest) — 2025-07-08
- 0.1.5-beta.2 (beta) — 2024-07-08
- 0.1.7 — 2025-03-19
- 0.1.6 — 2024-07-19
- 0.1.5 — 2024-07-08
- 0.1.5-beta.1 — 2024-07-08
- 0.1.4-beta.1 — 2024-07-08
- 0.1.4 — 2024-05-17
- 0.1.3 — 2024-05-17
- 0.1.2 — 2024-05-15
- 0.1.1 — 2024-05-10
- 0.1.0 — 2024-05-08
- 0.0.2 — 2024-04-18
- 0.0.1 — 2024-04-18

## README

# otrs-client-lib

## Disclaimer
This is a library used by OTRS to facilitate frontend clients to interact with the backend. 

Currently this is an active work in progress, with lots more to be added.

## Usage
Install the library using `npm install @otrs/client-lib` in a Javascript or Typescript application.

Next, register the client with the correct configuration

```ts
const client = createClient({
  testMode: false // optional (default = false),
})
```

### Listening to events
```ts
client.eventBus.on('translation-switch-success', (language) => {
  console.log('Language switched to: ', language)
})

client.eventBus.on('addUserLoaded', (user) => {
  console.log('User signed in: ', user)
})

client.eventBus.on('addUserSignedOut', () => {
  console.log('User signed out')
})
```

### Using authentication
```ts
// first, register the module
client.auth.init({
  clientId: '',
  authority: '',
  // Other options are automatically suggested
})

client.auth.signIn().then(
  res => console.log('result =', res)
)
```

### Loading translations
```ts
// Using aync/await
const language = 'en'
const hash = '<hash-value>'

// ... Error handling omitted
const res = await client.locale.loadLanguage(language, hash)
const { Locale, Translations } = res.data
```

### Logging
Most function calls are automatically logged, you can pass your own custom logger through the `createClient` options.


## License

[MIT](./LICENSE) License © 2024 [OTRS AG](https://www.otrs.com)

---
_Source: https://npm.io/package/@otrs/client-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
