
Perspective
Machine LearningNLP API to return probability that if text is toxic, obscene, insulting or threatening
π Documentation & Examples
Everything you need to integrate with Perspective
π Quick Start Examples
// Perspective API Example
const response = await fetch('https://perspectiveapi.com', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
The NLP API is designed to analyze text and return probabilities indicating whether the content may be toxic, obscene, insulting, or threatening. By leveraging advanced machine learning algorithms, this API provides developers with powerful insights into the sentiment of user-generated content. This functionality is crucial for applications aiming to maintain safe and respectful online environments, enabling businesses to preemptively filter out harmful language and foster positive interactions. With the growing prevalence of online communication, the ability to assess the nature of text helps organizations enhance user experience while adhering to community standards and policies.
Using the NLP API offers numerous advantages for anyone looking to implement text analysis solutions. Benefits include:
- Accurate assessments of textual toxicity levels.
- Ability to moderate user-generated content effectively.
- Integration capabilities with various platforms and languages.
- Continuous improvements to model performance through ongoing learning.
- Enhanced brand reputation by promoting a respectful community dialogue.
Hereβs a simple JavaScript example to call the API:
const axios = require('axios');
async function analyzeText(text) {
const url = 'https://api.perspectiveapi.com/v1alpha/score';
const apiKey = 'YOUR_API_KEY'; // Replace with your API key
const params = {
comment: { text: text },
requestedAttributes: {
TOXICITY: {},
OBSCENE: {},
INSULT: {},
THREAT: {},
}
};
try {
const response = await axios.post(url, params, {
headers: {
'Content-Type': 'application/json',
'API-Key': apiKey
}
});
console.log(response.data);
} catch (error) {
console.error('Error analyzing text:', error);
}
}
analyzeText("Your sample text here");
π 30-Day Uptime History
Daily uptime tracking showing online vs offline minutes