Python 3 Script to Send Text SMS Messages to any Mobile Number Using Fast2SMS API Full Tutorial For Beginners


Welcome folks today in this tutorial we will be using fast2sms api to send text sms messages to any mobile number in python 3. All the source code of the application will be shown below.




Get Started



In order to get started you need to be having python 3 installed on your computer and also just create a account on fast2sms here.



After that you need to get api key for your account to send sms messages using fast2sms. To get the api key you need to go to dashboard and go to dev api section as shown in the figure also.







And after that you will see the api key inside the section as shown below. Just copy it and store it somewhere we will use it later.





After getting the api key just create a file inside the root directory and copy paste the following code to it




import requests
import json
# mention url 
url = ""

# create a dictionary 
my_data = { 
    # Your default Sender ID 
    'sender_id': 'FSTSMS', 
    # Put your message here! 
    'message': 'This is a test message', 
    'language': 'english', 
    'route': 'p', 
    # You can send sms to multiple numbers 
    # separated by comma. 
    'numbers': '###yourmobilenumber####'    

# create a dictionary 
headers = { 
    'authorization': '######YOURAPIKEY#######', 
    'Content-Type': "application/x-www-form-urlencoded", 
    'Cache-Control': "no-cache"

# make a post request 
response = requests.request("POST",url,data = my_data,headers = headers) 

returned_msg = json.loads(response.text) 

# print the send message 




Here you just need to replace your own api key and mobile number where you need to send sms text message respectively.


After replacing the above things you can run the python script by executing the following command as follows




After this you will receive a sms text message like this on your mobile number


Leave a Reply