akismet 0.6.1


Release License Build

Prevent comment spam using Akismet service, in Dart.


  • Key Verification: checks an Akismet API key and gets a value indicating whether it is valid.
  • Comment Check: checks a comment and gets a value indicating whether it is spam.
  • Submit Spam: submits a comment that was not marked as spam but should have been.
  • Submit Ham: submits a comment that was incorrectly marked as spam but should not have been.


Installing via Pub

1. Depend on it

Add this to your package's pubspec.yaml file:

  akismet: any

2. Install it

If you're using the Dart Editor, choose:

Menu > Tools > Pub Get

Or if you want to install from the command line, run:

$ pub get

3. Import it

Now in your Dart code, you can use:

import 'package:akismet/html.dart'; // In browser applications.
import 'package:akismet/io.dart'; // In console applications.


Key Verification

var client = new Client('YourAPIKey', Uri.parse('http://your.blog.url'));
client.verifyKey().then((isValid) =>
  print(isValid ? 'Your API key is valid.' : 'Your API key is invalid.')

Comment Check

var author = new Author()
  ..ipAddress = ''
  ..userAgent = 'Mozilla/5.0';

var comment = new Comment('A comment.', author);
client.checkComment(comment).then((isSpam) =>
  print(isSpam ? 'The comment is marked as spam.' : 'The comment is marked as ham.')

Submit Spam/Ham

client.submitSpam(comment).then((_) => print('Spam submitted.'));
client.submitHam(comment).then((_) => print('Ham submitted.'));



The Akismet client comes in two flavors: a first one based on dart:io for server/console applications, and a second one based on dart:html for client/browser applications.

Their usage is the same, but the HTML client is limited by security restrictions in a browser context. Unfortunately, the Akismet service does not support CORS headers. So, the HTML client can't be used directly with the official service.


To be able to use the HTML client, we must rely on a proxy server adding CORS headers to service responses.

This is why a server implementation is provided with this package. To facilitate its usage, a command line interface is available in the bin folder.

From a command prompt, run the cli.dart script:

$ dart bin/cli.dart --help

Starts an Akismet.dart server.

    cli.dart [options]

-h, --help        output usage information
-V, --version     output the version number
-a, --address     address that the server should run on
                  (defaults to "")

-p, --port        port that the server should run on
                  (defaults to "3000")

-r, --redirect    the URL to redirect when a request is unhandled
    --silent      silence the log output from the server

Unit Tests


To test the dart:html client, launch a server instance, and points your browser to this link: Unit Tests of HTML Client


To test the dart:io client, you must set one or several environment variables prior to running the tests:

  • AKISMET_API_KEY: the Akismet API key (required).
  • AKISMET_BLOG: the front page or home URL (optional).
  • AKISMET_SERVICE_URL: the URL of the remote service (optional).

Then, run the io_test.dart script from a command prompt:

$ dart test/io_test.dart


Akismet.dart is distributed under the MIT License.


This file contains highlights of what changes on each version of the Akismet.dart package.

Version 0.6.1

  • Fixed bugs in async / await implementation.
  • Fixed bugs in JSON serialization.

Version 0.6.0

  • Added role property to Author class.
  • Added isTest property to Client class.
  • Added date and postModified properties to Comment class.
  • Moved the Future API to async and await.

Version 0.5.1

Version 0.5.0

  • Breaking change: renamed Server.start method to bind.
  • Added Server.bindSecure method to support SSL protocol.
  • Updated the package dependencies.

Version 0.4.0

  • Moved most methods and properties of Client child classes to the base abstract class.
  • Added Blog class to support the latest Akismet APIs.
  • Added Server events: you can listen to onClose, onError, onListening and onRequest streams.
  • Added --silent option to server CLI.
  • Breaking change: renamed Server.stop method to close.
  • Breaking change: renamed HTTPHeaders constants by using X_ as prefix.
  • Breaking change: removed Client.useSecureRequests property.

Version 0.3.2

Version 0.3.1

Version 0.3.0

  • Updated the package dependencies (fixed GitHub issue #2).
  • Removed obsolete build scripts (build.dart and tool/generate_docs.dart).

Version 0.2.1

  • Added new properties and methods to Server class.
  • Added utility scripts in tool folder.
  • Changed the package layout.
  • Breaking change: renamed Server.secureRequests property to useSecureRequests.

Version 0.2.0

  • Added client implementation based on dart:html.
  • Added server implementation used to proxy requests from HTML clients to Akismet service.
  • Breaking change: Uri in constructors can no longer be specified as String.
  • Breaking change: removed Client.encoding property.

Version 0.1.1

Version 0.1.0

  • Initial release: client implementation based on dart:io.

1. Depend on it

Add this to your package's pubspec.yaml file:


2. Install it

You can install packages from the command line:

$ pub get

Alternatively, your editor might support pub. Check the docs for your editor to learn more.


Prevent comment spam using Akismet service.


Email cedric@belin.io C├ędric Belin





Source code (hyperlinked)