Skip to main content

Bird's REST API for Python

This repository contains the open source Python client for New MessageBird's REST API. Documentation can be found at: https://docs.bird.com/api/.

Requirements

  • Sign up for a free MessageBird account
  • Create a new access key in the developers sections
  • An application written in Python (tested with Python 2.7 and Python 3.4)

Installation

The easiest way to install the bird_python package is either via pip:

$ pip install bird_python

Examples

We have put some self-explanatory examples in the examples directory, but here is a quick example on how to get started. Assuming the installation was successful, you can import the messagebird package like this:

import bird_python as messagebird

Then, create an instance of messagebird.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, SMS
  channels_id = client.channel_list()['results'][0]['id']
  
  # Build the body message like this format
  body = {
        "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)

except messagebird.client.ErrorException as e:
  print('Error:\n')

  for error in e.errors:
    print('  code        : %d' % error.code)
    print('  description : %s' % error.description)
    print('  parameter   : %s\n' % error.parameter)

Actions

  1. Get Contact
contact = client.contact(uuid='YOUR_CONTACT_ID')
# Retrieve the information of a specific contact.
  1. Create Contact
body = {
        "displayName": "Jhon Doe",
        "identifiers": [
                {
                    "key": "phone",
                    "value": "+15551234"
                }
            ]
        }
contact = client.contact_create(body=body)
# Allows create a contact.
  1. Get Contact List
contact = client.contact_list()
# Extract all contacts created in a workspace.
  1. Get Workspace List
contact = client.workspace_list()
# Gets a list of workspaces created in an organization's account.
  1. Get Workspace By ID
contact = client.workspace_list_by_id(uuid='YOUR_WORKSPACE_ID')
# Gets a list of workspaces created in an organization's account.
  1. Get Project List
contact = 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.
  1. Get Project By ID
contact = client.project_list_by_id(uuid='YOUR_PROJECT_ID')
# Gets one project created in an workspace by id.
  1. Get Channel List
contact = client.channel_list()
# Gets a list of channels created in an workspace.
  1. Get Channel By ID
contact = client.channel_list_by_id(uuid='YOUR_CHANNEL_ID')
# Gets one channel created in an workspace by id.
  1. Get Connector List
contact = client.connector_list()
# Gets a list of connectors created in an workspace.
# A connector can be Whatsapp, Messenger, SMS
  1. Get Connector By ID
contact = client.connector_list_by_id(uuid='YOUR_CONNECTOR_ID')
# Gets one connector created in an workspace by id.
  1. Send Message
body = {
        "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 message
  1. Get Webhook Event List
contact = client.webhook_event_list()
# Gets a list of webhooks available in an workspace.
  1. Create Webhook
contact = client.webhook_create(body='body')
# Allows create a webhook based in a event of available webhook list.

Metadata

Release files for bird-python 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bird-python 0.1.2
File Size Uploaded
bird_python-0.1.2.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bird-python 0.1.2
File Interpreter ABI Platform
bird_python-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / bird_python-0.1.2.tar.gz

Download URL bird_python-0.1.2.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9d801e9908cf5d363ea7e47ab4f3489673a6aad1936e6dc4009e5401e03fac98
BLAKE2b-256 checksum
How to use checksums
f9e7415bbf67fe72d8641abb8e8c7b0243839a2981148d9c83cd2810bcdb90f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.10

Release files / bird_python-0.1.2-py3-none-any.whl

Download URL bird_python-0.1.2-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3ab6a09329c1bb6852b3089925268d4b7b0884924b3fb6ebc4197f902ef1f84
BLAKE2b-256 checksum
How to use checksums
de12f6aac9953a6949e5095095a0a868b6c60b9135ad2329d275f1956b9077f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page