# @immail/realtime-api

> Javascript library for using imMail real-time API.

Latest version **0.0.6** (published 2020-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @immail/realtime-api
pnpm add @immail/realtime-api
yarn add @immail/realtime-api
bun add @immail/realtime-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2020-06-06 |
| First published | 2020-05-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | imMail Team |
| Maintainers | rmsouza |
| Keywords | realtime, immail, api |

## Links

- npm: https://www.npmjs.com/package/@immail/realtime-api
- npm.io page: https://npm.io/package/@immail/realtime-api

## Dependencies (1)

- [socket.io-client](https://npm.io/package/socket.io-client.md) ^2.3.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.0.6 (latest) — 2020-06-06
- 0.0.5 — 2020-05-20
- 0.0.4 — 2020-05-20
- 0.0.3 — 2020-05-20
- 0.0.2 — 2020-05-20
- 0.0.1 — 2020-05-20

## README

# imMail Web API

The `@immail/realtime-api` lib contains an easy and customizable HTTP client for using [Real-time API].
Use it to emit or listen real-time events from imMail.

## Installation

```shell
$ npm install @immail/realtime-api
```

## Usage

These example shows one of the most common features of the `RTMClient`.

---

### Initialize the client

The package exports a `RTMClient` class. All you need to do is instantiate it, and you're ready to go. You'll typically
initialize it with a `{ host, authToken }`. If you do not provide a host, the default one (https://app.immail.ca) will be defined.

```javascript
const { WebClient } = require('@immail/web-api');
const { RTMClient } = require('@immail/realtime-api');

// Read a host from the environment variables
const apiHost = process.env.IMMAIL_API_HOST // Optional. Usefull for on-premise versions. The imMail's production host will be set as default
const rtmHost = process.env.IMMAIL_RTM_HOST // Optional. Usefull for on-premise versions. The imMail's production host will be set as default
const login = process.env.IMMAIL_LOGIN
const password = process.env.IMMAIL_PASSWORD

// Log in using the WebClient library first of all
const webImmail = new WebClient({ host: apiHost })
const { token } = await immail.login({ login, password })

// Take the token from login and initialize
const rtmImmail = new RTMClient({ host: rtmHost, authToken: token })

// Connect
rtmImmail.connect()

/**
 * Alternatively you can use
 * rtmImmail.connect(token)
 * /

```

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