How to use OOPSpam Anti-Spam API to filter spam

No JunkMail Valletta


If you have ever owned a website with a contact form or a blog with a comment section then you’ve probably experienced a huge amount of spam almost daily. You are not alone. In 2017, we decided to do something about it and built OOPSpam API.

Deciding which content is spam solely based on content is a difficult problem. Even well-trained machine learning algorithms have a good chance of making a false positive. The better approach would be to analyze multiple factors and produce a single output such as a score. OOPSpam API allows you to pass the following values to make a better decision:

{
    "senderIP": "91.203.67.110",
    "content": "Dear Agent, We are a manufacturing company which specializes in supplying Aluminum Rod with Zinc Alloy Rod to customers worldwide, based in Japan, Asia. We have been unable to follow up payments effectively for transactions with debtor customers in your country due to our distant locations, thus our reason for requesting for your services representation.",
    "checkForLength": true,
    "allowedLanguages" : ["en"],
    "allowedCountries" : ["it","us"],
    "blockedCountries" : ["ru"]
}

Let’s see how the API makes a decision and which fields are important even though passing all values increase accuracy greatly.

What is allowedLanguages and how it helps to prevent spam?

Well, let’s say you have a website in English and you serve your content (article, news, service, etc.) in English. It would make sense that you expect your comments to be in English. In this case, you pass en (short for English ISO 639-1 two-letter code) to allowedLanguages parameter as an array (["en"]). OOPSpam API has built-in Language Detection algorithm which will check the comment and determine whether it’s actually in English or not. A content in a different language other than English will be marked as spam. In addition, say you expect your content to be in English and Italian then your allowedLanguages would look like ["en", "it"].

OOPSpam API will returns Score along with a detailed report to let you know why it’s spam or not. Here the all possible value you will get:

{
  "Score": 6,
  "Details": {
    "isIPBlocked": false,
    "isContentSpam": "spam",
    "langMatch": true,
    "countryMatch": false,
    "numberOfSpamWords": 0,
    "isContentTooShort": false
  }
}

Have a look at our Response Body Parameter section in our documentation to learn the definition of each field.

If you are a big fan of Postman like myself, here is Postman embed button that will load all the headers and request body for you. Make sure to grab an API key and replace YOUR_API_KEY in the Headers tab.

Run in Postman

Once you get a response to your request, you are ready to flag messages. While it depends on the use case, we recommend considering Score 3 and above as spam.

Check out OOPSpam API docs for more information.

Happy spam-free day!

A cocktail of unique measurements means cutting edge spam protection.

Since our launch in 2017 we’ve been perfecting our API to be the trusted option for small businesses to enterprise— and continue to stick to our values of being the accessibility and privacy-friendly option. Give us a shot!

Try OOPSpam for free → Try our WordPress plugin for free →

✓ No credit card required ✓ Cancel anytime

Enjoy Reading This Article?

Here are some more articles you might like to read next: