This project is was previously maintained by @madsmtm and @carpedm20, but they both no longer have the time to continue to maintain the project. Therefore, this fork will try to maintain a workable solution until there is a proper maintainer available to add/modify functionality. Follow the discussion in issue 613 for updates on if/when a maintainer has been found.
Most importantly, this code has been maintained in a works for me approach, meaning that any issues that arise from the code fits into two buckets:
- It affects me and I'll try fix it
- It doesn't affect me and I probably won't look at it
If you've read through all that and still want to use the code, you can do the following:
$ python -m pip install git+https://github.com/TimLChan/fbchat.git
A powerful and efficient library to interact with Facebook's Messenger, using just your email and password.
This is not an official API, Facebook has that over here for chat bots. This library differs by using a normal Facebook account instead.
fbchat
currently support:
- Sending many types of messages, with files, stickers, mentions, etc.
- Fetching all messages, threads and images in threads.
- Searching for messages and threads.
- Creating groups, setting the group emoji, changing nicknames, creating polls, etc.
- Listening for, an reacting to messages and other events in real-time.
- Type hints, and it has a modern codebase (e.g. only Python 3.5 and upwards).
async
/await
(COMING).
Essentially, everything you need to make an amazing Facebook bot!
v2
is currently being developed at the master
branch and it's highly unstable. If you want to view the old v1
, go here.
Additionally, you can view the project's progress here.
fbchat
works by imitating what the browser does, and thereby tricking Facebook into thinking it's accessing the website normally.
However, there's a catch! Using this library may not comply with Facebook's Terms Of Service!, so be responsible Facebook citizens! We are not responsible if your account gets banned!
Additionally, the APIs the library is calling is undocumented! In theory, this means that your code could break tomorrow, without the slightest warning! If this happens to you, please report it, so that we can fix it as soon as possible!
With that out of the way, you may go to Read The Docs to see the full documentation!
$ pip install fbchat
If you don't have pip, this guide can guide you through the process.
You can also install directly from source, provided you have pip>=19.0
:
$ pip install git+https://github.com/carpedm20/fbchat.git
import getpass import fbchat session = fbchat.Session.login("<email/phone number>", getpass.getpass()) user = fbchat.User(session=session, id=session.user_id) user.send_text("Test message!")
More examples are available here.
No one, see notice at the top.
This project was originally inspired by facebook-chat-api.