Baileys is a simple, fast and easy to use WhatsApp Web API written in TypeScript. It is designed to be simple to use and is optimized for usage in Node.js.
An implementation of @WhiskeySockets/Baileys as a simple REST API with multiple device support
Project continued from @ookamiiixd/baileys-api
- NodeJS version 18.19.0 or higher (Recommended version 20 and above)
- Prisma supported databases. Tested on MySQL and PostgreSQL
- Download latest release. If you want to skip the build step, you can download the release (file with the
baileys-api.tgzname pattern) from the release page - Enter to the project directory
- Install the dependencies
npm install- Build the project using the
buildscript
npm run buildYou can skip this part if you're using the prebuilt one from the release page
- Copy the
.env.examplefile and rename it into.env, then update your connection url in theDATABASE_URLfield - Update your provider in the
prisma/schema.prismafile if you're using database other than MySQL - Run your migration
npx prisma migrate (dev|deploy)or push the schema
npx prisma db pushDon't forget to always re-run those whenever there's a change on the prisma/schema.prisma file
# Listening Port HTTP and Socket.ioPORT="3000"# Project Mode (development|production)NODE_ENV="development"# Global URL WebhookURL_WEBHOOK="http://localhost:3000/webhook"# Enable WebhookENABLE_WEBHOOK="true"# Enable websocketENABLE_WEBSOCKET="true"# Name browser botBOT_NAME="Whatsapp Bot"# Database Connection URLDATABASE_URL="mysql://root:@localhost:3306/baileys_api"# Pino Logger LevelLOG_LEVEL="debug"# Reconnect Interval (in Milliseconds)RECONNECT_INTERVAL="5000"# Maximum Reconnect AttemptsMAX_RECONNECT_RETRIES="5"# Maximum SSE QR Generation AttemptsSSE_MAX_QR_GENERATION="10"# Name session configSESSION_CONFIG_ID="session-config"# API Key (for Authorization Header and Socket.io Token)API_KEY="a6bc226axxxxxxxxxxxxxx"- Make sure you have completed the Installation and Setup step
- You can then start the app using the
devfor development andstartscript for production
# Development
npm run dev
# Production
npm run start- Now the endpoint should be available according to your environment variables configuration. Default is at
http://localhost:3000
The API Documentation can fork Postman Collection in your workspace Postman
- I only provide a simple authentication method, please modify according to your own needs.
This project is intended for learning purpose only, don't use it for spamming or any activities that's prohibited by WhatsApp