Now with TypePad support!

Akismetor now supports the free TypePad API in addition to Akismet.

To switch to TypePad, add

:provider => :typepad

to your attributes hash (and don’t forget to set your API key to your TypePad key).

If you wish to continue using Akismet, you need do nothing.

Akismetor 1.1

This version includes rSpec tests and a method to verify the Akismet key.

This plugin was originally created by Ryan Bates (Railscasts episode 65), being forked from

This plugin provides the Akismet class which you can use to communicate with Akismet. Akismet [] is a collaborative spam filtering service.

You can use the class Akismet and its methods, wherever you want inside your Rails application.


./script/plugin install git://


# submits key to Akismet, and returns a string with “valid” or “invalid”. Akismetor.valid_key?(attributes)

# submits comment to Akismet, and returns true if the comment is spam, and false in case it’s not. Akismetor.spam?(attributes)

# submits hash as spam to Akismet. Returns a message string. Akismetor.submit_spam(attributes)

# submits hash as ham to Akismet. Returns a message string. Akismetor.submit_ham(attributes)

Let’s see a real usage:

comment_attributes =

:key => '123456789', 
:blog => '', 
:user_ip => '',
:user_agent => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv: Gecko/2008092414 Firefox/3.0.3',
:referrer => '',
:permalink => '',
:comment_type => 'comment',
:comment_author => 'John Doe',
:comment_author_email => '[email protected]',
:comment_author_url => '',
:comment_content => 'I beg to differ....'

check = Akismetor.spam?(comment_attributes) puts “Is this spam? #checkcheck.to_s.”

The Akismet API

Akismet API Documentation Version 1.1 is at

blog (required)

The front page or home URL of the instance making the request. For a blog or wiki this would be the front page. Note: Must be a full URI, including http://.

user_ip (required)

IP address of the comment submitter.

user_agent (required)

User agent information.

referrer (note spelling)

The content of the HTTP_REFERER header should be sent here.


The permanent location of the entry the comment was submitted to.


May be blank, comment, trackback, pingback, or a made up value like "registration".


Submitted name with the comment


Submitted email address


Commenter URL.


The content that was submitted.

Other server enviroment variables

In PHP there is an array of enviroment variables called $_SERVER which contains information about the web server itself as well as a key/value for every HTTP header sent with the request. This data is highly useful to Akismet as how the submited content interacts with the server can be very telling, so please include as much information as possible.

This call returns either “true” or “false” as the body content. True means that the comment is spam and false means that it isn’t spam. If you are having trouble triggering you can send “viagra-test-123” as the author and it will trigger a true response, always.