Profanity Filter is a simple tool for filtering out profanity words from a text. It returns the text with the profanity words replaced by placeholders.
npm install @apiverve/profanityfiltershell
npm install @apiverve/profanityfilter
`
Using yarn:
`shell
yarn add @apiverve/profanityfilter
`
---
Configuration
Before using the Profanity Filter API client, you have to setup your account and obtain your API Key.
You can get it by signing up at https://apiverve.com
---
Quick Start
Get started with the Quick Start Guide
The Profanity Filter API documentation is found here: https://docs.apiverve.com/ref/profanityfilter.
You can find parameters, example responses, and status codes documented here.
$3
`javascript
const profanityfilterAPI = require('@apiverve/profanityfilter');
const api = new profanityfilterAPI({
api_key: '[YOUR_API_KEY]'
});
`
---
Usage
---
$3
Using the API is simple. All you have to do is make a request. The API will return a response with the data you requested.
`javascript
var query = {
"text": "Today is so damn hot! Why the hell would anyone go outside?",
"mask": "*"
};
api.execute(query, function (error, data) {
if (error) {
return console.error(error);
} else {
console.log(data);
}
});
`
---
$3
You can also use promises to make requests. The API returns a promise that you can use to handle the response.
`javascript
var query = {
"text": "Today is so damn hot! Why the hell would anyone go outside?",
"mask": "*"
};
api.execute(query)
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});
`
---
$3
You can also use async/await to make requests. The API returns a promise that you can use to handle the response.
`javascript
async function makeRequest() {
var query = {
"text": "Today is so damn hot! Why the hell would anyone go outside?",
"mask": "*"
};
try {
const data = await api.execute(query);
console.log(data);
} catch (error) {
console.error(error);
}
}
`
---
Example Response
`json
{
"status": "ok",
"error": null,
"data": {
"isProfane": true,
"filteredText": "Today is so * hot! Why the * would anyone go outside?",
"mask": "*",
"trimmed": false,
"profaneWords": 2
}
}
``