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
.
from message_media_messages.message_media_messages_client import MessageMediaMessagesClient
import json
# Configuration parameters and credentials
auth_user_name = 'YOUR_API_KEY' # The username to use with basic/HMAC authentication
auth_password = 'YOUR_API_SECRET' # The password to use with basic/HMAC authentication
use_hmac_authentication = False # Change to True if you are using HMAC keys
client = MessageMediaMessagesClient(auth_user_name, auth_password, use_hmac_authentication)
messages_client = client.messages
body_value = '''{
"messages":[
{
"content":"My first message",
"destination_number":"+61491570156"
}
]
}'''
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
# Configuration parameters and credentials
auth_user_name = 'YOUR_API_KEY' # The username to use with basic/HMAC authentication
auth_password = 'YOUR_API_SECRET' # The password to use with basic/HMAC authentication
use_hmac_authentication = False # Change to True if you are using HMAC keys
client = MessageMediaMessagesClient(auth_user_name, auth_password, use_hmac_authentication)
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
# Configuration parameters and credentials
auth_user_name = 'YOUR_API_KEY' # The username to use with basic/HMAC authentication
auth_password = 'YOUR_API_SECRET' # The password to use with basic/HMAC authentication
use_hmac_authentication = False # Change to True if you are using HMAC keys
client = MessageMediaMessagesClient(auth_user_name, auth_password, use_hmac_authentication)
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
# Configuration parameters and credentials
auth_user_name = 'YOUR_API_KEY' # The username to use with basic/HMAC authentication
auth_password = 'YOUR_API_SECRET' # The password to use with basic/HMAC authentication
use_hmac_authentication = False # Change to True if you are using HMAC keys
client = MessageMediaMessagesClient(auth_user_name, auth_password, use_hmac_authentication)
delivery_reports_client = client.delivery_reports
result = delivery_reports_client.get_check_delivery_reports()
Check out the full API documentation for more detailed information.
Please contact developer support at developers@messagemedia.com or check out the developer portal at developers.messagemedia.com
Apache License. See the LICENSE file.