The official Unimatrix SDK for Python.
Project description
Unimatrix Python SDK
The Unimatrix Python SDK provides convenient access to integrate communication capabilities into your Python applications using the Unimatrix HTTP API. The SDK provides support for sending SMS, 2FA verification, and phone number lookup.
Getting started
Before you begin, you need an Unimatrix account. If you don't have one yet, you can sign up for an Unimatrix account and get free credits to get you started.
Documentation
Check out the documentation at unimtx.com/docs for a quick overview.
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.
Initialize a client
from uni.client import UniClient
client = UniClient("your access key id", "your access key secret")
or you can configure your credentials by environment variables:
export UNIMTX_ACCESS_KEY_ID=your_access_key_id
export UNIMTX_ACCESS_KEY_SECRET=your_access_key_secret
Send SMS
Send a text message to a single recipient.
from uni.client import UniClient
from uni.exception import UniException
client = UniClient()
try:
res = client.messages.send({
"to": "+1206880xxxx", # in E.164 format
"text": "Your verification code is 2048."
})
print(res.data)
except UniException as e:
print(e)
Send verification code
Send a one-time passcode (OTP) to a recipient. The following example will automatically generate a verification code.
from uni.client import UniClient
from uni.exception import UniException
client = UniClient()
try:
res = client.otp.send({
"to": "+1206880xxxx"
})
print(res.data)
except UniException as e:
print(e)
Check verification code
Verify the one-time passcode (OTP) that a user provided. The following example will check whether the user-provided verification code is correct.
from uni.client import UniClient
from uni.exception import UniException
client = UniClient()
try:
res = client.otp.verify({
"to": "+1206880xxxx",
"code": "123456" # the code user provided
})
print(res.valid)
except UniException as e:
print(e)
Reference
Other Unimatrix SDKs
To find Unimatrix SDKs in other programming languages, check out the list below:
License
This library is released under the MIT License.
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
Built Distribution
File details
Details for the file uni-sdk-0.3.0.tar.gz
.
File metadata
- Download URL: uni-sdk-0.3.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65ae4f7f17c95d4be45fd80ac75935e1a4c1939fd02809a5703a9439c58cd01e |
|
MD5 | 987c90d4009867282801089e6d7d7746 |
|
BLAKE2b-256 | 7ca53310d2d5db8646bf17cfd60b09d584a9b4bd077ce5914bf0204cc8e4ff86 |
Provenance
File details
Details for the file uni_sdk-0.3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: uni_sdk-0.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 610ed8ebc1316f293b8c07b57d9af7654b8263a0f2ad0db276fc4c33735049cf |
|
MD5 | f10a7d0d03e0a445b5a2400c1d47bf50 |
|
BLAKE2b-256 | a12c805bae6a98ab7e4b69eecde9472fcd704fb4a7b795bdc8e11ddef3c392ef |