WPPConnect/WA-Proto is an open-source package providing up-to-date Protocol Buffer (
.proto
) definitions extracted from WhatsApp Web (2.3000.x series). It enables Node.js and TypeScript developers to encode, decode, and work with WhatsApp message structures using the protobufjs library.
- Official WhatsApp Web
.proto
schema for 2.3000.x versions - Ready for use with Node.js and TypeScript
- Ideal for bots, integrations, and WhatsApp research
- Compatible with protobufjs
npm install @wppconnect/wa-proto
Below is an example showing how to use the static build from the dist
folder, accessing the WhatsApp proto definitions directly:
// TypeScript example using the static build from 'dist'
import { waproto } from "@wppconnect/wa-proto";
// // Node.js version
// const { waproto } = require("@wppconnect/wa-proto");
// Create a new message payload
const payload = {
conversation: "Hello from WA-Proto!"
// ...set other fields as needed
};
// Verify the payload
const errMsg = waproto.Message.verify(payload);
if (errMsg) throw Error(errMsg);
// Create a message instance
const message = waproto.Message.create(payload);
// Encode the message to a buffer
const buffer = waproto.Message.encode(message).finish();
// Decode the buffer back to a message
const decoded = waproto.Message.decode(buffer);
console.log("Decoded message:", decoded);
Tip: You can also generate static JS/TS code using
protobufjs-cli
for better TypeScript integration:npx pbjs -t static-module -w commonjs -o dist/index.js WAProto.proto npx pbts -o dist/index.d.ts dist/index.js
Apache 2.0 - See LICENSE for details.