Prevents spam in your python web apps. Cloud features allow you to use additional anti-spam functionality, such as: Personal IP/Email lists, blocking by country, language, stop words and etc.
Anti-Spam log - allows viewing all filtered requests in the "Log of spam attacks". The log contains detailed information about each request for a time period. At any time, you can check the request and make sure that the filtering is correct. A Python API for antispam service cleantalk.org. Invisible protection from spam, no captchas, no puzzles, no animals, and no math.
How API stops spam?
API uses several simple tests to stop spammers:
- Spam bots signatures.
- Blacklists checks by Email, IP, web-sites domain names.
- Comment submit time.
- Relevance test for the comment.
How API works?
API sends a comment's text and several previously approved comments to the servers. Servers evaluate the relevance of the comment's text on the topic, test spam and finally provide a solution - to publish or put on manual moderation of comments. If a comment is placed on manual moderation, the plugin adds to the text of a comment explaining the reason for the ban on server publishing.
- Python 2.6 and above
- Python 3 and above
- CleanTalk account
SPAM test for text comment sample
1. Download and unzip the archive into a folder.
2. Create a new .py file and paste the code below:
from cleantalk import CleanTalk
ct = CleanTalk(auth_key='yourkey')
ct_result = ct.request(
message = 'abc', # Visitor comment
sender_ip = '184.108.40.206', # Visitor IP address
sender_email = 'email@example.com', # Visitor email
sender_nickname = 'spam_bot', # Visitor nickname
submit_time = 12 # Seconds from start form filling till the form POST
print('Comment allowed. Reason ' + ct_result['comment'])
print('Comment blocked. Reason ' + ct_result['comment'])
3. Don't forget to paste your access key.
4. Run the created file and you will see the blocking message:
API Response description
API returns Python dictionary object, where keys:
- allow (0|1) - allow to publish or not, in other words spam or ham
- comment (string) - server comment for requests.
- id (string MD5 HEX hash) - unique request identifier.
Installing via PyPi
Run the next command in the terminal:
Then you can use Cleantalk class import:
If you haven't found the answer to your question, please, contact our support team.