About the project | Technologies | Getting started | How to contribute | License
This API allow send messages using whatsapp through an API Rest. The project is separated by two main process, one for the API Rest and other responsible for check if there is new messages to send in the queue. Remember: This software is only for study purposes and you have to be careful to not be banned for sending spam using whatsapp. (Send spam through Whatsapp is illegal).
Technologies that I used to develop this api
- Node.js
- Typescript
- Express
- TypeORM
- JWT-token
- MySQL
- Date-fns
- Babel
- Whatsapp-web.js
- Eslint
- Prettier
- EditorConfig
Import the Insomnia.json
on Insomnia App or click on Run in Insomnia button
Clone the project and access the folder
$ git clone https://github.com/felipeDS91/whatsapp-api.git && cd whatsapp-api
Follow the steps below
# Install the dependencies
$ yarn
# Creates a docker container or use your own mysql installation (changes the password)
$ docker run --name "whatsapp" -e MYSQL_ROOT_PASSWORD="mysql_password" -p 3306:3306 -d mysql:5.7.30
# Creates a new mysql user (changes the username and password)
# To connect with mysql database you can use a tool like DBeaver for example
$ CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
# Make a copy of '.env.example' to '.env'
# and set with YOUR environment variables
$ cp .env.example .env
# Run the migrations and seeds
$ yarn typeorm migration:run
# Run this command to start the server in development mode
$ yarn dev:server
# Or you can run separately the API/WhatsApp message client
$ yarn dev:api
$ yarn dev:whatsapp
# Default credentials:
# username: admin
# password: 123456
# Well done, project is started!
- /sessions: Sign in to get the access token .
- /message: Send message to the queue.
- /users: Manage the access to the API.
- /tokens: Manage the tokens if you want to register tokens without rendering it on command line prompt. Example: In some hosting the render on command line prompt doesn't work properly, so you can use it to insert new numbers (tokens).
- /prompt-token: Render a QrCode on command line prompt to be read using an whatsapp and record that number to send new messages.
- Paas hosting (Heroku): This project uses whatsapp-web.js package that uses Puppeter and it is based on chrome. So if you are getting some log like this "...loading shared libraries: libnss3.so: cannot open shared object file..." you will have to install a "Buildpack" in your app. To do it, you have to access the app on Heroku and go to the menu "Settings" --> "Buildpacks" --> "Add buildpack", fill out the Buildpack URL with "jontewks/puppeteer" and click in "Save changes" button. And after your next deploy, this buildpack to use puppeter will be installed with your app.
- Make a fork of this repository
# Fork using GitHub official command line
# If you don't have the GitHub CLI, use the web site to do that.
$ gh repo fork felipeDS91/whatsapp-api
# Clone your fork
$ git clone your-fork-url && cd whatsapp-api
# Create a branch with your feature
$ git checkout -b my-feature
# Make the commit with your changes
$ git commit -m 'feat: My new feature'
# Send the code to your remote branch
$ git push origin my-feature
After your pull request is merged, you can delete your branch
This project is licensed under the MIT License - see the LICENSE file for details.
Made with 💜 by Felipe Douglas 👋 See my linkedin