5 releases

0.2.0 Apr 8, 2024
0.1.4 Apr 8, 2024
0.1.3 Mar 27, 2023
0.1.2 Jan 9, 2023
0.1.1 Sep 26, 2022

#423 in Web programming

Download history 15/week @ 2024-03-30 233/week @ 2024-04-06 178/week @ 2024-04-13 94/week @ 2024-04-20 58/week @ 2024-04-27 99/week @ 2024-05-04 106/week @ 2024-05-11 46/week @ 2024-05-18 99/week @ 2024-05-25 87/week @ 2024-06-01 63/week @ 2024-06-08 34/week @ 2024-06-15 98/week @ 2024-06-22 46/week @ 2024-06-29 54/week @ 2024-07-06 60/week @ 2024-07-13

263 downloads per month

Apache-2.0

24KB
401 lines

Instant Akismet: Akismet spam detection client written in Rust

Documentation Crates.io Build status License: Apache 2.0

Instant Akismet is a full set of Rust bindings for the Akismet spam-detection service and is used in production over at Instant Domains to help us protect our users' sites from comment and messaging spam.

Features

  • Supports all Akismet API features
    • Akismet key verification
    • Comment spam check
    • Report spam (false negative)
    • Report ham (false positive)
  • Akismet pro-tip handling
  • Full Akismet error propagation
  • Unit tests for all API features

Getting Started

To begin with, you'll need to head over to Akismet and join the developer program to obtain an API key.

Note: In order to run the included tests, this key should be set as AKISMET_KEY in your environment.

Usage

// Initialize client
let akismet_client = AkismetClient::new(
    String::from("https://exampleblog.com"), // The URL for your blog
    akismet_key, // Your Akismet API key
    reqwest::Client::new(), // Reqwest client to use for requests
    AkismetOptions::default(), // AkismetOptions config
);

// Verify key
akismet_client.verify_key().await?;

// Create a comment
let comment = Comment::new(akismet_client.blog.as_ref(), "8.8.8.8")
    .comment_author("exampleUser1")
    .comment_author_email("example-user@example.com")
    .comment_content("example comment content");

// Check comment for spam
let is_spam = akismet_client.check_comment(comment).await?;

Testing

In order to run the included tests, you will need to ensure that you have your API key set as AKISMET_KEY in your environment.

cargo test

Dependencies

~7–19MB
~293K SLoC