python-facebook-api


Namepython-facebook-api JSON
Version 0.20.1 PyPI version JSON
download
home_pagehttps://github.com/sns-sdks/python-facebook
SummaryA simple Python wrapper around the Facebook Graph API
upload_time2024-10-08 08:37:31
maintainerNone
docs_urlNone
authorIkaros kun
requires_python<4.0,>=3.7
licenseApache-2.0
keywords facebook-graph-api facebook-sdk instagram-api instagram-sdk facebook-api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            Python Facebook
---------------

A Python wrapper for the Facebook & Instagram Graph APIs.

.. image:: https://github.com/sns-sdks/python-facebook/workflows/Test/badge.svg
    :target: https://github.com/sns-sdks/python-facebook/actions
    :alt: Build Status

.. image:: https://img.shields.io/badge/Docs-passing-brightgreen
    :target: https://sns-sdks.github.io/python-facebook/
    :alt: Documentation Status

.. image:: https://codecov.io/gh/sns-sdks/python-facebook/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/sns-sdks/python-facebook
    :alt: Codecov

.. image:: https://img.shields.io/pypi/v/python-facebook-api.svg
    :target: https://pypi.org/project/python-facebook-api
    :alt: PyPI


============
Introduction
============

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

The new structure is as follows

.. image:: docs/docs/images/structure.png


.. note::

    This new structure may still change.

    Now, you can use base class ``GraphAPI`` to get data.

==========
Installing
==========

You can install this library from ``pypi``::

    pip install --upgrade python-facebook-api

.. note::

    If you want to use an old version, you can set the version to ``0.9.*``, which also supports Python 2.7.

=====
Usage
=====

--------
GraphAPI
--------

You can use the ``GraphAPI`` class to communicate with the Facebook Graph API.

You can initialize a ``GraphAPI`` object with three different methods, depending on your needs.

1. If you already have an access token, you can initialize it with ::

    >>> from pyfacebook import GraphAPI
    >>> api = GraphAPI(access_token="token")

2. If you need to generate an app token automatically using the app/client ID and secret, you can do ::

    >>> from pyfacebook import GraphAPI
    >>> api = GraphAPI(app_id="id", app_secret="secret", application_only_auth=True)

3. If you want to perform the authorization process for a user, you can do ::

    >>> 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.

For more info about the different access tokens, see https://developers.facebook.com/docs/facebook-login/guides/access-tokens.

Once you have the user access token, you can get the Facebook data. For example,

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

See the code for more operations.

-----------
FacebookAPI
-----------

To get the user data::

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

To get the page data::

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

For more info, please, see the code or the docs.

========
Features
========

The library has the following 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
- Server-Sent Events

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`` has been 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.

.. image:: docs/docs/images/jetbrains.svg
    :target: https://www.jetbrains.com/?from=sns-sdks/python-facebook
    :alt: Jetbrains

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sns-sdks/python-facebook",
    "name": "python-facebook-api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.7",
    "maintainer_email": null,
    "keywords": "facebook-graph-api, facebook-sdk, instagram-api, instagram-sdk, facebook-api",
    "author": "Ikaros kun",
    "author_email": "merle.liukun@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/33/75/0d4a9075a1f7c25e3ea9481fcca0dc48465bbeffee8da09457f232e939fd/python_facebook_api-0.20.1.tar.gz",
    "platform": null,
    "description": "Python Facebook\n---------------\n\nA Python wrapper for the Facebook & Instagram Graph APIs.\n\n.. image:: https://github.com/sns-sdks/python-facebook/workflows/Test/badge.svg\n    :target: https://github.com/sns-sdks/python-facebook/actions\n    :alt: Build Status\n\n.. image:: https://img.shields.io/badge/Docs-passing-brightgreen\n    :target: https://sns-sdks.github.io/python-facebook/\n    :alt: Documentation Status\n\n.. image:: https://codecov.io/gh/sns-sdks/python-facebook/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/sns-sdks/python-facebook\n    :alt: Codecov\n\n.. image:: https://img.shields.io/pypi/v/python-facebook-api.svg\n    :target: https://pypi.org/project/python-facebook-api\n    :alt: PyPI\n\n\n============\nIntroduction\n============\n\nWe have refactored this library after `v0.10.0`. If you want to use the old version, please, see branch ``v0``.\n\nThe new structure is as follows\n\n.. image:: docs/docs/images/structure.png\n\n\n.. note::\n\n    This new structure may still change.\n\n    Now, you can use base class ``GraphAPI`` to get data.\n\n==========\nInstalling\n==========\n\nYou can install this library from ``pypi``::\n\n    pip install --upgrade python-facebook-api\n\n.. note::\n\n    If you want to use an old version, you can set the version to ``0.9.*``, which also supports Python 2.7.\n\n=====\nUsage\n=====\n\n--------\nGraphAPI\n--------\n\nYou can use the ``GraphAPI`` class to communicate with the Facebook Graph API.\n\nYou can initialize a ``GraphAPI`` object with three different methods, depending on your needs.\n\n1. If you already have an access token, you can initialize it with ::\n\n    >>> from pyfacebook import GraphAPI\n    >>> api = GraphAPI(access_token=\"token\")\n\n2. If you need to generate an app token automatically using the app/client ID and secret, you can do ::\n\n    >>> from pyfacebook import GraphAPI\n    >>> api = GraphAPI(app_id=\"id\", app_secret=\"secret\", application_only_auth=True)\n\n3. If you want to perform the authorization process for a user, you can do ::\n\n    >>> from pyfacebook import GraphAPI\n    >>> api = GraphAPI(app_id=\"id\", app_secret=\"secret\", oauth_flow=True)\n    >>> api.get_authorization_url()\n    # ('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')\n    # let user to do oauth at the browser opened by link.\n    # then get the response url\n    >>> api.exchange_user_access_token(response=\"url redirected\")\n    # Now the api will get the user access token.\n\nFor more info about the different access tokens, see https://developers.facebook.com/docs/facebook-login/guides/access-tokens.\n\nOnce you have the user access token, you can get the Facebook data. For example,\n\n    >>> api.get_object(object_id=\"20531316728\")\n    >>> {'name': 'Facebook App', 'id': '20531316728'}\n\nSee the code for more operations.\n\n-----------\nFacebookAPI\n-----------\n\nTo get the user data::\n\n    >>> fb.user.get_info(user_id=\"413140042878187\")\n    >>> User(id='413140042878187', name='Kun Liu')\n\nTo get the page data::\n\n    >>> fb.page.get_info(page_id=\"20531316728\")\n    >>> Page(id='20531316728', name='Facebook App')\n\nFor more info, please, see the code or the docs.\n\n========\nFeatures\n========\n\nThe library has the following features.\n\nFacebook Graph API:\n\n- Application and Application's edges\n- Page and Page's edges\n- User and User's edges\n- Group and Group's edges\n- Event and Event's edges\n- Server-Sent Events\n\nIG Business Graph API:\n\n- User and User's edges\n- Media and Media's edges\n\nIG Basic Display API:\n\n- User and User's edges\n- Media and Media's edges\n\n=======\nSUPPORT\n=======\n\n``python-facebook-api`` has been developed with Pycharm under the free JetBrains Open Source license(s) granted by JetBrains s.r.o.,\nhence I would like to express my thanks here.\n\n.. image:: docs/docs/images/jetbrains.svg\n    :target: https://www.jetbrains.com/?from=sns-sdks/python-facebook\n    :alt: Jetbrains\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A simple Python wrapper around the Facebook Graph API",
    "version": "0.20.1",
    "project_urls": {
        "Homepage": "https://github.com/sns-sdks/python-facebook",
        "Repository": "https://github.com/sns-sdks/python-facebook"
    },
    "split_keywords": [
        "facebook-graph-api",
        " facebook-sdk",
        " instagram-api",
        " instagram-sdk",
        " facebook-api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5e05b7458e4424824b2e4c87e9f84899d7a73ebb1b16e3f33d59cfbe0405b06a",
                "md5": "56c4002a0fc550c347d17650345c8e78",
                "sha256": "e44fd90c7e4ddbc1d6928f35490d4cbf7ff4a9a20453a0eb235ac4e11c45367b"
            },
            "downloads": -1,
            "filename": "python_facebook_api-0.20.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "56c4002a0fc550c347d17650345c8e78",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.7",
            "size": 78644,
            "upload_time": "2024-10-08T08:37:30",
            "upload_time_iso_8601": "2024-10-08T08:37:30.213418Z",
            "url": "https://files.pythonhosted.org/packages/5e/05/b7458e4424824b2e4c87e9f84899d7a73ebb1b16e3f33d59cfbe0405b06a/python_facebook_api-0.20.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "33750d4a9075a1f7c25e3ea9481fcca0dc48465bbeffee8da09457f232e939fd",
                "md5": "2fa444605fd15a37618078fdfe8f2620",
                "sha256": "96617a9f4cd8ff1744b501feb450e38056401cce78652aae1b55e281beb458ca"
            },
            "downloads": -1,
            "filename": "python_facebook_api-0.20.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2fa444605fd15a37618078fdfe8f2620",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.7",
            "size": 58922,
            "upload_time": "2024-10-08T08:37:31",
            "upload_time_iso_8601": "2024-10-08T08:37:31.458299Z",
            "url": "https://files.pythonhosted.org/packages/33/75/0d4a9075a1f7c25e3ea9481fcca0dc48465bbeffee8da09457f232e939fd/python_facebook_api-0.20.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-08 08:37:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sns-sdks",
    "github_project": "python-facebook",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "python-facebook-api"
}
        
Elapsed time: 0.72880s