The official Python SDK for Mslm APIs.
Before you start using the Mslm Python SDK, ensure that you have the following:
- Python: The SDK is compatible with Python 3.6 and above.
Mslm's APIs require an API key. If you don't have one, please read Authentication to understand how to get an API key before continuing.
To install the main library, use the following command:
pip install mslm
Or install specific packages like mslm-email-verify
and mslm-otp
separately:
pip install mslm-email-verify
pip install mslm-otp
import mslm
# Initialize the Mslm object with your API key.
client = mslm.Mslm("api_key")
- Single Verify
resp, error = client.email_verify.single_verify("support@mslm.io")
- Sending an OTP.
# Create an OtpSendReq object.
otp_send_request = client.otp.OtpSendReq(
phone="+923214444444",
tmpl_sms="Your verification code is {token}",
token_len=6,
expire_seconds=300
)
otp_send_response, error = mslm_instance.otp.send(otp_send_request)
# otp_send_response: OtpSendResp, error: Error
- Verifying a token.
# Create an OtpTokenVerifyReq object.
otp_token_verify_request = mslm_instance.otp.OtpTokenVerifyReq(
phone="+923214444444",
token="123456",
consume=True,
)
otp_token_verify_response, error = mslm_instance.otp.verify(otp_token_verify_request)
# otp_token_verify_response: OtpTokenVerifyResp, error: Error
Each service can be imported individually as well.
import mslm_email_verify
# Initialize the EmailVerify object with your API key.
mslm_email_verify_instance = mslm_email_verify.EmailVerify("api_key")
import mslm_otp
# Initialize the Otp object with your API key.
mslm_otp_instance = mslm_otp.Otp("api_key")
We expose the following error types in the SDK:
MslmError
: The base error type.
RequestQuotaExceededError
: The request quota has been exceeded.
These errors can be accessed as follows:
mslm.MslmError
mslm.RequestQuotaExceededError
mslm_email_verify.MslmError
mslm_email_verify.RequestQuotaExceededError
mslm_otp.MslmError
mslm_otp.RequestQuotaExceededError
We provide a few scripts for development purposes.
scripts/publish.sh
: Builds and publishes the package to PyPI.scripts/fmt.sh
: Formats the code using black.
See the official API Reference Documentation for details on each API's actual interface, which is implemented by this SDK.
See CONTRIBUTING for more information.
See Security Issue Notifications for more information.
This project is licensed under the MIT License.
At Mslm, we're all about making things better. Where others see norm, we see opportunity.
We build world-class solutions to the toughest problems. Excellence is a core value that defines our approach from top to bottom.
We're all about creating positive value for ourselves, our partners and our societies.
We do it by focusing on quality and the long-term, while intelligently maneuvering the complex realities of day-to-day business.
Our partners share our perspective, and we jointly produce truly world-class solutions to the toughest problems.