Python SDK

Installation

Using pip is the recommended way to install the Unimatrix SDK for Python, which is available on PyPI.

Run the following command to add uni-sdk as a dependency to your project:

pip install uni-sdk

Usage

The following example shows how to use the Unimatrix Python SDK to interact with Unimatrix services.

Send SMS

Send a text message to a single recipient.


from uni.client import UniClient
from uni.exception import UniException

# initialization
client = UniClient("your access key id", "your access key secret") # if you use the simple auth mode, just pass in the first parameter

# send the message
try:
  res = client.messages.send({
    "to": "your phone number", # in E.164 format
    "text": "Your verification code is 2048."
  })
  print(res.data)
except UniException as e:
  print(e)

Send a message using a template with variables.

client.messages.send({
  "to": "+1650253xxxx",
  "signature": "Unimatrix",
  "templateId": "pub_verif_en_basic2",
  "templateData": {
    "code": "2048"
  }
})