Skip to main content

fca-unofficial: Unofficial Facebook Chat API for Python

Project description

python-facebookapi

python-facebookapi: Unofficial Facebook Messenger API (Python) developed by Adnan Sami Bhuiyan.

Status: Experimental WIP. Supports cookie-based login (appState) and basic HTTP wrappers. MQTT realtime and full endpoint parity are in progress.

Install (editable)

  • Local development: use pip in editable mode from this folder.

Quickstart

from python_facebookapi import login

api = login({"appState": [
    {"key": "c_user", "value": "123456789"},
    {"key": "xs", "value": "..."},
    # other cookies
]})

print("Logged in as:", api.get_current_user_id())
status, res = api.httpGet("https://www.facebook.com/")
print(status)

MQTT realtime (preview)

from python_facebookapi import login

api = login({"appState": [
    {"key": "c_user", "value": "123456789"},
    {"key": "xs", "value": "..."},
]})

def on_event(err, event):
    if err:
        print("MQTT error:", err)
        return
    print("event:", event)

listener = api.listenMqtt(on_event)

# Send a message via MQTT
api.sendMessageMqtt("Hello MQTT", threadID="<THREAD_ID>")

# React to a message
api.setMessageReactionMqtt("<MESSAGE_ID>", "🙂", threadID="<THREAD_ID>")

# Typing indicator
api.sendTypingIndicatorV2("<THREAD_ID>", True)

# Admin actions
api.nickname("Cool Guy", "<THREAD_ID>", participantID="<USER_ID>")
api.gcname("New Group Name", "<THREAD_ID>")
api.gcmember("add", ["<USER_ID>"], "<THREAD_ID>")
api.gcrule("admin", "<USER_ID>", "<THREAD_ID>")
api.pinMessage("pin", "<THREAD_ID>", "<MESSAGE_ID>")

# Stop listener when done
listener.stop()

Dependencies for realtime: paho-mqtt, websocket-client (declared in pyproject).

Run tests (optional)

If you have pytest installed in your environment:

pytest -q

Notes

  • Use valid cookies (appState). Email/password login is intentionally not implemented.
  • For proxies, pass options={"proxy": "http://host:port"}.
  • Headers are randomized with realistic UA strings.

Project details


Download files

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

Source Distribution

fca_unofficial-0.0.1.tar.gz (38.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fca_unofficial-0.0.1-py3-none-any.whl (52.2 kB view details)

Uploaded Python 3

File details

Details for the file fca_unofficial-0.0.1.tar.gz.

File metadata

  • Download URL: fca_unofficial-0.0.1.tar.gz
  • Upload date:
  • Size: 38.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for fca_unofficial-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8568d0387a6bd3b0805e7d3420fe4f8f3d798095f00fc095e3183ee5d38df07d
MD5 66389b233c78f3acdc1b483a8dc5cad9
BLAKE2b-256 734ed2d3c5c8d0a8e4a1b793fb0df1e18d2f1131e44e1b6d7911e70f70edc8af

See more details on using hashes here.

File details

Details for the file fca_unofficial-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: fca_unofficial-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 52.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for fca_unofficial-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b43584153a7e91132f0ec7bef04fa46adb9d5b2d187b95a561e8a9f3092a5375
MD5 d7e92da124d452e5d0446d46edc7199e
BLAKE2b-256 49d874b896aff41c75c7faad43b9c56ddf3cae53d4cedb1f4da21f7b56b91250

See more details on using hashes here.

Supported by

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