Skip to main content

Mediana SMS api SDK

This repository contains open source Python client for mediana_sms api. Documentation can be found at: http://docs.medianasms.com.

Build Status

Installation

you can install this package with either pip:

pip install medianasms

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 medianasms 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.

bulk_id = sms.send(
    "+9810001",          # originator
    ["98912xxxxxxx"],    # recipients
    "mediana is awesome" # message
)

If send is successful, a unique tracking code returned and you can track your message status with that.

Get message summery

bulk_id = "message-tracking-code"

message = sms.get_message(bulk_id)

print(message.status)  # get message status
print(message.cost)    # get message cost
print(message.payback) # get message payback

Get message delivery statuses

bulk_id = "message-tracking-code"

statuses, pagination_info = sms.fetch_statuses(bulk_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.number))
}

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. parameters defined with %param_name%.

pattern = sms.create_pattern(r"%name% is awesome", False)

print(pattern.code)

Send with pattern

pattern_values = {
    "name": "Mediana",
}

bulk_id = sms.send_pattern(
    "t2cfmnyo0c",    # pattern code
    "+9810001",      # originator
    "98912xxxxxxx",  # recipient
    pattern_values,  # pattern values
)

Error checking

from medianasms import HTTPError, Error, ResponseCode

try:
    bulk_id = sms.send("9810001", ["98912xxxxx"], "mediana is awesome")
except Error as e: # mediana sms error
    print("Error handled => code: %s, message: %s" % (e.code, e.message))
    if e.code == ResponseCode.ErrUnprocessableEntity.value:
        for field in e.message:
            print("Field: %s , Errors: %s" % (field, e.message[field]))
except HTTPError as e: # http error like network error, not found, ...
    print("Error handled => code: %s" % (e))

Metadata

Release files for medianasms 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for medianasms 1.1.0
File Size Uploaded Provenance Actions
medianasms-1.1.0.tar.gz 6.9 kB Without provenance Details for medianasms-1.1.0.tar.gz

Release files / medianasms-1.1.0.tar.gz

Download URL medianasms-1.1.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
100a1b692fd35e0dd82dbce8f82dadb7f0e9bc51651218471f0dcce4d0f3fffa
BLAKE2b-256 checksum
How to use checksums
edeae50ac546bdcb67df4e4519d5f2f1b39e4166bc9c1ddd6c3a113f3990d868
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.3

Security for medianasms 1.1.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page