Python client for Infobip's API channels.
More channels to be added in the near future.
For infobip-api-python-sdk versioning we use
Semantic Versioning scheme.
Python 3.6 is minimum supported version by this library.
Currently, infobip-api-python-sdk only supports API Key authentication, and the key needs to be passed during client creation. This will most likely change with future versions, once more authentication methods are included.
To install infobip SDK you will need to run:
pip install infobip-api-python-sdkDetails of the package can be found here
To use the package you'll need an Infobip account. If you don't already have one, you can create a free trial account here.
In this example we will show how to send WhatsApp text message. Similar can be done for other channels. First step is to import necessary channel, in this case WhatsApp channel.
from infobip_channels.whatsapp.channel import WhatsAppChannelNow you can create instance of WhatsAppChannel with your base_url and api_key.
c = WhatsAppChannel.from_auth_params({
"base_url": "<your_base_url>",
"api_key": "<your_api_key>"
})After that you can access all the methods from WhatsAppChannel.
To send text message you can use send_text_message method and add correct payload:
response = c.send_text_message(
{
"from": "<WhatsApp sender number from your Infobib account>",
"to": "<Number that will receive WhatsApp message>",
"messageId": "a28dd97c-1ffb-4fcf-99f1-0b557ed381da",
"content": {
"text": "Some text"
},
"callbackData": "Callback data",
"notifyUrl": "https://www.example.com/whatsapp"
}
)To run tests position yourself in the project's root while your virtual environment is active and run:
python -m pytestTo enable pre-commit hooks run:
pip install -r requirements/dev.txtYou will need to install pre-commit hooks Using homebrew:
brew install pre-commitUsing conda (via conda-forge):
conda install -c conda-forge pre-commitTo check installation run:
pre-commit --versionIf installation was successful you will see version number.
You can find the Pre-commit configuration in .pre-commit-config.yaml.
Install the git hook scripts:
pre-commit installRun against all files:
pre-commit run --all-filesIf setup was successful pre-commit will run on every commit.
Every time you clone a project that uses pre-commit, running pre-commit install
should be the first thing you do.
This library is distributed under the MIT license found in the License.