SDKs

Official clients for Python, PHP and JavaScript. The same names in all three, the same answers as the API, and no dependencies.

Python

Python 3.9+, no dependencies

pip install toxicfilter-sdk

from toxicfilter import Client

tf = Client("tf_live_...")
verdict = tf.text(comment, locales=["en"])

if verdict.blocked:
    refuse()
elif verdict.needs_review:
    hold(verdict.id, verdict.reasons)

PHP

PHP 8.1+, ext-curl

composer require edulazaro/toxicfilter-sdk

use ToxicFilter\Client;

$tf = new Client('tf_live_...');
$verdict = $tf->text($comment, ['locales' => ['en']]);

if ($verdict->blocked()) {
    return refuse();
}

JavaScript

Node 20+, Deno, Bun, Workers

npm install toxicfilter-sdk

import ToxicFilter from 'toxicfilter-sdk'

const tf = new ToxicFilter('tf_live_...')
const verdict = await tf.text(comment, { locales: ['en'] })

if (verdict.blocked) return refuse()

Retries that are safe

A rate limit or a server error is asked again after a growing wait, with the same idempotency key, so it is judged and billed once. Out of credits is never retried.

Errors you can branch on

A bad key, a rejected field and an empty account each arrive as their own type, carrying what you need to act on them.

Webhooks checked for you

One call verifies that an event really came from us before your code acts on it.

Nothing pulled in

No HTTP library pinned on your application. Each client takes a transport you can replace.

Prefer plain HTTP? Every endpoint is in the API reference, with a curl for each.