fca-nx
v6.6.6
Published
Facebook Messenger API for Node.js — Fast, Secure, and Feature-Rich
Maintainers
Readme
⚡ Lightning Fast · 🔒 Secure · 🌐 90+ Methods · 🛡️ Auto-Healing
FCA-NX is a modern Facebook Messenger API client for Node.js,
built for bots, automation systems, integrations, and advanced Messenger applications.
✨ Features
| Feature | Description | |:---:|---| | ⚡ Lightning Fast | Optimized MQTT communication engine | | 🔒 Security First | Session protection with automatic backups | | 🛡️ Auto-Healing | Automatic recovery from connection problems | | 🔄 Auto Reconnect | Automatically reconnect after disconnects | | 🌐 90+ Methods | Messages, users, threads, reactions and more | | 📡 Real-Time Events | Powerful MQTT event listener | | 💾 Auto Save | Automatic appState protection | | 📢 Broadcasting | Controlled multi-thread broadcasting | | 👥 Thread Tools | Complete group management utilities | | 👤 User Tools | User information and relationship APIs |
📦 Installation
npm install fca-nx
Requirements
- Node.js >= 18.0.0 Check your Node.js version:
node -v
🚀 Quick Start
const { login } = require("fca-nx");
const appState = require("./account.json");
login(
{ appState },
{ listenEvents: true },
(err, api) => {
if (err) {
console.error(err);
return;
}
console.log("╭─────────────────────────────╮");
console.log("│ 🚀 FCA-NX CONNECTED │");
console.log("╰─────────────────────────────╯");
api.autoSaveSession("./account.json", {
interval: 3 * 60 * 1000,
backup: true
});
api.listenMqtt((err, event) => {
if (err) {
console.error("Listen error:", err);
return;
}
if (event.type === "message") {
api.sendMessage(
"🤖 I received: " + event.body,
event.threadID
);
}
});
}
);
🔐 Session Protection
api.autoSaveSession("./account.json");
api.autoSaveSession("./account.json", {
interval: 5 * 60 * 1000,
debounce: 30 * 1000,
backup: true,
maxBackups: 5
});
api.saveSession();
api.restoreFromBackup();
api.stopAutoSave();
💬 Messaging
Send Message
api.sendMessage("Hello world!", threadID);
Send Attachment
const fs = require("fs");
api.sendMessage(
{
body: "Check this out!",
attachment: fs.createReadStream("./photo.jpg")
},
threadID
);
Mentions
api.sendMessage(
{
body: "Hey @John, how are you?",
mentions: [
{
id: "123456789",
tag: "@John",
fromIndex: 4
}
]
},
threadID
);
Sticker
api.sendMessage(
{
sticker: "369239263222822"
},
threadID
);
Location
api.sendMessage(
{
location: {
latitude: 23.8103,
longitude: 90.4125,
current: true
}
},
threadID
);
📡 Mass Broadcasting
const result = await api.sendBroadcast(
"📢 Important announcement!",
[
"thread_id_1",
"thread_id_2",
"thread_id_3"
],
{
parallel: 3,
delay: 2000,
onProgress: (sent, total) => {
console.log(`📊 Progress: ${sent}/${total}`);
}
}
);
console.log(`✅ Sent: ${result.success}`);
console.log(`❌ Failed: ${result.failed}`);
👥 Thread Management
const info = await api.getThreadInfo(threadID);
const threads = await api.getThreadList(20);
const history = await api.getThreadHistory(threadID, 50);
const groupID = await api.createGroup("New Group", ["user1", "user2"]);
await api.addUserToGroup(userID, threadID);
await api.removeUserFromGroup(userID, threadID);
await api.setTitle("New Group Name", threadID);
await api.changeThreadColor("#0084FF", threadID);
await api.changeThreadEmoji("🔥", threadID);
await api.changeNickname("Captain", threadID, userID);
await api.changeGroupImage(fs.createReadStream("./group.png"), threadID);
await api.changeAdminStatus(threadID, userID, true);
await api.createPoll(
"What's your favorite color?",
threadID,
{
Red: false,
Blue: false,
Green: false
}
);
👤 User Operations
const user = await api.getUserInfo(userID);
const userV2 = await api.getUserInfoV2(userID);
const users = await api.getUserID("John Doe");
const uid = await api.getUID("[https://facebook.com/username](https://facebook.com/username)");
const friends = await api.getFriendsList();
const avatar = await api.getAvatarUser(userID);
// Relationship Management
await api.sendFriendRequest(userID);
await api.handleFriendRequest(userID, true);
await api.changeBlockedStatus(userID, true);
await api.unfriend(userID);
🖼️ Profile Management
await api.changeAvatar(fs.createReadStream("./avatar.jpg"));
await api.changeCover(fs.createReadStream("./cover.jpg"));
await api.changeBio("Powered by FCA-NX");
😍 Reactions & Interactions
await api.setMessageReaction("❤️", messageID, threadID);
await api.setMessageReaction("", messageID); // Remove reaction
await api.reactToPost(postID, "😂");
await api.sendMessage("Nice message!", threadID, null, messageID); // Reply
🔧 Message Actions
await api.editMessage("Updated text", messageID);
await api.unsendMessage(messageID);
await api.deleteMessage([messageID1, messageID2]);
await api.forwardAttachment(attachmentID, [userID]);
const attachments = await api.uploadAttachment([
fs.createReadStream("./file.pdf")
]);
await api.markAsRead(threadID);
await api.markAsReadAll();
await api.sendTypingIndicator(threadID, true);
🌐 HTTP Utilities
// GET
api.httpGet("[https://api.example.com](https://api.example.com)", { param: "value" }, (err, data) => {
console.log(data);
});
// POST
api.httpPost("[https://api.example.com](https://api.example.com)", { key: "value" }, (err, data) => {
console.log(data);
});
// Form Data
api.httpPostFormData("[https://api.example.com](https://api.example.com)", { file: fs.createReadStream("./file.jpg") }, (err, data) => {
console.log(data);
});
⚙️ Configuration
| Option | Type | Default | Description | |---|---|---|---| | selfListen | boolean | false | Receive own messages | | listenEvents | boolean | true | Receive thread events | | listenTyping | boolean | false | Receive typing events | | updatePresence | boolean | false | Receive online status | | autoMarkDelivery | boolean | false | Auto mark delivered | | autoMarkRead | boolean | false | Auto mark read | | autoReconnect | boolean | true | Auto reconnect | | online | boolean | false | Appear online | | proxy | string | null | HTTP proxy | | userAgent | string | null | Custom User-Agent | | emitReady | boolean | false | Emit ready event |
🔑 Login Methods
AppState
const { login } = require("fca-nx");
const appState = require("./account.json");
login({ appState }, options, callback);
Email & Password
login(
{
email: "[email protected]",
password: "your_password"
},
options,
callback
);
Email/password authentication may require additional verification.
🧩 API Architecture
api
│
├── messages
│ ├── send
│ ├── edit
│ ├── delete
│ ├── unsend
│ ├── react
│ └── uploadAttachment
│
├── threads
│ ├── createGroup
│ ├── getInfo
│ ├── getList
│ ├── addUsers
│ ├── removeUser
│ ├── setTitle
│ └── setNickname
│
├── users
│ ├── getID
│ ├── getInfo
│ ├── getInfoV2
│ └── getFriends
│
├── account
│ ├── changeAvatar
│ ├── changeCover
│ ├── changeBio
│ ├── handleFriendRequest
│ ├── changeBlockedStatus
│ └── logout
│
└── realtime
├── listen
├── stop
└── middleware
🏗️ Architecture
┌─────────────────────┐
│ Your Bot / App │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ FCA-NX │
├─────────────────────┤
│ API Layer │
│ MQTT Engine │
│ Session Manager │
│ Auto Healing │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Facebook Services │
│ │
└─────────────────────┘
🛡️ Best Practices
- Always use AppState
- Enable automatic session backups
- Use listenMqtt for real-time events
- Handle connection errors properly
- Use controlled broadcasting
- Keep session files private
- Never publish account credentials
- Keep FCA-NX updated
🤝 Contributing
git clone [https://github.com/xalmandevv/fca-nx.git](https://github.com/xalmandevv/fca-nx.git)
cd fca-nx
git checkout -b feature/amazing
git add .
git commit -m "Add amazing feature"
git push origin feature/amazing
Then open a Pull Request.
📄 License
MIT License — Free to use, modify, and distribute.
