Sign inSign up

wsapichat/wsapi

By wsapichat

•Updated 23 days ago

Go Rest API for Whatsapp

Image
0

2.7K

wsapichat/wsapi repository overview

⁠WSAPI

A Go REST API for WhatsApp built on whatsmeow⁠. Run multiple WhatsApp sessions behind a single HTTP API with webhook or Redis event delivery.

Multi-arch image — supports linux/amd64 and linux/arm64.

⁠Quick Start

docker run -d \
  -p 8080:8080 \
  -v $(pwd)/data:/app/data \
  -e WSAPI_ADMIN_API_KEY=my-secret-admin-key \
  -e WSAPI_DEFAULT_API_KEY=my-secret-instance-key \
  wsapichat/wsapi:latest

Verify it's running:

curl http://localhost:8080/health

⁠Docker Compose

services:
  wsapi:
    image: wsapichat/wsapi:latest
    ports:
      - "8080:8080"
    volumes:
      - ./data:/app/data
    environment:
      WSAPI_ADMIN_API_KEY: my-secret-admin-key
      WSAPI_DEFAULT_API_KEY: my-secret-instance-key

⁠Usage

⁠1. Create an instance
curl -X POST http://localhost:8080/admin/instances \
  -H "X-Api-Key: my-secret-admin-key" \
  -H "Content-Type: application/json" \
  -d '{"id": "my-instance"}'
⁠2. Pair your WhatsApp device

QR code — scan with WhatsApp > Linked Devices > Link a Device:

curl http://localhost:8080/session/qr \
  -H "X-Instance-Id: my-instance" \
  -H "X-Api-Key: my-secret-instance-key" \
  --output qr.png

Pair code — enter the code on your phone:

curl http://localhost:8080/session/pair-code/1234567890 \
  -H "X-Instance-Id: my-instance" \
  -H "X-Api-Key: my-secret-instance-key"
⁠3. Send a message
curl -X POST http://localhost:8080/messages/text \
  -H "X-Instance-Id: my-instance" \
  -H "X-Api-Key: my-secret-instance-key" \
  -H "Content-Type: application/json" \
  -d '{"to": "1234567890", "text": "Hello from WSAPI!"}'

⁠Configuration

All configuration is done via environment variables. Key settings:

VariableDescriptionDefault
WSAPI_PORTHTTP port8080
WSAPI_DB_DRIVERApp store driver (sqlite/postgres)sqlite
WSAPI_DB_DSNApp store DSN./data/wsapi.db
WSAPI_ADMIN_API_KEYAPI key for admin endpoints
WSAPI_DEFAULT_API_KEYDefault API key for instance endpoints
WSAPI_DEFAULT_WEBHOOK_URLWebhook URL for event delivery
WSAPI_DEFAULT_SIGNING_SECRETHMAC-SHA256 signing secret for webhooks
WSAPI_PUBLISH_VIAEvent delivery method: webhook, redis, or none
WSAPI_LOG_LEVELdebug, info, warn, errorinfo

See the full environment variable reference⁠ for all options.

⁠Volumes

PathDescription
/app/dataSQLite databases (app store + device sessions). Mount this to persist data across container restarts.

Tag summary

Content type

Image

Digest

sha256:b7e5a97af…

Size

25.5 MB

Last updated

23 days ago

docker pull wsapichat/wsapi