Skip to main content

Official Darbird Python SDK

Project description

darbird-python

The SDK provides convenient access to the Darbird APIs to python apps.

Documentation

Take a look at the API docs here.

Install

$ pip  install darbird # python 2.7.x

OR

$ python -m pip install darbird # python 2.7.x

OR

$ pip3 install darbird # python 3.6.x

OR

$ python3 -m pip install darbird # python 3.6.x

Usage

The package needs to be configured with your app username and API key, which you can get from the dashboard.

Your receipent number must be in an International Number example (+234xxxxxxxxxx)

# import package
import darbird


# Initialize SDK
username = "YOUR_USERNAME"    # use 'sandbox' for development in the test environment
api_key = "YOUR_API_KEY"      # use your sandbox app API key for development in the test environment
darbird.initialize(username, api_key)


# Initialize a service e.g. SMS
sms = darbird.SMS


# Use the service synchronously
response = sms.send("Hello Message!", ["+2547xxxxxx"])
print(response)

# Or use it asynchronously
def on_finish(error, response):
    if error is not None:
        raise error
    print(response)

sms.send("Hello Message!", ["+2547xxxxxx"], callback=on_finish)    

See example for more usage examples.

Initialization

Initialize the SDK by calling darbird.initialize(username, api_key). After initialization, you can get instances of offered services as follows:

Sms

  • send(message: str, recipients: str, sender_id: str = None, enqueue: bool = False): Send a message.

    • message: SMS content. REQUIRED
    • recipients: Phone numbers. REQUIRED
    • sender_id: Shortcode or alphanumeric ID that is registered with your Darbird account.
    • enqueue: Set to true if you would like to deliver as many messages to the API without waiting for an acknowledgement from telcos.
  • sendschedule(message: str, recipients: str, schedule: str, sender_id: str = None, enqueue: bool = False)): Send a premium SMS

    • message: SMS content. REQUIRED
    • recipients: An array of phone numbers. REQUIRED
    • schedule: Date like this format: m/d/Y h:i A. REQUIRED
    • sender_id: Shortcode or alphanumeric ID that is registered with your Darbird account.
    • enqueue: Set to true if you would like to deliver as many messages to the API without waiting for an acknowledgement

Voice

  • send(message: str, recipients: str, sender_id: str = None, enqueue: bool = False): Send a message.

    • message: SMS content. REQUIRED
    • recipients: Phone numbers. REQUIRED
    • sender_id: Shortcode or alphanumeric ID that is registered with your Darbird account.
    • enqueue: Set to true if you would like to deliver as many messages to the API without waiting for an acknowledgement from telcos.

MMS

  • send(message: str, recipients: str, media_url:str, sender_id: str = None, enqueue: bool = False): Send a message.

    • message: SMS content. REQUIRED
    • recipients: Phone numbers. REQUIRED
    • sender_id: Shortcode or alphanumeric ID that is registered with your Darbird account.
    • media_url: A link of your mms media.
    • enqueue: Set to true if you would like to deliver as many messages to the API without waiting for an acknowledgement from telcos.

Authy

  • send(message: str, recipients: str, media_url:str, sender_id: str = None, enqueue: bool = False): Send a message.

    • to_number: Phone numbers. REQUIRED
    • token_lenght: Token Lenght. REQUIRED
    • sender_id: Shortcode or alphanumeric ID that is registered with your Darbird account.
    • msg_type: Authenication type eg. voice or sms.
  • authverify(self, recipients, code, sender_id=None, unicodes=False, callback=None): Verify Token.

    • to_number: Phone numbers. REQUIRED
    • auth_code: Receieved Authenication code. REQUIRED
    • sender_id: Shortcode or alphanumeric ID that is registered with your Darbird account.

Development

$ git clone https://github.com/darbird/darbird-python.git
$ cd darbird-python
$ touch .env

Make sure your .env file has the following content then run python -m unittest discover -v

# AT API
USERNAME=sandbox
API_KEY=some_key

Issues

If you find a bug, please file an issue on our issue tracker on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

darbird-1.0.1.tar.gz (5.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page