Simple RESTful API for WhatsApp in Golang (using the Whatsmeow multi device library)

WUZAPI

WuzAPI is an implementation of @tulir/whatsmeow library as a simple RESTful API service with multiple device support and concurrent sessions.

Whatsmeow does not use Puppeteer on headless Chrome, nor an Android emulator. It talks directly to WhatsApp websocket servers, thus is quite fast and uses much less memory and CPU than those solutions. The drawback is that a change in the WhatsApp protocol could break connections and will require a library update.

⚠️ Warning

Using this software violating WhatsApp ToS can get your number banned: Be very careful, do not use this to send SPAM or anything like it. Use at your own risk. If you need to develop something with commercial interest you should contact a WhatsApp global solution provider and sign up for the Whatsapp Business API service instead.

Available endpoints

  • Session: connect, disconnect and logout from WhatsApp. Retrieve connection status. Retrieve QR code for scanning.
  • Messages: send text, image, audio, document, template, video, sticker, location and contact messages.
  • Users: check if phones have whatsapp, get user information, get user avatar, retrieve full contact list.
  • Chat: set presence (typing/paused,recording media), mark messages as read, download images from messages, send reactions.
  • Groups: list subscribed, get info, get invite links, change photo and name.
  • Webhooks: set and get webhook that will be called whenever events/messages are received.

Prerequisites

Packages:

  • Go (Go Programming Language)

Optional:

  • Docker (Containerization)

Building

go build .

Run

By default it will start a REST service in port 8080. These are the parameters you can use to alter behaviour

  • -address : sets the IP address to bind the server to (default 0.0.0.0)
  • -port : sets the port number (default 8080)
  • -logtype : format for logs, either console (default) or json
  • -wadebug : enable whatsmeow debug, either INFO or DEBUG levels are suported
  • -sslcertificate : SSL Certificate File
  • -sslprivatekey : SSL Private Key File

Example:

./wuzapi -logtype json

Usage

In order to open up sessions, you first need to create a user and set an authentication token for it. You can do so by updating the SQLite users.db database:

sqlite3 dbdata/users.db "insert into users ('name','token') values ('John','1234ABCD')" 

Once you have some users created, you can talk to the API passing the Token header as a simple means of authentication. You can have several users (different numbers), on the same server.

The daemon also serves some static web files, useful for development/testing that you can load with your browser:

  • An API swagger reference in /api A sample web page to connect and
  • scan QR codes in /login (where you will need to pass ?token=1234ABCD)

API reference

API calls should be made with content type json, and parameters sent into the request body, always passing the Token header for authenticating the request.

Check the API Reference

License

Copyright © 2022 Nicolás Gudiño

MIT

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Icon Attribution

Communication icons created by Vectors Market - Flaticon

Legal

This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by WhatsApp or any of its affiliates or subsidiaries. This is an independent and unofficial software. Use at your own risk.

Cryptography Notice

This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See http://www.wassenaar.org/ for more information.

The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms. The form and manner of this distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code.

Similar Resources

Komikuapitk - Restful API Manga bahasa Indonesia built with Go

Komikku API Restful API Manga bahasa Indonesia built with ❤️ and Go Usage Clone

Sep 2, 2022

Backgammon Web API. Sophisticed neural net based multi-ply evalution engine for Backgammon moves

Backgammon Web API. Sophisticed neural net based multi-ply evalution engine for Backgammon moves.

Dec 25, 2022

Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure.

Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure.

tutor-pet API Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure. Macro architecture: Code architecture: Pre-Re

Aug 17, 2022

RESTful based volume management framework for GlusterFS

Heketi Heketi provides a RESTful management interface which can be used to manage the life cycle of GlusterFS volumes. With Heketi, cloud services lik

Nov 18, 2020

A simple todolist application API created using Golang

API Aplikasi KegiatanQ Merupakan API aplikasi todolist sederhana yang dibuat men

Dec 29, 2021

support multi autosolve instances for AYCD

AYCD AutoSolve Go Client Client for connecting to the AYCD AutoSolve network

Jun 26, 2022

A Pulumi multi language component to create an IAM role for an EKS cluster

xyz Pulumi Component Provider (Go) This repo is a boilerplate showing how to create a Pulumi component provider written in Go. You can search-replace

Oct 27, 2021

CoreDNS plugin implementing K8s multi-cluster services DNS spec.

multicluster Name multicluster - implementation of Multicluster DNS Description This plugin implements the Kubernetes DNS-Based Multicluster Service D

Dec 3, 2022

Package figtree provides a multi-paradigm SDK for sophisticated configuration file access

Package figtree provides a multi-paradigm SDK for sophisticated configuration file access. Motivation Figtree syntax is based on classic key/value pai

Dec 31, 2021
Comments
  • invalid character 'j' looking for beginning of value

    invalid character 'j' looking for beginning of value

    Hi, when webhook start i got receive en the webbhook server this message

    invalid character 'j' looking for beginning of value

    if i test the webhook server with postman everything works.

    thanks

    victor

  • Got an

    Got an "Skipping webhook" error

    Hello,

    Tried to setting up the webhook, but it simply doesnt work.

    Some message I'v got so far:

    "2022-11-24T03:07:49+07:00 WRN Skipping webhook. Not subscribed for this type host=0.0.0.0 role=wuzapi type=Message"

    What happened? Does I missed something here? Tankyouu

  • [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x86bb3a]

    [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x86bb3a]

    2022-11-14T19:06:26+07:00 INF Message sent host=0.0.0.0 id=B228D74613E2DDD0F7958F738A72AE86 role=wuzapi timestamp="{0 63804024386 19609344}" 2022-11-14T19:06:26+07:00 INF Message delivered host=0.0.0.0 id=D7E05D5EE17DD2A15ED3E96F3405E0D9 role=wuzapi [email protected] timestamp="{0 63804024386 19609344}" 2022-11-14T19:06:26+07:00 WRN Skipping webhook. Not subscribed for this type host=0.0.0.0 role=wuzapi type=ReadReceipt 2022-11-14T19:06:26+07:00 INF Got API Request duration=774.648288 host=0.0.0.0 ip=172.17.12.185:37724 method=POST req_id=cdp2ugkon3mb6v6tj9l0 role=wuzapi size=134 status=200 url=/chat/send/text userid=1 panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x86bb3a]

    goroutine 83199 [running]: go.mau.fi/libsignal/state/record.(*State).SenderChainKey(...) /home/cloud/go/pkg/mod/go.mau.fi/[email protected]/state/record/SessionState.go:297 go.mau.fi/libsignal/session.(*Cipher).Encrypt(0xc0014599a8, {0xc000884000, 0xb2, 0x160}) /home/cloud/go/pkg/mod/go.mau.fi/[email protected]/session/SessionCipher.go:71 +0x7a go.mau.fi/whatsmeow.(*Client).encryptMessageForDevice(0xc00069d000, {0xc000ccf1e0, 0xaf, 0xaf}, {{0xc000831880, 0xd}, 0x0, 0x0, {0xc62306, 0xe}, ...}, ...) /home/cloud/go/pkg/mod/go.mau.fi/[email protected]/send.go:362 +0x67d go.mau.fi/whatsmeow.(*Client).handleRetryReceipt(0xc00069d000, 0xc000b43ea0, 0xc0011c78c0) /home/cloud/go/pkg/mod/go.mau.fi/[email protected]/retry.go:152 +0x125d go.mau.fi/whatsmeow.(*Client).handleReceipt.func1() /home/cloud/go/pkg/mod/go.mau.fi/[email protected]/receipt.go:26 +0x33 created by go.mau.fi/whatsmeow.(*Client).handleReceipt /home/cloud/go/pkg/mod/go.mau.fi/[email protected]/receipt.go:25 +0xca

go-whatsapp-rest-API is a Go library for the WhatsApp web which use Swagger as api interface

go-whatsapp-rest-API go-whatsapp-rest-API is a Go library for the WhatsApp web which use Swagger as api interface Multi-devices (MD) Support. This ver

Dec 15, 2022
Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers

go-whatsapp Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of

Mar 19, 2022
Golang API for Whatsapp API MultiDevice version
Golang API for Whatsapp API MultiDevice version

Go Whatsapp API Multi Device Version Required Mac OS: brew install vips export C

Jan 3, 2023
WhatsAppExpenseTracker - Way to track expenses using whatsapp group

WhatsAppExpenseTracker Way to track expenses using whatsapp group One needs to c

Jan 4, 2022
WhatsApp Web API

go-whatsapp Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of

Jan 7, 2023
Simple-Weather-API - Simple weather api app created using golang and Open Weather API key
Simple-Weather-API - Simple weather api app created using golang and Open Weather API key

Simple Weather API Simple weather api app created using golang and Open Weather

Feb 6, 2022
An implementation of a simple RESTful API in Golang on AWS infrastructure.

go-api An implementation of a simple RESTful API in Golang on AWS infrastructure. Tech Stack Serverless framework Go language AWS API Gateway AWS Lamb

Dec 25, 2021
Display last GitLab project git commit. Page is optimized for an e-paper device.
Display last GitLab project git commit. Page is optimized for an e-paper device.

git-on-epaper A gitlab webhook for push notifications on a project. The webhook serves a HTML that shows the last push on the project with the followi

Dec 12, 2022
Quick add or delete ASN/AS-SET to your AS-SET through RIPE RESTful API

RIPE AS-SET updater Quick add or delete ASN/AS-SET to your AS-SET through RIPE RESTful API. Requirenments You need to add "auth:" attribute in mntner

Apr 19, 2022
OpenAPI for Todolist RESTful API

Go API client for swagger OpenAPI for Todolist RESTful API Overview This API cli

Dec 18, 2021