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 totrue
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 SMSmessage
: 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 totrue
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 totrue
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 totrue
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
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
File details
Details for the file darbird-1.0.1.tar.gz
.
File metadata
- Download URL: darbird-1.0.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 897c63e916351f7a5900a127d60aea4c1f01e82fffb76c9f8b44c4b499c2c912 |
|
MD5 | 999ef2433368a26152de0e18836e5aa2 |
|
BLAKE2b-256 | 5b3ff4a632dead30f129af24f0f3e3cf483dd39c6f4f73f3e80091a1e8e9788d |