aiofb package


aiofb.api module

class aiofb.api.GraphAPI(access_token=None, session=None, timeout=10)[source]

Bases: object

A Facebook Graph API wrapper.

URL = ''
VERSION = '3.0'
access_token = None

str: API access token

async_timeout = None

int: timeout for HTTP requests

get(path, session=None, **kwargs)[source]

Make a HTTP GET request to the API.

A wrapper to request() for GET requests.

post(path, session=None, **kwargs)[source]

Make a HTTP POST request to the API.

A wrapper to request() for POST requests.

request(method, path, session=None, **kwargs)[source]

Make an HTTP request to the API

method : str
HTTP method
path : str
API endpoint
session : ClientSession, optional
An aiohttp.ClientSession to be used for making the request.
Keyword arguments to be passed to aiohttp request. For more info check
session = None

aiohttp.ClientSession: Aiohttp session.

class aiofb.api.Messenger(access_token=None, session=None, timeout=10)[source]

Bases: aiofb.api.GraphAPI

Messenger Platform API wrapper.

This class provides some additional for accessing Messenger API a bit more conveniently

DEFAULT_USER_PROFILE_FIELDS = ['name', 'first_name', 'last_name', 'profile_pic']

list of str: Default user profile properties to be requested

get_user_profile(psid, fields=None, session=None)[source]

Retrieve user profile information using PSID.

psid : str
fields : list
List of field to be retieved. If not provided Messenger.DEFAULT_USER_PROFILE_FIELDS will be used.
pass_thread_control(data, session=None)[source]

Pass thread control from your app to another app.

data : dict
Data for the handover.
send_message(data, session=None)[source]

Send messages to user

This may include text, attachments, structured message templates, sender actions, and more.

data : dict
Message data.
take_thread_control(data, session=None)[source]

Take thread control from another app.

data : dict
Data for the handover.
update_profile(data, session=None)[source]

Update bot’s Messenger profile properties.

Sets the values of one or more Messenger Profile properties. Only properties set in the request body will be overwritten.

To set or update Messenger Profile properties you must have the ‘Administrator’ role for the Page associated with the bot.

data : dict
data for the update

aiofb.exceptions module

exception aiofb.exceptions.GraphAPIException(message='', response=None)[source]

Bases: Exception

Module contents

Top-level package for aiofb.