Package: bird-python
Bird's REST API for PythonThis repository contains the open source Python client for New MessageBird's REST API. Documentation can be found at:https://docs.bird.com/api/.RequirementsSign upfor a free MessageBird accountCreate a new access key in the developers sectionsAn application written in Python (tested with Python 2.7 and Python 3.4)InstallationThe easiest way to install the bird_python package is either via pip:$ pip install bird_pythonExamplesWe have put some self-explanatory examples in theexamplesdirectory, but here is a quick example on how to get started. Assuming the installation was successful, you can import the messagebird package like this:importbird_pythonasmessagebirdThen, create an instance ofmessagebird.Client:client=messagebird.Client('YOUR_ACCESS_KEY','YOUR_ORGANIZATION_ID')Now you can query the API for information or send a request. For example, if we want to send a message through any channel like whatsapp, you'd do something like this:try:# Get and set any workspace for sent request to the channels related.client.workspaces=client.workspace_list()['results'][0]['id']# Get and set any channel id for sender request, for example: Whatsapp, Messenger, SMSchannels_id=client.channel_list()['results'][0]['id']# Build the body message like this formatbody={"receiver":{"contacts":[{"identifierValue":"+15598585"}]},"body":{"type":"text","text":{"text":"Single text message"}}}response=client.send_message(channels_id=channels_id,body=body)# Print the object information.print('response:\n')print(response)exceptmessagebird.client.ErrorExceptionase:print('Error:\n')forerrorine.errors:print('  code        :%d'%error.code)print('  description :%s'%error.description)print('  parameter   :%s\n'%error.parameter)ActionsGet Contactcontact=client.contact(uuid='YOUR_CONTACT_ID')# Retrieve the information of a specific contact.Create Contactbody={"displayName":"Jhon Doe","identifiers":[{"key":"phone","value":"+15551234"}]}contact=client.contact_create(body=body)# Allows create a contact.Get Contact Listcontact=client.contact_list()# Extract all contacts created in a workspace.Get Workspace Listcontact=client.workspace_list()# Gets a list of workspaces created in an organization's account.Get Workspace By IDcontact=client.workspace_list_by_id(uuid='YOUR_WORKSPACE_ID')# Gets a list of workspaces created in an organization's account.Get Project Listcontact=client.project_list()# Gets a list of projects created in an workspace.# In this API you get what were previously known as templates,# only now they can be compatible with multiple channels.Get Project By IDcontact=client.project_list_by_id(uuid='YOUR_PROJECT_ID')# Gets one project created in an workspace by id.Get Channel Listcontact=client.channel_list()# Gets a list of channels created in an workspace.Get Channel By IDcontact=client.channel_list_by_id(uuid='YOUR_CHANNEL_ID')# Gets one channel created in an workspace by id.Get Connector Listcontact=client.connector_list()# Gets a list of connectors created in an workspace.# A connector can be Whatsapp, Messenger, SMSGet Connector By IDcontact=client.connector_list_by_id(uuid='YOUR_CONNECTOR_ID')# Gets one connector created in an workspace by id.Send Messagebody={"receiver":{"contacts":[{"identifierValue":"+15551234"}]},"body":{"type":"text","text":{"text":"Single text message"}}}contact=client.send_message(channels_id='YOUR_CHANNEL_ID',body=body)# Allows you to send a message through a channel.# :param channels_id: ID of the channel through which you want to send the message# :param body: Body of the message in json, which contains all the information necessary to send the messageGet Webhook Event Listcontact=client.webhook_event_list()# Gets a list of webhooks available in an workspace.Create Webhookcontact=client.webhook_create(body='body')# Allows create a webhook based in a event of available webhook list.