Asanak API
A Python client library for the Asanak SMS API. This package provides a simple and intuitive interface to interact with Asanak SMS services.
Installation
You can install the package via pip:
pip install asanak-api
Quick Start
from asanak_api import AsanakAPI
# Initialize the client
api = AsanakAPI(username="your_username", password="your_password")
# Or use the API key format (username,password)
# api = AsanakAPI(api_key="your_username,your_password")
# Send an SMS
response = api.sms_send({
"source": "your_source_number",
"destination": ["destination_number1", "destination_number2"],
"message": "Hello from Asanak API!"
})
print(response)
Authentication
Asanak SMS provider uses username and password for authentication. You can provide these credentials in two ways:
-
Separate username and password parameters:
api = AsanakAPI(username="your_username", password="your_password")
-
Combined API key:
api = AsanakAPI(api_key="your_username,your_password")
Available Methods
SMS Operations
-
Send SMS:
api.sms_send({ "source": "your_source_number", "destination":"recipient_number1,recipient_number2,...", "message": "Your message content" })
-
Send Template SMS:
api.sms_template({ "source": "your_source_number", "destination": "recipient_number1,recipient_number2,...", "message": "Your template name", "variables": {"var1": "value1", "var2": "value2"} })
-
Send Peer-to-Peer SMS:
api.sms_p2p( { { "source": "your_source_number", "destinations": "recipient_number1", "messages": "Message for recipient1" }, { "source": "your_source_number", "destinations": "recipient2", "messages": "Message for recipient2" } } )
-
Check SMS Status:
api.sms_status({"msgid": "your_message_id"})
Other Operations
-
Get Templates List:
api.sms_template_list()
-
Get Credit:
api.get_credit()
-
Get Rial Credit:
api.get_rial_credit()
Response Format
All API methods return responses in the following format:
{
"status": status_code, # Status code of the response
"message": "message", # Message describing the status
"data": {...} # Response data
}
Status Codes
The library includes predefined status codes that help you interpret API responses:
- SMS Status codes - Available in
SMS_STATUSdictionary - API Status codes - Available in
API_STATUSdictionary
Exception Handling
The library can raise the following exceptions:
APIException: For API-related errorsHTTPException: For HTTP connection issues
from asanak_api import AsanakAPI, APIException, HTTPException
try:
api = AsanakAPI(api_key="your_api_key")
response = api.sms_send({...})
except APIException as e:
print(f"API Error: {e}")
except HTTPException as e:
print(f"HTTP Error: {e}")
Requirements
- Python >= 3.12
- requests >= 2.32.3
Metadata
Release files for asanak-api 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| asanak_api-0.1.1.tar.gz | 4.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asanak_api-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.8 kB
Release files / asanak_api-0.1.1.tar.gz
| Download URL | asanak_api-0.1.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
88a84030d93359ce77a24713ed1d0922d54c0b37bfe5837161908191fd5a2340
|
|
BLAKE2b-256 checksum How to use checksums |
178d64e8e26490b3161433acc8b6cc435fcab1689ff452f19b76374b528ead61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / asanak_api-0.1.1-py3-none-any.whl
| Download URL | asanak_api-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
546aa86261375b6bbf579bf2b8c5c48b079b0f258f62f6d272155d088a72be03
|
|
BLAKE2b-256 checksum How to use checksums |
afdd13c6847000b1cb313904861a201d9f2da111d6a0eb677c7d39f969280d84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for asanak-api 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.