Profanity Filter API
The profanity API checks for profanity in the given text - it provides a 0/1 label for each token, where 1 indicates profanity was detected. Note that as with any profanity check API, there will be terms specific to different industries and audiences that are not captured; please contact us with any feedback.
Sample Code
- cURL
 - JavaScript
 - Python
 
curl -X POST https://api.sapling.ai/api/v1/profanity \
     -H "Content-Type: application/json" \
     -d '{"key":"<api-key>", "text":"This is so damn stupid"}'
import axios from 'axios';
async function run(text) {
    try {
        const response = await axios.post(
            'https://api.sapling.ai/api/v1/profanity',
            {
                key: '<api-key>',
                text,
            },
        );
        const {status, data} = response;
        console.log({status});
        console.log(JSON.stringify(data, null, 4));
    } catch (err) {
        const { msg } = err.response.data;
        console.log({err: msg});
    }
}
run("This is so damn stupid.");
import requests
from pprint import pprint
response = requests.post(
    "https://api.sapling.ai/api/v1/profanity",
    json={
        "key": "<api-key>",
        "text": "This is so damn stupid."
    }
)
if 200 <= response.status_code < 300:
    pprint(response.json())
else:
    print('Error: ', response.status_code, response.text)
Sample Response
{
    "labels": [
        0,
        0,
        0,
        1,
        1
    ],
    "toks": [
        "This",
        "is",
        "so",
        "damn",
        "stupid."
    ]
}
Request Parameters
POST to https://api.sapling.ai/api/v1/profanity
key: String
32-character API key. Can also be supplied via the Authorization header as a bearer token; if both are provided, the key parameter takes precedence.
text: String
Text to check for profanity.
Response Parameters
The profanity filter API response contains two fields:
toks: The tokens (words) detected in the sentence.labels: For each token, 0 (not profanity) or 1 (profanity).