Hi,
I recently needed to integrate sms.ir into one of my projects and used the official library. It works, but it lacks any type safety, essentially it's a thin wrapper around raw HTTP requests, leaving callers to deal with untyped JSON responses directly.
I ended up writing a full replacement. Here's what it offers over the current library:
- Fully type-safe: every endpoint, request payload, and response is a typed and response are Pydantic models.
- Both sync and async support via httpx
- Minimal dependencies: only httpx and pydantic
- No raw JSON handling: response fields are accessible as typed attributes
- Clean exception hierarchy: the library never leaks underlying dependency errors (httpx, pydantic). Everything surfaces as a library-specific exception type:
NetworkError, APIError, AuthenticationError, RateLimitError, ResponseParsingError, and ResponseValidationError, all under a common SMSIRError base
Example (sync):
from smsir import SMSIRClient
from smsir.endpoints import BulkSend
client = SMSIRClient("your-api-key")
result = client.execute(BulkSend(
line_number=30004505000017,
message_text="Your message here",
mobiles=["09121234567", "09191234567"],
))
print(result.pack_id, result.message_ids, result.cost)
The source is available at https://github.com/YouKnow-sys/smsir and published on PyPI as smsir-sdk.
I'm open to contributing this as a replacement for the official library if there's interest. Happy to discuss the design or adapt it to fit the project's direction.
Hi,
I recently needed to integrate sms.ir into one of my projects and used the official library. It works, but it lacks any type safety, essentially it's a thin wrapper around raw HTTP requests, leaving callers to deal with untyped JSON responses directly.
I ended up writing a full replacement. Here's what it offers over the current library:
NetworkError,APIError,AuthenticationError,RateLimitError,ResponseParsingError, andResponseValidationError, all under a commonSMSIRErrorbaseExample (sync):
The source is available at https://github.com/YouKnow-sys/smsir and published on PyPI as
smsir-sdk.I'm open to contributing this as a replacement for the official library if there's interest. Happy to discuss the design or adapt it to fit the project's direction.