API wrapper for https://semaphore.co/
Project description
semaphore-sms
API wrapper for Semaphore SMS Gateway. The documentation for their API can be found here.
Installation
This library should be able to support Python versions >= 3.7.
Install from PyPi using pip via
pip install semaphore-sms
Don't have pip installed? Refer to this documentation
Usage
‼️ For all these calls, you can see sample responses in tests/test_semaphore_client.py ‼️
Initializing the client
from semaphore_sms import SemaphoreClient
client = SemaphoreClient(
api_key='your_api_key',
sender_name'sender_name',
)
Note:
SemaphoreClient
will try to pullapi_key
fromos.environ
if not supplied. If it still can't a value then, aSemaphoreException
will be raised
Sending SMS
For sending a basic single message,
client.send(
message='Your text here',
recipients=['09980101010', ]
)
To send one message to several numbers in bulk, simply provide multiple numbers under recipients
client.send(
message='Your text here',
recipients=['09980101010', '09980202020', ]
)
Sending out priority messages and OTP messages will look very similar
client.priority(
message='Your text here',
recipients=['09980101010', '09980202020', ]
)
client.otp(
message='Your OTP is: {otp}', # refer to Semaphore's docs for details
recipients=['09980101010', ],
code=123456, # refer to Semaphore's docs for details
)
Fetching messages
https://semaphore.co/docs#retrieving_messages
client.messages(
limit=100, # optional
page=1, # optional
start_date='2023-11-06', # optional
end_date='2023-12-25', # optional
network='smart', # optional
status='succcess' # optional
)
Retrieving account information
https://semaphore.co/docs#retrieving_account
account_information = client.account
transactions = client.transactions(
limit=100, # optional
page=1 # optional
)
sender_names = client.sender_names(
limit=100, # optional
page=1 # optional
)
users = client.users(
limit=100, # optional
page=1 # optional
)
Again, you can see sample responses in tests/test_semaphore_client.py
Tests
Clone the repo and run
PYTHONPATH=src python -m unittest
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/sbenemerito/semaphore-sms/
License
The library is available as open source under the terms of 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 semaphore_sms-1.0.0.tar.gz
.
File metadata
- Download URL: semaphore_sms-1.0.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2fad52c2c53ec89e20712d4a71259f1cd14f053a9cba3c70b3f14cdab250131 |
|
MD5 | dcbd355ec2797d443fdb94348347778c |
|
BLAKE2b-256 | e1f9cb3a713b2033f25508aede699e62d35e49fb0c27fade2e5e2df123be4b6e |
File details
Details for the file semaphore_sms-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: semaphore_sms-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ee717aaa198f2a6ecd56a30b6d6b30339d8ec759ec947a5d8182a3c8f81fd15 |
|
MD5 | febc6e3dd09c832b23ed2cedc4cda560 |
|
BLAKE2b-256 | c437e7481ce7ec5f049ae4578da1f617308417f43c91978bd9a91159eddaf067 |