fca-sifu
v1.0.4
Published
A modern Facebook Chat API for Node.js Build by SIFAT— real-time MQTT messaging, auto session revival, encrypted vault, smart rate-limiting, and a full Messenger surface. Drop-in compatible with popular bot frameworks.
Maintainers
Readme
Install · Quick Start · API Reference · Stealth System · Themes · FAQ
Overview
FCA-SIFU is a drop-in Facebook Chat API built for longevity. It replaces polling with a direct MQTT connection, wraps every session in a layered protection stack, and exposes the full Messenger surface through a clean async API.
Works out of the box with Goat-Bot V2, Mirai, MARIN-BOT-V1, and any bot that previously used fca-unofficial.
Feature Matrix
| Area | What you get |
|------|-------------|
| Transport | MQTT-first, sub-second delivery, auto-reconnect |
| Session | Cookie + email/password login, TOTP 2FA support |
| Stealth | Identity rotation, warmup mode, circuit breaker |
| Reliability | Auto-revival, token refresh cycle, session watchdog |
| Rate limiting | Adaptive gate — stays under Facebook's thresholds |
| Vault | AES-encrypted runtime secret store (SifuCipher) |
| Messaging | Send, edit, react, unsend, forward, broadcast |
| Threads | Create, manage, archive, delete, theme, emoji |
| AI Themes | Generate Messenger themes from a text prompt |
| Media | Attachments, images, video, location, stickers |
| Users | Profile, avatar, bio, cover, friends, block |
| Groups | Create, admin, image, polls, notes, add/remove |
| TypeScript | Full .d.ts type definitions included |
Install
npm install fca-sifuRequires Node.js ≥ 18
Quick Start
const login = require("fca-sifu");
login({ appState: require("./appstate.json") }, (err, api) => {
if (err) return console.error(err);
api.setOptions({
listenEvents: true,
autoMarkDelivery: true,
autoMarkRead: false,
});
api.listenMqtt((err, event) => {
if (err) return console.error(err);
if (event.type === "message" && event.body === "/ping") {
api.sendMessage("pong", event.threadID);
}
});
});Both callback and Promise styles are supported on every method.
Login Options
Export cookies from your browser with a tool like C3C FBState, save as appstate.json, then:
login({ appState: require("./appstate.json") }, callback);login({ email: "[email protected]", password: "••••••••" }, callback);login({
email: "[email protected]",
password: "••••••••",
totpSecret: "YOUR_TOTP_SECRET",
}, callback);login(credentials, {
online: true,
selfListen: false,
listenEvents: true,
autoMarkDelivery: true,
autoReconnect: true,
proxy: "http://user:pass@host:port",
}, callback);API Reference
Messaging
// Send
api.sendMessage("Hello!", threadID);
api.sendMessage({ body: "look", attachment: fs.createReadStream("img.png") }, threadID);
// Edit / delete
api.editMessage("corrected text", messageID);
api.unsendMessage(messageID);
// Forward
api.forwardMessage(messageID, threadID);
api.broadcastMessage("Announcement", [id1, id2, id3]);
// Schedule (sends after delay)
api.scheduleMessage("Reminder!", threadID, Date.now() + 60_000);Reactions & Receipts
api.setMessageReaction("❤️", messageID);
api.markAsRead(threadID);
api.markAsDelivered(threadID);
api.markAsReadAll();
// Auto-unsend any message the bot sent when someone reacts
api.unsendOnReaction(); // all reactions
api.unsendOnReaction({ triggers: ["😡","👎"] }); // specific reactions
api.unsendOnReaction.disable();Call
unsendOnReaction()beforelistenMqtt()so it can hook into the stream.
Threads
api.getThreadInfo(threadID);
api.getThreadHistory(threadID, 30, null);
api.getThreadList(10, null, ["INBOX"]);
api.changeNickname("Bot", threadID, userID);
api.changeGroupImage(imageStream, threadID);
api.changeThreadName("New name", threadID);
api.createNewGroup([uid1, uid2], "Group name");
api.addUserToGroup(userID, threadID);
api.removeUserFromGroup(userID, threadID);
api.changeAdminStatus(threadID, userID, true);
api.createPoll("Question?", threadID, { "Yes": true, "No": false });Users & Friends
api.getUserInfo(userID);
api.getUserInfoV2(userID);
api.getFriendsList();
api.addFriend(userID);
api.changeAvatar(imageStream);
api.changeBio("New bio");Real-time
api.listenMqtt(callback); // start listener
api.stopListening(); // stop listener
api.isSessionAlive(); // → Promise<boolean>
api.getHealthStatus(); // MQTT, rate-limiter, token cycle statsSession & Tokens
api.getAppState(); // export current cookie state
api.refreshTokens(); // force token refresh
api.getCycleStatus(); // token cycle health
api.disconnect(); // graceful logoutAI Themes
Generate and apply Messenger themes from a natural-language prompt.
// Generate themes
const themes = await api.createAITheme("ocean sunset", 3);
console.log(themes[0].name, themes[0].preview_image_urls.light_mode);
// Apply a theme to a thread
await api.setThreadTheme(threadID, { themeId: themes[0].id });
// Or use the unified theme() helper
await api.theme("ai:dark neon galaxy", threadID);
await api.theme("list", threadID); // list all available themes
await api.theme("ocean", threadID); // fuzzy match by name
await api.theme("undo", threadID); // revert to previous
// Full AI theme producer (structured output)
const result = await api.produceMetaTheme("aurora borealis", { numThemes: 2 });
console.log(result.themes[0].colors.gradient);Stealth System
Four cooperating managers run automatically after login:
┌─────────────┬─────────────────────────────────────────────────┐
│ Shield │ Circuit breaker + warmup mode on fresh starts │
│ Revive │ Detects expired sessions and re-authenticates │
│ Heartbeat │ Refreshes auth tokens before expiry │
│ Gate │ Adaptive rate-limiter, respects FB thresholds │
└─────────────┴─────────────────────────────────────────────────┘You can inspect or control them at runtime:
api.shield.getStatus();
api.shield.reset();
api.isAutoReviveActive();
api.enableAutoRevive(false);
const { globalRateLimiter, globalShield, globalMonitor } = require("fca-sifu");
globalRateLimiter.pause(5000);
globalShield.setDailyLimit(200);Encrypted Vault
const { globalCipher } = require("fca-sifu");
globalCipher.set("myToken", "secret-value");
globalCipher.get("myToken"); // decrypted
globalCipher.delete("myToken");Top-level Exports
const {
connect, // login function
globalShield, // circuit breaker
globalReviveManager, // session revival
globalGate, // rate limiter
globalRateLimiter, // rate limiter (alias)
globalMonitor, // telemetry
globalCache, // in-memory cache
globalCipher, // encrypted vault
CycleManager, // token refresh
TokenRefreshManager,
SifuCipher,
configureRateLimiter,
getRateLimiterStats,
} = require("fca-sifu");Compatibility
| Framework | Status | |-----------|--------| | Goat-Bot V2 | Drop-in | | Mirai | Drop-in | | MARIN-BOT-V1 | Drop-in | | fca-unofficial | Drop-in replacement | | Custom bots | Full support |
FAQ
const [api1, api2] = await Promise.all([
login({ appState: state1 }),
login({ appState: state2 }),
]);Each call returns an independent API instance with its own session.
Disclaimer
This project is not affiliated with, endorsed by, or sponsored by Meta Platforms. Use at your own risk and in accordance with Facebook's Terms of Service. The maintainers accept no liability for account actions taken by Meta.
License
MIT © 2026 SIFAT
If FCA-SIFU saved you time, a ⭐ on GitHub goes a long way.
