npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

github-bot-fca

v1.5.3

Published

A Facebook chat API

Readme

⚡ Koja Project — Facebook Chat API

🚀 A faster, experimental fork of the main Facebook Chat API repo.
⚙️ Expect new features earlier — and possibly a few extra bugs.


🧩 Overview

Koja Project Facebook Chat API is an unofficial API that enables automation for Facebook Messenger by emulating browser behavior.
It performs the same GET and POST requests as the web client — allowing you to interact programmatically with Messenger.

🛑 Disclaimer:
This project is not affiliated with Facebook.
Use responsibly — spammy or automated behavior can result in account bans.
Avoid sending bulk messages, suspicious URLs, or excessive login attempts.

📖 For projects built on top of this API, see Projects Using This API.


📦 Installation

Stable Release

If you just want to use the latest stable version:

npm install github-bot-fca@latest

🧪 Bleeding Edge (GitHub)

Want the newest features (and bugs)? Install directly from GitHub:

npm install github-bot-fca@latest

🧠 Testing Bots Safely

To test bots without risking your main Facebook account, use
👉 Facebook Whitehat Accounts


💡 Example Usage

const login = require("github-bot-fca");

// Simple echo bot
login({ email: "FB_EMAIL", password: "FB_PASSWORD" }, (err, api) => {
  if (err) return console.error(err);

  api.listen((err, message) => {
    api.sendMessage(message.body, message.threadID);
  });
});

🖼️ Example Result:


📚 Documentation

Full documentation available in DOCS.md.


🔧 Main Functionality

✉️ Sending a Message

api.sendMessage(message, threadID[, callback][, messageID])

You can send:

  • 💬 Regular messagesbody: "Hello!"
  • 😄 Stickersticker: "STICKER_ID"
  • 📎 File/Imageattachment: fs.createReadStream("image.jpg")
  • 🌐 URLurl: "https://example.com"
  • ❤️ Emojiemoji: "😀", emojiSize: "large"

💡 Tip:
To find your own userID, check your cookies — it’s under c_user.

Example: Basic Message

api.sendMessage("Hey!", "000000000000000");

Example: File Upload

const fs = require("fs");
api.sendMessage({
  body: "Hey!",
  attachment: fs.createReadStream(__dirname + "/image.jpg")
}, "000000000000000");

💾 Saving Sessions

Avoid logging in every time by saving your AppState (cookies, tokens, etc.):

const fs = require("fs");
const login = require("github-bot-fca");

login({ email: "FB_EMAIL", password: "FB_PASSWORD" }, (err, api) => {
  if (err) return console.error(err);
  fs.writeFileSync("appstate.json", JSON.stringify(api.getAppState()));
});

🔁 Or use c3c-fbstate to generate fbstate.json.


👂 Listening to Chats

api.listen(callback)

You can listen for new messages, events, and more.
Enable extra options like event listening or self messages via:

api.setOptions({ listenEvents: true, selfListen: true });

Example: Simple Echo Bot

const fs = require("fs");
const login = require("github-bot-fca");

login({ appState: JSON.parse(fs.readFileSync("appstate.json", "utf8")) }, (err, api) => {
  if (err) return console.error(err);

  api.setOptions({ listenEvents: true });

  const stopListening = api.listenMqtt((err, event) => {
    if (err) return console.error(err);
    api.markAsRead(event.threadID, () => {});

    switch (event.type) {
      case "message":
        if (event.body === "/stop") {
          api.sendMessage("👋 Goodbye!", event.threadID);
          return stopListening();
        }
        api.sendMessage("🤖 BOT: " + event.body, event.threadID);
        break;
      case "event":
        console.log(event);
        break;
    }
  });
});

❓ FAQs

1. How do I run tests?
Create test-config.json (like example-config.json) in /test and run:

npm test

2. Why doesn't sendMessage work for pages?
Pages can’t start new conversations — this is a Facebook restriction.

3. login doesn’t work?
Make sure you can log in via browser first.
If you have 2FA, read about handling approvals in login.

4. How do I avoid logging in every time?
Use api.getAppState() and store it in a file to reuse sessions.

5. Can I send messages as a Page?
Yes:

login(credentials, { pageID: "000000000000000" }, (err, api) => { ... });

6. Getting SyntaxError: Unexpected token [?
Update your Node.js — older versions don’t support new syntax.

7. Too much console logging?
Silence logs with:

api.setOptions({ logLevel: "silent" });

🧠 Projects Using This API

  • 🧩 c3c — Customizable bot framework supporting Facebook & Discord.
  • 🤖 KOJA-PROJECT-bot — A simple Facebook Messenger Bot made by Koja Jutt.

🪪 License & Credits

  • 🧠 Original project inspired by the community at facebook-chat-api
  • 🧑‍💻 Modified & maintained by the Koja Project Team

⭐ If this project helped you, give it a star on GitHub!

It helps others discover it and keeps the project alive. 💖