Skip to content

REST API that can be tested locally to connect using QRCode and send messages by POST requests.

License

Notifications You must be signed in to change notification settings

jsdaniell/whats-api

Repository files navigation

whatsapp-api

Connect and send messages as a whatsapp client sending REST requests, this is only for experimental use.

Summary

1. How to use locally
2. How to use on Heroku Instance
3. Testing request end-points
4. Contribute

How to use locally

Requirements:

  • Have the go installed on your machine.
Download the repository

git clone https://github.com/jsdaniell/whats-api.git

Get dependencies

go mod download || go mod vendor

Running

go run main.go

How to use on Heroku Instance

Requirements:

  • Have the heroku cli installed on your machine and logged account.
Download the repository

git clone https://github.com/jsdaniell/whats-api.git

Create your project on your heroku account

heroku create {name-of-your-project}

Deploying to heroku

heroku container:push -a {name-of-your-project} web

heroku container:release -a {name-of-your-project} web

Testing

curl https://{name-of-your-project}.herokuapp.com/

The response must be: Server Running...

See logs with heroku logs --tail on the root folder of project.

Testing the requests end-points

GET: https://localhost:9000/getQrCode
returns the QRCode PNG on the response.

curl --location --request GET 'http://localhost:9000/getQrCode' \ --header 'Authorization: anyIDString'

GET: https://localhost:9000/disconnect
disconnect the actually logged session on the server.

curl --location --request GET 'http://localhost:9000/disconnect' \ --header 'Authorization: anyIDString'

POST: https://localhost:9000/sendMessage
send a message to some number.

curl --location --request POST 'http://localhost:9000/sendMessage' \ --header 'Authorization: anyIDString' \ --header 'Content-Type: application/json' \ --data-raw '{ "number": "558599999999", "message": "message" }'

Your contribution is important!

Feel free to contribute and create suggestions about this tool, you can submit a PR anytime you want!

About

REST API that can be tested locally to connect using QRCode and send messages by POST requests.

Resources

License

Stars

Watchers

Forks