HUB
Sign inSign up

netfloex/whatsapp

By netfloex

•Updated almost 5 years ago

Image
0

965

netfloex/whatsapp repository overview

⁠Whatsapp API

This repo uses Baileys-MD⁠ to create a Socket.IO⁠ api. This project will store the data in a sqlite database, the data can be retrieved by various Socket.IO "endpoints"

⁠Run it in Docker
docker run --init \
	-e TOKEN=secret_password \
	-v $PWD/data:/app/data \
	-p 3000:3000 \
	netfloex/whatsapp
version: "3"

services:
	api:
		image: netfloex/whatsapp
		container_name: whatsapp-api
        volumes:
            - ./data:/app/data
        environment:
            TOKEN: secret_password
        ports:
            - 3000:3000
⁠Creating A Client

Install socket.io-client

yarn add socket.io-client

If you're using typescript I recommend downloading the SocketIO types from here⁠

import { ClientToServer, ServerToClient } from "@typings/SocketIO";
import { io, Socket } from "socket.io-client";

const socket: Socket<ServerToClient, ClientToServer> = io(
	"http://localhost:3000",
	{
		auth: {
			token: "secret_password",
		},
	},
);

socket.emit("chats", async (chats) => {
	console.log(chats[0].name);
	socket.emit(
		"messages.for",
		{ chatId: chats[0].id, length: 10 },
		(messages) => {
			console.log(messages);
		},
	);
});

socket.on("connect_error", console.error);

Tag summary

Content type

Image

Digest

Size

33.9 MB

Last updated

almost 5 years ago

docker pull netfloex/whatsapp