How chrishubert/whatsapp-api works
WhatsApp REST API wraps whatsapp-web.js, letting clients manage named WhatsApp sessions and perform messaging, chat, contact, and group operations over HTTP. The main flow is an API request through Express routing and session validation to a controller, which invokes the session’s WhatsApp client and returns a result. Session lifecycle and local authentication support restoration; client events can dispatch configurable webhook callbacks. The graph reflects the sampled controllers and session code plus README capabilities; unsampled route and event wiring is represented only where documented.
Main entry points: sessions.js Session Runtime · routes.js API Routes · app.js Express App · sessionController.js Session API
Components 18
HTTP API
- Express App
src/app.js - API Routes
src/routes.js - Request Middleware
src/middleware.js - Session API
src/controllers/sessionController.js - Health API
src/controllers/healthController.js
Session Runtime
- Session Runtime
src/sessions.js - Local Session Data
src/sessions.js - Runtime Config
src/config.js
WhatsApp Operations
- Client Operations
src/controllers/clientController.js - Chat Operations
src/controllers/chatController.js - Message Operations
src/controllers/messageController.js - Contact Operations
src/controllers/contactController.js - Group Operations
src/controllers/groupChatController.js
External Integrations
- Callback Utilities
src/utils.js - WhatsApp Web
Other components
- API Consumer
- Webhook Endpoint
- WhatsApp User
Connections 29
- API Consumer → Express App: sends requests
- Express App → API Routes: mounts routes
- API Routes → Request Middleware: validates requests
- API Routes → Session API: dispatches session
- API Routes → Health API: dispatches health
- API Routes → Client Operations: dispatches client
- API Routes → Chat Operations: dispatches chat
- API Routes → Message Operations: dispatches message
- API Routes → Contact Operations: dispatches contact
- API Routes → Group Operations: dispatches group
- Express App → Session Runtime: restores sessions
- Session API → Session Runtime: manages sessions
- Session API → Local Session Data: reads QR state
- Session Runtime → Local Session Data: persists auth
- Session Runtime → Runtime Config: reads settings
- Client Operations → Session Runtime: gets session client
- Chat Operations → Session Runtime: gets session client
- Message Operations → Session Runtime: gets session client
- Contact Operations → Session Runtime: gets session client
- Group Operations → Session Runtime: gets session client
- Session Runtime → WhatsApp Web: initializes client
- Client Operations → WhatsApp Web: invokes client API
- Chat Operations → WhatsApp Web: invokes chat API
- Message Operations → WhatsApp Web: invokes message API
- Contact Operations → WhatsApp Web: invokes contact API
- Group Operations → WhatsApp Web: invokes group API
- WhatsApp User → WhatsApp Web: scans QR
- Session Runtime → Callback Utilities: triggers callbacks
- Callback Utilities → Webhook Endpoint: posts events