Contact Us

Send a text message using Python in under 2 minutes

120 seconds? Certainly can't be that easy. Or can it? In this tutorial, I’d like to quickly show you how simple it is to add messaging capability to your web app. Prerequisites

Step 1: Set up project Create an empty folder for your project, let’s name it testApp. 

Step 2: Install dependency Run the code from the command line from the root of your project folder

pip install messagemedia-messages-sdk

This command installs the package using which you can send messages. 

Step 3: Add the code 

Create an index.js file inside the folder you created earlier and open it up in your editor. Write down the following code. .

from message_media_messages.message_media_messages_client import MessageMediaMessagesClient
import json

auth_user_name = 'YOUR_API_KEY'
auth_password = 'YOUR_API_SECRET'
use_hmac_authentication = False

client = MessageMediaMessagesClient(auth_user_name, auth_password, use_hmac_authentication)
messages_client = client.messages

body_value = '''{
            "content":"My first message",

body = json.loads(body_value)

result = messages_client.send_messages(body)

Don’t forget to update the API credentials and the destination number. 

Step 4: Abracadabra 

Fire up the command line and run the following command


A successful response should look like this:  

Well done – that’s how simple it is to send a message using Python. Check out the API documentation and the Github repository to see what else you can do.