Go WhatsApp Multi-Device Implementation in REST API with Multi-Session/Account Support

Go WhatsApp Multi-Device Implementation in REST API

This repository contains example of implementation go.mau.fi/whatsmeow package with Multi-Session/Account Support. This example is using a labstack/echo version 4.x.

Features

  • Multi-Session/Account Support
  • Multi-Device Support
  • WhatsApp Authentication (QR Code and Logout)
  • WhatsApp Messaging Send Text
  • WhatsApp Messaging Send Media (Document, Image, Audio, Video, Sticker)
  • WhatsApp Messaging Send Location
  • WhatsApp Messaging Send Contact
  • WhatsApp Messaging Send Link
  • And Much More ...

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment section for notes on how to deploy the project on a live system.

Prerequisites

Prequisites packages:

  • Go (Go Programming Language)
  • Swag (Go Annotations Converter to Swagger Documentation)
  • GoReleaser (Go Automated Binaries Build)
  • Make (Automated Execution using Makefile)

Optional packages:

  • Docker (Application Containerization)

Deployment

Using Container

  1. Install Docker CE based on the manual documentation

  2. Run the following command on your Terminal or PowerShell

docker run -d \
  -p 3000:3000 \
  --name go-whatsapp-multidevice \
  --rm dimaskiddo/go-whatsapp-multidevice-rest:latest
  1. Now it should be accessible in your machine by accessing localhost:3000/api/v1/whatsapp or 127.0.0.1:3000/api/v1/whatsapp

  2. Try to use integrated API docs that accesible in localhost:3000/api/v1/whatsapp/docs/ or 127.0.0.1:3000/api/v1/whatsapp/docs/

Using Pre-Build Binaries

  1. Download Pre-Build Binaries from the release page

  2. Extract the zipped file

  3. Copy the .env.default file as .env file

  4. Run the pre-build binary

# MacOS / Linux
chmod 755 go-whatsapp-multidevice-rest
./go-whatsapp-multidevice-rest

# Windows
# You can double click it or using PowerShell
.\go-whatsapp-multidevice-rest.exe
  1. Now it should be accessible in your machine by accessing localhost:3000/api/v1/whatsapp or 127.0.0.1:3000/api/v1/whatsapp

  2. Try to use integrated API docs that accesible in localhost:3000/api/v1/whatsapp/docs/ or 127.0.0.1:3000/api/v1/whatsapp/docs/

Build From Source

Below is the instructions to make this source code running:

  1. Create a Go Workspace directory and export it as the extended GOPATH directory
cd <your_go_workspace_directory>
export GOPATH=$GOPATH:"`pwd`"
  1. Under the Go Workspace directory create a source directory
mkdir -p src/github.com/dimaskiddo/go-whatsapp-multidevice-rest
  1. Move to the created directory and pull codebase
cd src/github.com/dimaskiddo/go-whatsapp-multidevice-rest
git clone -b master https://github.com/dimaskiddo/go-whatsapp-multidevice-rest.git .
  1. Run following command to pull vendor packages
make vendor
  1. Link or copy environment variables file
ln -sf .env.development .env
# - OR -
cp .env.development .env
  1. Until this step you already can run this code by using this command
make run
  1. (Optional) Use following command to build this code into binary spesific platform
make build
  1. (Optional) To make mass binaries distribution you can use following command
make release
  1. Now it should be accessible in your machine by accessing localhost:3000/api/v1/whatsapp or 127.0.0.1:3000/api/v1/whatsapp

  2. Try to use integrated API docs that accesible in localhost:3000/api/v1/whatsapp/docs/ or 127.0.0.1:3000/api/v1/whatsapp/docs/

API Access

You can access any endpoint under HTTP_BASE_URL environment variable which by default located at .env file.

Integrated API Documentation can be accessed in <HTTP_BASE_URL>/docs/ or by default it's in localhost:3000/api/v1/whatsapp/docs/ or 127.0.0.1:3000/api/v1/whatsapp/docs/

Running The Tests

Currently the test is not ready yet :)

Built With

  • Go - Go Programming Languange
  • Swag - Go Annotations Converter to Swagger Documentation
  • GoReleaser - Go Automated Binaries Build
  • Make - GNU Make Automated Execution
  • Docker - Application Containerization

Authors

  • Dimas Restu Hidayanto - Initial Work - DimasKiddo

See also the list of contributors who participated in this project

Annotation

You can seek more information for the make command parameters in the Makefile

Owner
Dimas Restu H
A GitHub repository of hectic live journey from a crazy developer O.O
Dimas Restu H
Comments
  • unlimited JWT token, no Expired

    unlimited JWT token, no Expired

    Feature request

    if expired zero

    AUTH_JWT_EXPIRED_HOUR=0
    

    Then AUTH JWT no expired.

    i use api to api to send Whatsapp Message.

    if JWT expired, i need to relogin, and add new jwt to backend apps.

    it can be automatically to call login, but is good if we dont need to do that 😁

  • [WIKI] cURL commands for API methods.

    [WIKI] cURL commands for API methods.

    I managed to work out some of the missing API methods in the Wiki, and am putting the cURL commands below for anyone who needs them.

    # Check if whatsapp account exists?
    curl -X 'GET' \
      "http://127.0.0.1:3000/api/v1/whatsapp/registered?msisdn=$PHONE_NUMBER" \
      -H "Authorization: Bearer $TOKEN" \
      -H 'accept: application/json'
    
    # Send text
    curl -X 'POST' \
      'http://127.0.0.1:3000/api/v1/whatsapp/send/text' \
      -H 'accept: application/json' \
      -H "Authorization: Bearer $TOKEN" \
      -H 'Content-Type: multipart/form-data' \
      -F "msisdn=$PHONE_NUMBER" \
      -F 'message=Hello World'
    
    # Send Image
    curl -X 'POST' \
      'http://127.0.0.1:3000/api/v1/whatsapp/send/image' \
      -H 'accept: application/json' \
      -H "Authorization: Bearer $TOKEN" \
      -H 'Content-Type: multipart/form-data' \
      -F "msisdn=$PHONE_NUMBER" \
      -F 'caption=<Image Caption Here>' \
      -F '[email protected];type=image/jpeg' \
      -F 'viewonce=false'
    
    # Send Video
    curl -X 'POST' \
      'http://127.0.0.1:3000/api/v1/whatsapp/send/video' \
      -H 'accept: application/json' \
      -H "Authorization: Bearer $TOKEN" \
      -H 'Content-Type: multipart/form-data' \
      -F "msisdn=$PHONE_NUMBER" \
      -F 'caption=<Video Caption Here>' \
      -F '[email protected];type=video/mp4' \
      -F 'viewonce=false'
    
    # Send document
    curl -X 'POST' \
      'http://127.0.0.1:3000/api/v1/whatsapp/send/document' \
      -H 'accept: application/json' \
      -H "Authorization: Bearer $TOKEN" \
      -H 'Content-Type: multipart/form-data' \
      -F "msisdn=$PHONE_NUMBER" \
      -F '[email protected];type=application/pdf'
    

    I hope this will help fill in the gaps in the Wiki pages :)

  • Missmatch Authentication and logout

    Missmatch Authentication and logout

    POST remote_ip="127.0.0.1:50810" uri=/api/v1/whatsapp/login INFO[2022-09-10T01:42:00+05:30] Checking WhatsApp Client for 1462465xxxx
    INFO[2022-09-10T01:42:00+05:30] Logging out WhatsApp Client for 1462465xxxx Due to Missmatch Authentication

    auto logout after 1 minute

  • First message show waiting Bug

    First message show waiting Bug

    First message show waiting Bug And if send 4 message . Then 3 received 1 not received. This issue after faw minutes. And big problem first message .. status show sent. But message waiting show .

  • Pre-build binary running on windows getting error WhatsApp Client is not Valid

    Pre-build binary running on windows getting error WhatsApp Client is not Valid

    Able to generate token and QR code but during login (scanning from WhatsApp android app) is showing error as below:

    INFO[2022-12-18T12:10:00+05:30] Checking WhatsApp Client for 91981833xxxx INFO[2022-12-18T12:10:00+05:30] Logging out WhatsApp Client for 91981833xxxx Due to Missmatch Authentication

    Want to share one more information. Yesterday mobile app got updated for new WhatsApp update. Can this be a reason?

  • how to add new session?

    how to add new session?

    i have one session, and success auth to whatsapp, but i need multiple session, and i get it when i try to add new session image can you help me for this? its bug? or what?

  • Return messageid in response

    Return messageid in response

    It is necessary, in addition to the status, when sending a message, to return the messageid in order to be able to track the status of the sent messages in the future (sent, delivered, read)

  • group action

    group action

    At the level of the idea, what would come from the functionality of groups Group list Group invitation Create a group Add/remove contacts to groups Assign/remove a group administrator

An experimental Go application that allows an SSH session to interact with the clipboard of the host machine and forward calls to open

Remote Development Manager An experimental Go application that allows an SSH session to interact with the clipboard of the host machine and forward ca

Dec 27, 2022
Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration

Karmada Karmada: Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration Karmada (Kubernetes Armada) is a Kubernetes management system that enables

Dec 30, 2022
nano-gpu-agent is a Kubernetes device plugin for GPU resources allocation on node.
nano-gpu-agent is a Kubernetes device plugin for GPU resources allocation on node.

Nano GPU Agent About this Project Nano GPU Agent is a Kubernetes device plugin implement for gpu allocation and use in container. It runs as a Daemons

Dec 29, 2022
Fleet - Open source device management, built on osquery.
Fleet - Open source device management, built on osquery.

Fleet - Open source device management, built on osquery.

Dec 30, 2022
OpenAIOS vGPU scheduler for Kubernetes is originated from the OpenAIOS project to virtualize GPU device memory.
OpenAIOS vGPU scheduler for Kubernetes is originated from the OpenAIOS project to virtualize GPU device memory.

OpenAIOS vGPU scheduler for Kubernetes English version|中文版 Introduction 4paradigm k8s vGPU scheduler is an "all in one" chart to manage your GPU in k8

Jan 3, 2023
NVIDIA device plugin for Kubernetes

NVIDIA device plugin for Kubernetes Table of Contents About Prerequisites Quick Start Preparing your GPU Nodes Enabling GPU Support in Kubernetes Runn

Dec 31, 2022
NVIDIA device plugin for Kubernetes

NVIDIA device plugin for Kubernetes Table of Contents About Prerequisites Quick Start Preparing your GPU Nodes Enabling GPU Support in Kubernetes Runn

Dec 28, 2021
K8s-socketcan - Virtual SocketCAN Kubernetes device plugin

Virtual SocketCAN Kubernetes device plugin This plugins enables you to create vi

Feb 15, 2022
Cheiron is a Kubernetes Operator made with OperatorSDK for reconciling service account and attaching imagePullSecrets to service accounts automatically

anny-co/cheiron NOTE: Cheiron is currently in very early stages of development and and far from anything usable. Feel free to contribute if you want t

Sep 13, 2021
Go-Mongodb API - A sample REST API ( CRUD operations ) created using Golang

Go-Mongodb_API This is a sample REST API ( CRUD operations ) created using the G

May 31, 2022
K8s controller implementing Multi-Cluster Services API based on AWS Cloud Map.

AWS Cloud Map MCS Controller for K8s Introduction AWS Cloud Map multi-cluster service discovery for Kubernetes (K8s) is a controller that implements e

Dec 17, 2022
Rest API for todoapp written in Golang, using clean architecture, CI/CD
Rest API for todoapp written in Golang, using clean architecture, CI/CD

todoapp-backend Rest API for todoapp written in Golang, using Clean Architecture and CI/CD (includes unit tests and integration tests). Using: Web fra

Oct 23, 2022
Golang Rest Api Sample
Golang Rest Api Sample

Golang Rest Api Sample Şimdi localhost’umuzda HTTP requestleri ile çalışan basit

Nov 9, 2022
A seed repository that contains a Go project that accepts input via a REST API and saves data to an Oracle database.

rest-oracle-go-seed A seed repository that contains a Go project that accepts input via a REST API and saves data to an Oracle database. Why Oracle? T

Apr 18, 2022
Koios-rest-go-client - Go Client library for Koios API

Koios API Client Library for Go Koios API is Elastic Cardano Query Layer! A cons

Mar 18, 2022
cluster-api-state-metrics (CASM) is a service that listens to the Kubernetes API server and generates metrics about the state of custom resource objects related of Kubernetes Cluster API.

Overview cluster-api-state-metrics (CASM) is a service that listens to the Kubernetes API server and generates metrics about the state of custom resou

Oct 27, 2022
Multi cluster kubernetes dashboard with batteries included. Build by developers, for developers.

kubetower Multi cluster kubernetes dashboard with batteries included. Built by developers, for developers. Features Restart deployments with one click

Nov 28, 2022
A multi-service dev environment for teams on Kubernetes
A multi-service dev environment for teams on Kubernetes

Tilt Kubernetes for Prod, Tilt for Dev Modern apps are made of too many services. They're everywhere and in constant communication. Tilt powers multi-

Jan 5, 2023