Skip to main content

A simple Python wrapper around the Facebook Graph API

Project description

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

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

python-facebook-api-0.12.2.tar.gz (52.0 kB view details)

Uploaded Source

Built Distribution

python_facebook_api-0.12.2-py3-none-any.whl (72.4 kB view details)

Uploaded Python 3

File details

Details for the file python-facebook-api-0.12.2.tar.gz.

File metadata

  • Download URL: python-facebook-api-0.12.2.tar.gz
  • Upload date:
  • Size: 52.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.2 Linux/5.8.0-1042-azure

File hashes

Hashes for python-facebook-api-0.12.2.tar.gz
Algorithm Hash digest
SHA256 a88cd8a7a500f1fa04caa4cf56d4957287da792f51e93b762b6e62fdd5bc2be8
MD5 33ab78d05c6582ec20d1cf6a204f6e25
BLAKE2b-256 092ae42a46bdb101b51c58d5d2eabc7ae357d067cc40c3f74d05f3a53ca8d5e9

See more details on using hashes here.

File details

Details for the file python_facebook_api-0.12.2-py3-none-any.whl.

File metadata

File hashes

Hashes for python_facebook_api-0.12.2-py3-none-any.whl
Algorithm Hash digest
SHA256 018a1f5a3577a33ced9e1a89cb6443b6d8fc7246720a7e86d36a24017f2f06a5
MD5 e4330163598a6b1a54f651a3f01e4c5b
BLAKE2b-256 79748882ef4ef75251d962fb8a8fb98fcb439bda270ba8f06e81d0c1c8330dbe

See more details on using hashes here.

Supported by

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