The client library to support Sendsay API.
Please note that the current version of the package is not backward compatible with the versions before v1.0.0.
- API request returns an instance of
Responseinstead of dict track_waitwas removed fromSendsayAPIclass. You can get the tracking information by usingtrackmethod of a response returnedattach_fileis a method ofsendsay.apimodule
pip install sendsay-api-pythonrequests
If your Python version older than 2.7.9, the following packages are required to support TLS SNI certificate checking:
ndg-httpsclientpyopensslpyasn1
from sendsay.api import SendsayAPI
api = SendsayAPI(login='<YOUR_LOGIN>', sublogin='<YOUR_SUBLOGIN>', password='<YOUR_PASSWORD>')# Calling with parameters
response = api.request('member.set', { 'email': '[email protected]', 'addr_type': 'email', 'if_exists': 'overwrite', 'newbie.confirm': 0, 'return_fresh_obj': 1 })
# Getting the response data
response = api.request('sys.settings.get', dict(list=['about.name']))
print(response.data)from sendsay.api import SendsayAPI, attach_file
from time import sleep
response = api.request('issue.send', {
'sendwhen': 'now',
'letter': {
'subject': "Subject",
'from.name': "Tester",
'from.email': "[email protected]",
'message': {
'html': "Sendsay API client test message<hr>Hello!"
},
'attaches': [
attach_file("sample.jpg")
],
},
'relink' : 1,
'users.list': "[email protected]\n[email protected]",
'group' : 'masssending',
})
# If the response has tracking data
if response.track:
# Refresh the tracking status
while response.track.check():
# Get the current status
print(response.track.status, response.track.status_message)
sleep(3)