A simple imessage api that leverages applescript and a local webserver to send iMessage or SMS messages (including files) programmatically. Runs persistently in the macOS menubar.
Due to limitations imposed by apple, all features are not accessible to machines running macOS 10.16 or higher. All macOS versions can send imessages/sms to new or existing conversations.
In order to send a message, you will need to use the API Key that is auto generated by the app on first launch. In order to access it, you will need to click the 'copy api key' option in the menu bar app.
import requests
# set the request parameters
json = {
'apikey': 'YOUR_API_KEY'
'number': 'XXXXXXXXXX', # can also be an iMessage enabled email
'service': 'iMessage', # can also be set to 'SMS'
'message': 'hello from imessage-api!',
'isFile': 'false'
}
# make the request to the local server
req = requests.post('http://localhost:33229/sendMessage', json=json)
# print the response
print(req.text) # {"status":"success","time":"2022-09-26 22:24:54"}# clone the repository
git clone https://github.com/aravindnatch/imessage-api.git
# install the dependencies
pip install -r requirements.txt
# run the app locally
python3 main.py
# build the app locally
python3 setup.py py2app # saved to: dist/imessage-api.app