Python client SDK for Sendbee Public API
Project description
███████╗███████╗███╗ ██╗██████╗ ██████╗ ███████╗███████╗ ██╗ ██╗██████╗ █████╗ ██████╗ ██╗
██╔════╝██╔════╝████╗ ██║██╔══██╗██╔══██╗██╔════╝██╔════╝ ██║ ██║╚════██╗ ██╔══██╗██╔══██╗██║
███████╗█████╗ ██╔██╗ ██║██║ ██║██████╔╝█████╗ █████╗ ██║ ██║ █████╔╝ ███████║██████╔╝██║
╚════██║██╔══╝ ██║╚██╗██║██║ ██║██╔══██╗██╔══╝ ██╔══╝ ╚██╗ ██╔╝██╔═══╝ ██╔══██║██╔═══╝ ██║
███████║███████╗██║ ╚████║██████╔╝██████╔╝███████╗███████╗ ╚████╔╝ ███████╗ ██║ ██║██║ ██║
╚══════╝╚══════╝╚═╝ ╚═══╝╚═════╝ ╚═════╝ ╚══════╝╚══════╝ ╚═══╝ ╚══════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
.' '. __
. . . (__\_
. . . -{{_(|8)
' . . ' ' . . ' (__/
Sendbee Python API Client
Installation
> pip install sendbee-api
Usage
Initialization
from sendbee_api import SendbeeApi
api = SendbeeApi(
'__your_api_key_here__', '__your_secret_key_here__',
'__business_id_here__'
)
Fetch contacts
contacts = api.contacts([tags=['...', ...]], [search_query='...'])
for contact in contacts:
contact.id
contact.name
contact.phone
contact.email
contact.created_at
contact.tags
Subscribe contact
contact = api.subscribe_contact(
phone='+...', [tags=['...', ...]], [block_notifications=[True|False]]
)
contact.id
contact.name
contact.phone
contact.email
contact.created_at
contact.tags
Fetch tags
tags = api.tags([name='...'])
for tag in tags:
tag.id
tag.name
Create tag
tag = api.create_tag(name='...')
tag.id
tag.name
Update tag
tag = api.update_tag(id='...', name='...')
tag.id
tag.name
Delete tag
tag = api.delete_tag(id='...')
Fetch message templates
templates = api.message_templates([search_query='...'])
for template in templates:
template.id
template.text
template.tags
template.keyword
template.language
template.approved
Send template message
response = api.send_template_message(
phone='+...', template_keyword='...', language='...', tags=['...', ...]
)
response.conversation_id
# save this id, and when you get sent message status requests on
# your webhook, you'll get this same id to identify the conversation
Authenticate webhook request
After activating your webhook URL in Sendbee Dashboard, we will start sending requests on that URL depending on which webhook type is linked with that webhook URL.
Every request that we make will have authorization token in header, like this:
{
...
'X-Authorization': '__auth_token_here__',
...
}
To authenticate requests that we make to your webhook URL, take this token from request header and check it using Sendbee API Client:
from sendbee_api import SendbeeApi
api = SendbeeApi('__your_api_key_here__', '__your_secret_key_here__')
token = '...' # taken from the request header
if api.auth.check_auth_token(token):
print('Weeee... Sendbee sent me the data on my webhook URL \o/ :)')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sendbee_api-0.3.1.tar.gz
(11.4 kB
view hashes)
Built Distribution
Close
Hashes for sendbee_api-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2053176d2cb8c2133521c72cec7957d254dfcb4a0c39eb6dc89f06dee49917a4 |
|
MD5 | 4cebfe68240a98402cd30be12f2c9b75 |
|
BLAKE2b-256 | f66fb46843ed0fd1ffab5b87a71c00d809c3ce6e545afc39586f305945d6770a |