Skip to main content

A Python interface to the Akismet spam-filtering service.

Project description

CI status image

A Python interface to the Akismet spam-filtering service.

Two API clients are available from this library:

  • akismet.SyncClient is an Akismet API client which performs synchronous (blocking) HTTP requests to the Akismet web service.

  • akismet.AsyncClient is an Akismet API client which performs asynchronous (async/await/non-blocking) HTTP requests to the Akismet web service.

Aside from one being sync and the other async, the two clients expose identical APIs, and implement all methods of the Akismet web API, including the v1.2 key and API usage metrics.

To use this library, you will need to obtain an Akismet API key and register a site for use with the Akismet web service; you can do this at <https://akismet.com>. Once you have a key and corresponding registered site URL to use with it, place them in the environment variables PYTHON_AKISMET_API_KEY and PYTHON_AKISMET_BLOG_URL, and they will be automatically detected and used.

You can then construct a client instance and call its methods. For example, to check a submitted forum post for spam:

import akismet

akismet_client = akismet.SyncClient.validated_client()

if akismet_client.comment_check(
    user_ip=submitter_ip,
    comment_content=submitted_content,
    comment_type="forum-post",
    comment_author=submitter_name
):
    # This piece of content was classified as spam; handle it appropriately.

Or using the asynchronous client:

import akismet

akismet_client = await akismet.AsyncClient.validated_client()

if await akismet_client.comment_check(
    user_ip=submitter_ip,
    comment_content=submitted_content,
    comment_type="forum-post",
    comment_author=submitter_name
):
    # This piece of content was classified as spam; handle it appropriately.

Note that in both cases the client instance is created via the alternate constructor validated_client(). This is recommended instead of using the default constructor (i.e., directly calling akismet.SyncClient() or akismet.AsyncClient()); the validated_client() constructor will perform automatic discovery of the environment-variable configuration and validate the configuration with the Akismet web service before returning the client, while directly constructing an instance will not (so if you do directly construct an instance, you must manually provide and validate its configuration).

See the documentation for full details.

The original version of this library was written by Michael Foord.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

akismet-1.3.tar.gz (43.3 kB view details)

Uploaded Source

Built Distribution

akismet-1.3-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file akismet-1.3.tar.gz.

File metadata

  • Download URL: akismet-1.3.tar.gz
  • Upload date:
  • Size: 43.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.0

File hashes

Hashes for akismet-1.3.tar.gz
Algorithm Hash digest
SHA256 7c5497cc37f7b7b6fb4ff21c4afcecfe89344db070bda388d76ff66e453cb8c0
MD5 d52969ef436bd6af671bdcaae3a1e057
BLAKE2b-256 f88ab893021d1463aba91b8987d9498609a6128a09c82d74059513cb088261d6

See more details on using hashes here.

Provenance

File details

Details for the file akismet-1.3-py3-none-any.whl.

File metadata

  • Download URL: akismet-1.3-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.0

File hashes

Hashes for akismet-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 00cd86f04507505d71bc9674feb8b4a809d393fb4b33edbf50508e70b0dcd899
MD5 cff71cfecf5003f97b69fa94fb35b38e
BLAKE2b-256 04ca365f7399b424bf30d4af46d0a7e119fc55bb8587ebb88fe08b4664b48d54

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page