IPPanel SMS api SDK
Installation
you can install this package with either pip:
python -m pip install ippanel
or running bellow command after downloading source:
python setup.py install
Examples
For using sdk, you have to create a client instance that gives you available methods on API
from ippanel import Client
# you api key that generated from panel
api_key = "api-key"
# create client instance
sms = Client(api_key)
...
Credit check
# return float64 type credit amount
credit = sms.get_credit()
Send one to many
For sending sms, obviously you need originator number, recipients and message.
message_id = sms.send(
"+9810001", # originator
["98912xxxxxxx"], # recipients
"ippanel is awesome" # message
"description" # is logged
)
If send is successful, a unique tracking code returned and you can track your message status with that.
Get message summery
message_id = "message-tracking-code"
message = sms.get_message(message_id)
print(message.state) # get message status
print(message.cost) # get message cost
print(message.return_cost) # get message payback
Get message delivery statuses
message_id = "message-tracking-code"
statuses, pagination_info = sms.fetch_statuses(message_id, 0, 10)
# you can loop in messages statuses list
for status in statuses {
print("Recipient: %s, Status: %s" % (status.recipient, status.status))
}
print("Total: ", pagination_info.total)
Inbox fetch
fetch inbox messages
messages, pagination_info = sms.fetch_inbox(0, 10)
for message in messages {
print("Received message %s from number %s in line %s" % (message.message, message.sender, message.to))
}
Pattern create
For sending messages with predefined pattern(e.g. verification codes, ...), you hav to create a pattern. a pattern at least have a parameter.
pattern_variables = {
"name": "string",
"code": "integer",
}
code = sms.create_pattern(r"%name% is awesome, your code is %code%", "description", pattern_variables, "%", False)
print(code)
Send with pattern
pattern_values = {
"name": "IPPANEL",
}
message_id = sms.send_pattern(
"t2cfmnyo0c", # pattern code
"+9810001", # originator
"98912xxxxxxx", # recipient
pattern_values, # pattern values
)
Error checking
from ippanel import HTTPError, Error, ResponseCode
try:
message_id = sms.send("9810001", ["98912xxxxx"], "ippanel is awesome")
except Error as e: # ippanel sms error
print(f"Error handled => code: {e.code}, message: {e.message}")
if e.code == ResponseCode.ErrUnprocessableEntity.value:
for field in e.message:
print(f"Field: {field} , Errors: {e.message[field]}")
except HTTPError as e: # http error like network error, not found, ...
print(f"Error handled => code: {e}")
Metadata
Release files for ippanel 2.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ippanel-2.0.7.tar.gz | 7.8 kB | Details |
Release files / ippanel-2.0.7.tar.gz
| Download URL | ippanel-2.0.7.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2aa221a80ea0ad8ecaac67e0b9b9ffccd08e300116e2a5839b7c72fb8327c3f
|
|
BLAKE2b-256 checksum How to use checksums |
f4cd869c78b9f87353eb72bc20388a2024b0205024080dd8baa0e013022ca102
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|