npm package: @sebuahhobi/waavis
Description: WAAVIS Unofficial WhatsApp API client
Author: sebuahhobi
Latest version: 1.2.0

# WAAVIS Node.js Library

[![npm version](https://img.shields.io/npm/v/%40sebuahhobi%2Fwaavis?cacheSeconds=300)](https://www.npmjs.com/package/@sebuahhobi/waavis)
[![npm downloads](https://img.shields.io/npm/dm/%40sebuahhobi%2Fwaavis)](https://www.npmjs.com/package/@sebuahhobi/waavis)

Unofficial WAAVIS WhatsApp API client for Node.js.

## Install

```bash
npm install @sebuahhobi/waavis
```

## Usage

### 1) Simple function

```js
const waavis = require('@sebuahhobi/waavis');

async function main() {
  const result = await waavis.sendChat({
    token: 'DEVICE_TOKEN',
    to: '628xxxxxx',
    message: 'Halo'
  });

  console.log(result);
}

main().catch(console.error);
```

### 1b) Simple function (POST)

```js
const waavis = require('@sebuahhobi/waavis');

async function main() {
  const result = await waavis.sendChatPost({
    token: 'DEVICE_TOKEN',
    to: '62812xxxx@s.whatsapp.net',
    message: 'Halo',
    typing: true
  });

  console.log(result);
}

main().catch(console.error);
```

### 1c) Simple function (POST link)

```js
const waavis = require('@sebuahhobi/waavis');

async function main() {
  const result = await waavis.sendChatLinkPost({
    token: 'DEVICE_TOKEN',
    to: '62822xxxxxxx',
    message: 'Halo',
    typing: true,
    link: 'https://waavis.com',
    link_title: 'Waavis API',
    link_description: 'WhatsApp API Service'
  });

  console.log(result);
}

main().catch(console.error);
```

### 1d) Simple function (POST media)

```js
const waavis = require('@sebuahhobi/waavis');

async function main() {
  const result = await waavis.sendChatMedia({
    token: 'DEVICE_TOKEN',
    to: '62812xxxx@s.whatsapp.net',
    message: 'Halo',
    typing: true,
    type: 'image',
    file: './image.jpg'
  });

  console.log(result);
}

main().catch(console.error);
```

### 2) Client instance

```js
const { WaavisClient } = require('@sebuahhobi/waavis');

const client = new WaavisClient({
  token: process.env.WAAVIS_TOKEN,
  baseUrl: 'https://api.waavis.com'
});

client
  .sendChat({ to: '628xxxxxx', message: 'Halo' })
  .then(console.log)
  .catch(console.error);
```

### 2b) Client instance (POST)

```js
const { WaavisClient } = require('@sebuahhobi/waavis');

const client = new WaavisClient({
  token: process.env.WAAVIS_TOKEN,
  baseUrl: 'https://api.waavis.com'
});

client
  .sendChatPost({
    to: '62812xxxx@s.whatsapp.net',
    message: 'Halo',
    typing: true
  })
  .then(console.log)
  .catch(console.error);
```

### 2c) Client instance (POST link)

```js
const { WaavisClient } = require('@sebuahhobi/waavis');

const client = new WaavisClient({
  token: process.env.WAAVIS_TOKEN,
  baseUrl: 'https://api.waavis.com'
});

client
  .sendChatLinkPost({
    to: '62822xxxxxxx',
    message: 'Halo',
    typing: true,
    link: 'https://waavis.com',
    link_title: 'Waavis API',
    link_description: 'WhatsApp API Service'
  })
  .then(console.log)
  .catch(console.error);
```

### 2d) Client instance (POST media)

```js
const { WaavisClient } = require('@sebuahhobi/waavis');

const client = new WaavisClient({
  token: process.env.WAAVIS_TOKEN,
  baseUrl: 'https://api.waavis.com'
});

client
  .sendChatMedia({
    to: '62812xxxx@s.whatsapp.net',
    message: 'Halo',
    typing: true,
    type: 'image',
    file: './image.jpg'
  })
  .then(console.log)
  .catch(console.error);
```

## API Endpoint Example

```text
https://api.waavis.com/v1/send_chat?token=DEVICE_TOKEN&to=628xxxxxx&message=Halo
```

```text
POST https://api.waavis.com/v1/send_chat
Authorization: DEVICE_TOKEN
to=62812xxxx@s.whatsapp.net&message=Halo&typing=true
```

```text
POST https://api.waavis.com/v1/send_chat_link
Authorization: DEVICE_TOKEN
to=62822xxxxxxx&message=Halo&typing=true&link=https://waavis.com&link_title=Waavis%20API&link_description=WhatsApp%20API%20Service
```

```text
POST https://api.waavis.com/v1/send_chat_media
Authorization: DEVICE_TOKEN
multipart/form-data
to=62812xxxx@s.whatsapp.net&message=Halo&typing=true&type=image&file=@image.jpg
```

## Requirements

- Node.js 18+

## License

MIT