Skip to main content

Python Facebook

A Python wrapper for the Facebook Common API.

Build Status Documentation Status Codecov PyPI

Introduction

We have refactored this library after v0.10.0. If you want to use old version, please see branch v0.

The new structure we will provide like follow show.

docs/docs/images/structure.png

Installing

If you want to use old version you can set version to 0.9.*, And this series will also support with python2.7

You can install this library from pypi:

$pip install --upgrade python-facebook-api
✨🍰✨

Usage

GraphAPI

Now you can use GraphApi class to communicate with Facebook Graph Api.

You can initial GraphApi with three different methods.

  1. if you already have an access token, you can initial with it:

    >>> from pyfacebook import GraphAPI
    >>> api = GraphAPI(access_token="token")
  2. if you want to use app credentials to generate app token:

    >>> from pyfacebook import GraphAPI
    >>> api = GraphAPI(app_id="id", app_secret="secret", application_only_auth=True)
  3. if you want to perform an authorization process to a user:

    >>> from pyfacebook import GraphAPI
    >>> api = GraphAPI(app_id="id", app_secret="secret", oauth_flow=True)
    >>> api.get_authorization_url()
    # ('https://www.facebook.com/dialog/oauth?response_type=code&client_id=id&redirect_uri=https%3A%2F%2Flocalhost%2F&scope=public_profile&state=PyFacebook', 'PyFacebook')
    # let user to do oauth at the browser opened by link.
    # then get the response url
    >>> api.exchange_user_access_token(response="url redirected")
    # Now the api will get the user access token.

Then you can get data from facebook.

Get object data:

>>> api.get_object(object_id="20531316728")
>>> {'name': 'Facebook App', 'id': '20531316728'}

More you can see the code because we still working on new structure.

FacebookAPI

Initial methods same with GraphAPI.

Get user data:

>>> fb.user.get_info(user_id="413140042878187")
>>> User(id='413140042878187', name='Kun Liu')

Get page data:

>>> fb.page.get_info(page_id="20531316728")
>>> Page(id='20531316728', name='Facebook App')

See more in documents.

Features

Now library has cover follows features

Facebook Graph API:

  • Application and Application’s edges

  • Page and Page’s edges

  • User and User’s edges

  • Group and Group’s edges

  • Event and Event’s edges

IG Business Graph API:

  • User and User’s edges

  • Media and Media’s edges

IG Basic Display API:

  • User and User’s edges

  • Media and Media’s edges

SUPPORT

python-facebook-api had been being developed with Pycharm under the free JetBrains Open Source license(s) granted by JetBrains s.r.o., hence I would like to express my thanks here.

Jetbrains

Release files for python-facebook-api 0.12.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-facebook-api 0.12.1
File Size Uploaded
python-facebook-api-0.12.1.tar.gz 52.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-facebook-api 0.12.1
File Interpreter ABI Platform
python_facebook_api-0.12.1-py3-none-any.whl Python 3 none any Details

Total release size: 124.3 kB

Release files / python-facebook-api-0.12.1.tar.gz

Download URL python-facebook-api-0.12.1.tar.gz
Size 52.0 kB
Tags Source
SHA-256 checksum
How to use checksums
173b56274dc3627a34a75a04cc7df01631144a3a00e7f4e6aade2769f2008605
BLAKE2b-256 checksum
How to use checksums
edbfd6cd5aa1c7cfb4327a344b0c5b6d5137be8b79e0d846ad71b1ad6fd1af8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.8.2 Linux/5.8.0-1042-azure

Release files / python_facebook_api-0.12.1-py3-none-any.whl

Download URL python_facebook_api-0.12.1-py3-none-any.whl
Size 72.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9602eadfa0a09f7d19940d662bb73371218089edd72b5651d9b4e68502b166b5
BLAKE2b-256 checksum
How to use checksums
80dcb5dd4a2dae01ddc882c0f897e5ddb34621bc468d40b810554b0e41571983
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.8.2 Linux/5.8.0-1042-azure

Release history Release notifications | RSS feed

0.24.0

2 release files

0.20.0

2 release files

0.19.0

2 release files

0.18.0

2 release files

0.17.1

2 release files

0.15.0

2 release files

0.14.3

2 release files

0.14.2

2 release files

0.14.1

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.12.2

2 release files

This release

0.12.1 This release

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3

2 release files

0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page