Skip to main content

Facebook Messenger library for Python/Asyncio.

Project description

Project version Supported python versions: 3.5, 3.6, 3.7, 3.8 and pypy License: BSD 3-Clause Documentation Travis CI Code style

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!

Version Warning

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.

Caveats

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!

Installation

$ 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

Example Usage

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.

Maintainer

Acknowledgements

This project was originally inspired by facebook-chat-api.

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fbchat-asyncio-0.6.3.tar.gz (54.2 kB view hashes)

Uploaded Source

Built Distribution

fbchat_asyncio-0.6.3-py3-none-any.whl (64.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page