# Quick Start

### Installing Open WA

Use this command to install the library for the first time and to keep the library up to date.

```bash
npm i --save @open-wa/wa-automate@latest
```

### Argument list

| Argument      | Description                                                                                                                                                                                                           |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| -p, --port    | Set the port for the api. Default to 8002                                                                                                                                                                             |
| --api-host    | <p>The easy API may be sitting behind a reverse proxy. In this case set<br>--api-host in order to make sure the api docs and api explorer are working<br>properly. You will need to include the protocol as well.</p> |
| -w, --webhook | Webhook to use for the listeners.                                                                                                                                                                                     |
| -k, --key     | <p>Specify an api key to use as a check for all requests. If you add -k by<br>itself, a key will be auto generated for you.</p>                                                                                       |

For more detail each argument use this command

```bash
npx @open-wa/wa-automate --help
```

### Running on a server

If you're not running this on your localhost, you'll need to set the server hostname for the api-docs to work correctly.

```bash
npx @open-wa/wa-automate -p 8080 --api-host 'https://my-wa-api.dev:8080'
```

The environment should be

```
WAVEL_HOST=https://my-wa-api.dev:8080
```

Example usage for standalone should be

```php
$wavel = new Ardzz\Wavel\WavelFactory(
    wavelHost: 'https://my-wa-api.dev:8080'
);
```

### Webhook client

You can also set a webhook address to send all requests

```bash
npx @open-wa/wa-automate -w 'https://my.laravel.project/wavel_webhook_server'
```

### Use webhook and securing server

In order to protect the API server, you must set the API key

```bash
npx @open-wa/wa-automate -p 8080 -k 'S3Cr3T_K3y' --api-host 'https://my-wa-api.dev:8080' 
```

The environment should be

```
WAVEL_HOST=https://my-wa-api.dev:8080
WAVEL_API_KEY=S3Cr3T_K3y
```

Example usage for standalone should be

```php
$wavel = new Ardzz\Wavel\WavelFactory(
    wavelHost: 'https://my-wa-api.dev:8080',
    wavelApiKey: 'S3Cr3T_K3y'
);
```
