The MessageMedia Messages API provides a number of endpoints for building powerful two-way messaging applications.
Run the following command to install the SDK via pip:
pip install messagemedia-messages-sdk
It's easy to get started. Simply enter the API Key and secret you obtained from the MessageMedia Developers Portal into the code snippet below and a mobile number you wish to send to.
- Destination numbers (
destination_number
) should be in the E.164 format. For example,+61491570156
.
# Configuration parameters and credentials
from message_media_messages.message_media_messages_client import MessageMediaMessagesClient
import json
auth_user_name = 'YOUR_API_KEY' # The username to use with basic authentication
auth_password = 'YOUR_API_SECRET' # The password to use with basic authentication
client = MessageMediaMessagesClient(auth_user_name, auth_password)
messages_client = client.messages
body_value = '''{
"messages":[
{
"content":"My first message",
"destination_number":"YOUR_MOBILE_NUMBER"
}
]
}'''
body = json.loads(body_value)
result = messages_client.create_send_messages(body)
You can get a messsage ID from a sent message by looking at the message_id
from the response of the above example.
# Configuration parameters and credentials
from message_media_messages.message_media_messages_client import MessageMediaMessagesClient
import json
auth_user_name = 'YOUR_API_KEY' # The username to use with basic authentication
auth_password = 'YOUR_API_SECRET' # The password to use with basic authentication
client = MessageMediaMessagesClient(auth_user_name, auth_password)
messages_client = client.messages
message_id = 'YOUR_MESSAGE_ID'
result = messages_client.get_message_status(message_id)
print result
You can check for replies that are sent to your messages
# Configuration parameters and credentials
from message_media_messages.message_media_messages_client import MessageMediaMessagesClient
import sys
import json
auth_user_name = 'YOUR_API_KEY' # The username to use with basic authentication
auth_password = 'YOUR_API_SECRET' # The password to use with basic authentication
client = MessageMediaMessagesClient(auth_user_name, auth_password)
replies_client = client.replies
result = replies_client.get_check_replies()
This endpoint allows you to check for delivery reports to inbound and outbound messages.
# Configuration parameters and credentials
from message_media_messages.message_media_messages_client import MessageMediaMessagesClient
import sys
import json
auth_user_name = 'YOUR_API_KEY' # The username to use with basic authentication
auth_password = 'YOUR_API_SECRET' # The password to use with basic authentication
client = MessageMediaMessagesClient(auth_user_name, auth_password)
delivery_reports_client = client.delivery_reports
result = delivery_reports_client.get_check_delivery_reports()
The Python SDK Documentation can be viewed here
Please contact developer support at developers@messagemedia.com or check out the developer portal at developers.messagemedia.com