mailwizz lib for python

Not officially
Wait a little. I prepare simple code tomorrow (It's not full SDK)
 
Ok, Thanks. Waiting for your response.
Somthing like below
for get list:
Code:
import http.client

conn = http.client.HTTPConnection("yourdomain,com")

headers = {
    'X-MW-PUBLIC-KEY': "PUBLIC-KEY",
    'X-MW-TIMESTAMP': "TIMESTAMP",
    'Cache-Control': "no-cache"
    }

conn.request("GET", "api,lists", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
Replace, PUBLIC-KEY with your public key, TIMESTAMP with timestamp , yourdomain,com with your mailwizz installed domain.
This code is without signature(MW>>Setting>> API (disable signature))
 
@majid1f
Code:
import http.client
import time

conn = http.client.HTTPConnection("139.59.4.213/mailwizz/api/index.php")
_tim = str(time.time())

headers = {
    'X-MW-PUBLIC-KEY': "3c6725e43b17cd11cc40d40c333f4a5d4a73ce280",
    'X-MW-TIMESTAMP': _tim,
    'Cache-Control': "no-cache"
    }

conn.request("GET", "api/lists", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))


Here is My error:
Code:
Traceback (most recent call last):
  File "mailwizzconnection.py", line 13, in <module>
    conn.request("GET", "api/lists", headers=headers)
  File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/home/soham/anaconda3/lib/python3.6/http/client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/home/soham/anaconda3/lib/python3.6/socket.py", line 704, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/home/soham/anaconda3/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
 
change code to like this:
Code:
import http.client
import time

conn = http.client.HTTPConnection("139,59,4,213")

headers = {
    'X-MW-PUBLIC-KEY': "3c6725e43b17cd11cc40d40c333f4a5d4a73ce280",
    'X-MW-TIMESTAMP': str(time.time())
    }

conn.request("GET", "mailwizz,api,index.php,lists", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

then go mailwizz and disable API signature (MW>>Setting>> API )

-------------
Make sure you install https://pypi.org/project/httpclient/
 
@majid1f
Code:
(venv) soham@soham:~/PycharmProjects/logic$ python3 mailwizz.py
[]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at 139.59.4.213 Port 80</address>
</body></html>

My code
Code:
import http.client
import time

conn = http.client.HTTPConnection("139.59.4.213")
_tim = str(time.time())

headers = {
    'X-MW-PUBLIC-KEY': "3c6725e43b17cd11cc40d40c333f4a5d4a73ce280",
    'X-MW-TIMESTAMP': _tim,
    'Cache-Control': "no-cache"
    }

conn.request("GET", "/mailwizz/api/index.php", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))


import http.client
import time

conn = http.client.HTTPConnection("139.59.4.213")

headers = {
    'X-MW-PUBLIC-KEY': "3c6725e43b17cd11cc40d40c333f4a5d4a73ce280",
    'X-MW-TIMESTAMP': str(time.time())
    }

conn.request("GET", "mailwizz/api/index.php/lists", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
 
@majid1f
somehow http.client won't work in mycase. I installed requests lib and use it. Now it is working fine. @twisted1919 Is there any API endpoint documentation in mailwizz where I can refer all endpoint.
I think you used python 2 and http.client work on python 3.
I sent you a copy but it is not completed yet, after completing I will put on the site.
 
@majid1f I am using python3 only. By the way it works after using request lib. But next problem is transaction email apo not working. API response says success msg but mail is not sending.
 
When API say success , it's sent:) But maybe you have problem in the mw , check :mw : /backend/index.php/transactional-emails/index
 
Back
Top