Akismet for Kotlin/Java/Android, a client library for accessing the Automattic Kismet (Akismet) spam comments filtering service. https://github.com/ethauvin/akismet-kotlin
Find a file
2025-03-20 20:37:27 -07:00
.circleci Update Java/Kotlin to latest versions 2025-03-16 17:06:46 -07:00
.github/workflows Bump Kotlin to version 2.1.20 2025-03-20 09:44:19 -07:00
.idea Bump Kotlin to version 2.1.20 2025-03-20 09:44:19 -07:00
config Bump Kotlin to version 2.0.20 2024-09-19 18:19:07 -07:00
docs Fixed docs generation classpath 2024-05-25 01:18:29 -07:00
examples Bump Kotlin to version 2.1.20 2025-03-20 09:44:19 -07:00
lib/bld Update extensions dependencies 2025-03-16 11:28:00 -07:00
src Combine Kotlin compile options 2025-03-20 20:37:27 -07:00
.editorconfig Initial commit. 2019-09-18 05:16:01 -07:00
.gitattributes Initial commit. 2019-09-18 05:16:01 -07:00
.gitignore Minor cleanup 2024-05-23 22:22:33 -07:00
.gitlab-ci.yml Updated Kotlin dependencies 2024-07-15 14:44:18 -07:00
bitbucket-pipelines.yml Updated Kotlin dependencies 2024-07-15 14:44:18 -07:00
bld Moved from Gradle to bld 2023-11-12 15:12:11 -08:00
bld.bat Moved from Gradle to bld 2023-11-12 15:12:11 -08:00
LICENSE.txt Update license copyright 2025-03-16 12:55:07 -07:00
pom.xml Bump Kotlin to version 2.1.20 2025-03-20 09:44:19 -07:00
README.md Bump Kotlin to version 2.1.20 2025-03-20 09:44:19 -07:00
sonar-project.properties Moved from Gradle to bld 2023-11-12 15:12:11 -08:00
version.txt Updated Kotlin dependencies 2024-07-15 14:44:18 -07:00

License (3-Clause BSD) Kotlin bld Release Nexus Snapshot Maven Central

Quality Gate Status GitHub CI CircleCI

Akismet for Kotlin, Java and Android

A pretty complete and straightforward implementation of the Automattic's Akismet API, a free service which can be used to actively stop comments spam.

Examples (TL;DR)

Kotlin

val akismet = Akismet(apiKey = "YOUR_API_KEY", blog = "YOUR_BLOG_URL")
val comment = AkismetComment(userIp = "127.0.0.1", userAgent = "curl/7.29.0").apply {
    referrer = "https://www.google.com"
    type = CommentType.COMMENT
    author = "admin"
    authorEmail = "test@test.com"
    authorUrl = "https://www.CheckOutMyCoolSite.com"
    dateGmt = Akismet.dateToGmt(Date())
    content = "Thanks for reviewing our software."
}
// ...

val isSpam = akismet.checkComment(comment)
if (isSpam) {
    // ...
}

View Full Examples

Java

final Akismet akismet = new Akismet("YOUR_API_KEY", "YOUR_BLOG_URL");
final AkismetComment comment = new AkismetComment(
    new CommentConfig.Builder("127.0.0.1", "curl/7.29.0")
            .referrer("https://www.google.com")
            .type(CommentType.COMMENT)
            .author("admin")
            .authorEmail("test@test.com")
            .authorUrl("https://www.CheckOutMyCoolSite.com")
            .dateGmt(Akismet.dateToGmt(new Date()))
            .content("Thanks for reviewing our software.")
            .build
);
//...

final boolean isSpam = akismet.checkComment(comment);
if (isSpam) {
    // ...
}

View Full Examples

bld

To use with bld, include the following dependency in your build file:

repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);

scope(compile)
    .include(dependency("net.thauvin.erik:akismet-kotlin:1.1.0-SNAPSHOT"));

Gradle

To use with Gradle, include the following dependency in your build file:

repositories {
    mavenCentral()
}

dependencies {
    implementation("net.thauvin.erik:akismet-kotlin:1.1.0-SNAPSHOT")
}

Instructions for using with Maven, Ivy, etc. can be found on Maven Central.

HttpServletRequest

The more information is sent to Akismet, the more accurate the response is. An HttpServletRequest can be used as a parameter so that all the relevant information is automatically included.

AkismetComment(request = context.getRequest())

This will ensure that the user's IP, agent, referrer and various environment variables are automatically extracted from the request.

View Full Example

JSON

Since comments mis-identified as spam or ham can be submitted to Askimet to improve the service. A comment can be saved as a JSON object to be stored in a database, etc.

var json = comment.toJson()

At a latter time, the comment can then be submitted:

akismet.submitSpam(Akismet.jsonComment(json))

Contributing

If you want to contribute to this project, all you have to do is clone the GitHub repository:

git clone git@github.com:ethauvin/akismet-kotlin.git

Then use bld to build:

cd akismet-kotlin
./bld compile

The project has an IntelliJ IDEA project structure. You can just open it after all the dependencies were downloaded and peruse the code.

More…

If all else fails, there's always more Documentation.