/fbmessengerexport

Export/access you Messenger/Facebook chat messages

Primary LanguagePythonMIT LicenseMIT

Export your personal Facebook chat/Messenger data into an sqlite database.

Main difference from “Download your information” export is that this tool can be run automatically and doesn’t require remembering go onto Facebook website, reentering password, downloading archive, etc.

Note that at the moment it exports text only, images or videos are not exported. I recommend checking the database after initial export to make sure it contains everything you want from the tool! I cleaned up some things I assumed weren’t useful from raw responses, but I could be misinterpreting something as I’m not a heavy Facebook user. Feel free to open a github issue if you think something about storage should be changed.

Setting up

  1. pip3 install --user -r requirements.txt
  2. Login and get cookies: ./export.py --login

    Facebook doesn’t have an API, so you’ll have to use cookies.

    Ideally this step needs to be done once, after that just use cookies to access your data.

    Note that this step might prompt you for two factor auth.

    Also Facebook will likely notify you about unusual login, so make sure to approve it in security settings.

Exporting

Usage:

Recommended: create secrets.py keeping your api parameters, e.g.:

cookies = "COOKIES"

After that, use:

./export.py --secrets /path/to/secrets.py --db /path/to/export.sqlite

That way you type less and have control over where you keep your plaintext secrets.

Alternatively, you can pass parameters directly, e.g.

./export.py --cookies <cookies> --db /path/to/export.sqlite

However, this is verbose and prone to leaking your keys/tokens/passwords in shell history.

I highly recommend checking exported files at least once just to make sure they contain everything you expect from your export. If not, please feel free to ask or raise an issue!

Using data

You can use dal.py (stands for “Data Access/Abstraction Layer”) to access your exported data, even offline. I elaborate on motivation behind it here.

  • main usecase is to be imported as python module to allow for programmatic access to your data.

    You can find some inspiration in =my.= package that I’m using as an API to all my personal data.

  • to test it against your export, simply run: ./dal.py --source /path/to/export
  • you can also try it interactively: ./dal.py --source /path/to/export --interactive