Node.js library for the Arattai messaging API — send messages, media, and build bots.
npm install arattixconst { ArattixBot } = require('arattix');
(async () => {
const arattix = new ArattixBot({ isShowQr: true });
const bot = await arattix.loginWithQr();
// Fetch chats
const chats = await bot.fetchChats({ limit: 20 });
const chatId = Object.keys(chats)[0];
// Send a text message
await bot.sender.sendMessage('Hello from Arattix!', { chat: chats[chatId] });
// Send a file
await bot.sender.sendFile('photo.jpg', 'My caption', { chat: chats[chatId] });
})();Run the simple polling bot:
node Example/simple-bot.jsOr the class-based command bot:
node Example/command-bot.jsconst arattix = new ArattixBot({ isShowQr: true, proxy: null });
const bot = await arattix.loginWithQr();const chats = await bot.fetchChats({ limit: 20 });
const raw = await bot.fetchChatsRaw({ limit: 20 });
const live = await bot.fetchChatsLive({ limit: 20 });const messages = await bot.fetchMessages(chatId, { limit: 20 });// Download to buffer
const { data, contentType, fileName } = await bot.downloadMedia(fileId, chatId);
// Download to file
await bot.downloadMediaToFile(fileId, chatId, './photo.jpg');
// Get download URL
const url = bot.getMediaUrl(fileId, chatId);
// Download thumbnail
const thumb = await bot.downloadMedia(fileId, chatId, { thumbnail: true });if (Bot.isMediaMessage(msg)) {
const info = Bot.getMediaInfo(msg);
console.log(info.fileName, info.mimeType, info.size);
console.log(info.isImage, info.isAudio, info.isVideo);
}await bot.sender.sendMessage('Hello!', { chatId });
await bot.sender.sendFile('./photo.jpg', 'caption', { chatId });
await bot.sender.sendImage('./img.png', 'caption', { chatId });
await bot.sender.sendAudio('./audio.mp3', '', { chatId });
await bot.sender.sendVideo('./video.mp4', '', { chatId });
await bot.sender.sendDocument('./doc.pdf', 'Here', { chatId });
await bot.sender.sendBuffer(buffer, 'file.jpg', { chatId, mimeType: 'image/jpeg' });| Class | Fields |
|---|---|
Chat |
chatId, title, owner, participants, message, lastmsguid |
Message |
msguid, msg |
MediaInfo |
fileId, fileName, mimeType, size, width, height, thumbnail |
Participant |
dname, zuid |
ChatManager |
parseChatData() → { chatId: Chat } |
All API URLs and constants are centralized in src/Defaults/index.js:
const { Defaults } = require('arattix');
console.log(Defaults.WEB_BASE_URL); // https://web.arattai.in
console.log(Defaults.FILE_DOWNLOAD_URL); // https://files.arattai.in/webdownload
console.log(Defaults.DOWNLOAD_SERVICE); // CLIQMIT
