|
1 | 1 | --- |
2 | | -title: Get started with wa-automate via Docker |
3 | | -sidebar_label: Easy API |
| 2 | +title: Quick Start Guide - wa-automate EASY API |
| 3 | +sidebar_label: Quick Start |
4 | 4 | sidebar_position: 0 |
5 | | -description: |
6 | | - Guide showing how to use wa-automate with Docker. This also covers how to import |
7 | | - data as well as persistence. |
| 5 | +description: A comprehensive guide to quickly set up wa-automate and create a Open-wa EASY API with zero installation requirements. |
8 | 6 | --- |
9 | 7 |
|
10 | | -# Zero Install EASY API |
| 8 | +# Quick Start Guide |
11 | 9 |
|
12 | | -Ever wanted to create an API out of your WA number? You're in luck! |
| 10 | +Want to create an API from your WA number in seconds? This guide will show you how! |
13 | 11 |
|
14 | | -Open the terminal, and enter this: |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +Before you begin, ensure you have the following installed on your system: |
| 15 | +- Node.js |
| 16 | +- npm (Node Package Manager) |
| 17 | +- npx (Node Package Runner) |
| 18 | + |
| 19 | +## Basic Usage |
| 20 | + |
| 21 | +1. Open your terminal and run: |
15 | 22 |
|
16 | 23 | ```bash |
17 | | -> npx @open-wa/wa-automate |
| 24 | +npx @open-wa/wa-automate |
18 | 25 | ``` |
19 | 26 |
|
20 | | -> P.S you have to make sure you have `node`, `npm`, and `npx` installed on your system. |
| 27 | +This command will: |
| 28 | +- Start a @open-wa EASY API server |
| 29 | +- Provide you with a URL to an interactive API explorer |
| 30 | +- Generate documentation for all available endpoints |
21 | 31 |
|
22 | | -When you run the code, it will also give you a URL to an API explorer where you can play around with the various API endpoints with documentation. |
| 32 | +## Configuration Options |
23 | 33 |
|
24 | | -You can see all the help text like so: |
| 34 | +### Port Configuration |
| 35 | +Set a custom port for your API server: |
25 | 36 |
|
26 | 37 | ```bash |
27 | | -> npx @open-wa/wa-automate --help |
| 38 | +npx @open-wa/wa-automate -p 8080 |
28 | 39 | ``` |
29 | 40 |
|
30 | | -You can set a custom port: |
| 41 | +### API Security |
| 42 | +Protect your API with an authentication key: |
31 | 43 |
|
32 | 44 | ```bash |
33 | | -> npx @open-wa/wa-automate -p 8080 |
| 45 | +# Auto-generate a secure key |
| 46 | +npx @open-wa/wa-automate -p 8080 -k |
| 47 | + |
| 48 | +# Use a custom key |
| 49 | +npx @open-wa/wa-automate -p 8080 -k 'YOUR_SECURE_KEY' |
34 | 50 | ``` |
35 | 51 |
|
36 | | -and an api key which will prevent unauthorized requests. This will result in a key being automatically generated for you: |
| 52 | +:::note |
37 | 53 |
|
38 | | -```bash |
39 | | -> npx @open-wa/wa-automate -p 8080 -k |
40 | | -``` |
| 54 | +[randomkeygen.com](https://randomkeygen.com/) is a great resource for generating secure keys. |
| 55 | + |
| 56 | +::: |
41 | 57 |
|
42 | | -or you can set your own, I got the following secure key from [https://randomkeygen.com/](https://randomkeygen.com/): |
| 58 | +### Tunneling |
| 59 | +Your EASY API instance, by default, will be only accessible in your local network. This is useful and secure for local development but if you want to be able to access the API outside of your network you can do so easily with the `--tunnel` flag. |
43 | 60 |
|
44 | 61 | ```bash |
45 | | -> npx @open-wa/wa-automate -p 8080 -k 'K6MEQJRV3trXMPZ5eQd1Jl8NaaaRZxqy' |
| 62 | +npx @open-wa/wa-automate -p 8080 -k 'YOUR_SECURE_KEY' --tunnel |
46 | 63 | ``` |
47 | 64 |
|
48 | | -You can easily force the program to maintain focus (`--keep-alive` or `-a`): |
| 65 | +:::note |
49 | 66 |
|
50 | | -```bash |
51 | | -> npx @open-wa/wa-automate -p 8080 -k 'K6MEQJRV3trXMPZ5eQd1Jl8NaaaRZxqy' --keep-alive |
| 67 | +You will might need to manually install **cloudflared** for this to work. |
52 | 68 |
|
53 | | -//or |
| 69 | +::: |
54 | 70 |
|
55 | | -> npx @open-wa/wa-automate -p 8080 -k 'K6MEQJRV3trXMPZ5eQd1Jl8NaaaRZxqy' --keep-alive |
56 | | -``` |
| 71 | +## Session Management |
57 | 72 |
|
58 | | -## Restarting session |
| 73 | +Starting from version 2.0.0, sessions are managed using base64 strings. You can restore a session using any of these equivalent commands: |
59 | 74 |
|
60 | | -As of version 2.0.0 of this library, you can now provide session data as a base64 string. This is the default method goin forward and your `.data.json` files should have this string if you've run the program in version 2.0.0+. |
| 75 | +```bash |
| 76 | +# Using --session-data (recommended) |
| 77 | +npx @open-wa/wa-automate --session-data "YOUR_BASE64_SESSION_DATA" |
61 | 78 |
|
62 | | -There are 3 param tags that can be used to set session data `-s`, `--session` or `--session-data` - all work but make sure you wrap the string with double quotes `"` and NOT sinle quotes `'`. |
| 79 | +# Using --session |
| 80 | +npx @open-wa/wa-automate --session "YOUR_BASE64_SESSION_DATA" |
63 | 81 |
|
64 | | -```bash |
65 | | -> npx @open-wa/wa-automate -p 8080 -k 'K6MEQJRV3trXMPZ5eQd1Jl8NaaaRZxqy' --session-data "eyJXQUJyb...ifQ==" |
66 | | -//or |
67 | | -> npx @open-wa/wa-automate -p 8080 -k 'K6MEQJRV3trXMPZ5eQd1Jl8NaaaRZxqy' --session "eyJXQUJyb...ifQ==" |
68 | | -//or |
69 | | -> npx @open-wa/wa-automate -p 8080 -k 'K6MEQJRV3trXMPZ5eQd1Jl8NaaaRZxqy' -s "eyJXQUJyb...ifQ==" |
| 82 | +# Using -s (shorthand) |
| 83 | +npx @open-wa/wa-automate -s "YOUR_BASE64_SESSION_DATA" |
70 | 84 | ``` |
71 | 85 |
|
72 | | -## Running on a server |
| 86 | +:::note |
| 87 | +Always wrap your session data string in double quotes (`""`), not single quotes. |
| 88 | +::: |
| 89 | + |
| 90 | +## Server Deployment |
73 | 91 |
|
74 | | -If you're not running this on your localhost, you'll need to set the server hostname for the api-docs to work correctly. |
| 92 | +When deploying to a remote server, specify your API hostname for proper documentation: |
75 | 93 |
|
76 | 94 | ```bash |
77 | | -> npx @open-wa/wa-automate -p 8080 --api-host 'https://my-wa-api.dev:8080' |
| 95 | +npx @open-wa/wa-automate -p 8080 --api-host 'https://your-api-domain.com:8080' |
78 | 96 | ``` |
79 | 97 |
|
80 | | -## Webhooks |
| 98 | +## Webhook Integration |
81 | 99 |
|
82 | | -You can also set a webhook address to send all requests to. I like using [webhook.site](https://webhook.site/) to check and test events. |
| 100 | +Set up webhooks to receive real-time event notifications: |
83 | 101 |
|
84 | 102 | ```bash |
85 | | -> npx @open-wa/wa-automate -w 'https://webhook.site/7a00ac21-60f2-411e-a571-515b37b2025a' |
| 103 | +npx @open-wa/wa-automate -w 'https://your-webhook-url.com/endpoint' |
86 | 104 | ``` |
87 | 105 |
|
88 | | -Now if you go to: |
| 106 | +:::tip Testing Webhooks |
89 | 107 |
|
90 | | -```http |
91 | | -https://webhook.site/#!/7a00ac21-60f2-411e-a571-515b37b2025a |
92 | | -``` |
| 108 | +For testing webhooks, you can use services like [webhook.site](https://webhook.site/). Remember to clear your test data afterward for privacy! |
93 | 109 |
|
94 | | - you'll be able to see all the events come through. |
| 110 | +::: |
95 | 111 |
|
96 | | -If you do use this link please make sure to clear all of your requests for your privacy. |
| 112 | +## API Documentation |
97 | 113 |
|
98 | | -## API Docs |
99 | | - |
100 | | -By default, the CLI generates and serves a swagger api explorer at `[host]/api-docs/` |
| 114 | +The API documentation is automatically available at: |
| 115 | +``` |
| 116 | +http://[your-host]/api-docs/ |
| 117 | +``` |
101 | 118 |
|
102 | | -For example: |
| 119 | +This interactive documentation includes: |
| 120 | +- Complete endpoint listing |
| 121 | +- Request/response examples |
| 122 | +- Testing interface |
| 123 | +- Authentication details |
103 | 124 |
|
104 | | -```bash |
105 | | -> npx @open-wa/wa-automate -w 'https://webhook.site/7a00ac21-60f2-411e-a571-515b37b2025a' -p 8008 |
106 | | -``` |
| 125 | +## Getting Help |
107 | 126 |
|
108 | | -will server the api docs at |
| 127 | +View all available options and their descriptions: |
109 | 128 |
|
110 | | -```http |
111 | | -http://localhost:8008/api-docs/ |
| 129 | +```bash |
| 130 | +npx @open-wa/wa-automate --help |
112 | 131 | ``` |
113 | 132 |
|
114 | | -## Postman collection |
| 133 | +## Postman Collection |
115 | 134 |
|
116 | | -The CLI will also automatically generate a postman collection for your specific set up (including api keys, hostname, ports, etc.) which you can then easily import into postman. |
| 135 | +A Postman collection is automatically generated for your specific setup, including API keys, hostname, ports, and more. You can easily import this collection into Postman for further testing and exploration. |
117 | 136 |
|
118 | | -## Coming soon |
| 137 | +## Coming Soon |
119 | 138 |
|
120 | | -Soon SDKs for most programming lanugages will be created using the CLI as a base 'server'. Check this issue for updates: [#894](https://github.com/open-wa/wa-automate-nodejs/issues/894) |
| 139 | +SDKs for most programming languages will be created using the CLI as a base 'server'. Check this issue for updates: [#894](https://github.com/open-wa/wa-automate-nodejs/issues/894) |
0 commit comments