Perspective

Perspective

Machine Learning

NLP API to return probability that if text is toxic, obscene, insulting or threatening

Visit API🔁 Alternatives

📚 Documentation & Examples

Everything you need to integrate with Perspective

🚀 Quick Start Examples

Perspective Javascript Examplejavascript
// 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

Dec 6Dec 8Dec 10Dec 12Dec 14Dec 16Dec 18Dec 20Dec 22Dec 24Dec 26Dec 28Dec 30Jan 1Jan 404008001440Minutes
Online
Offline

Related APIs in Machine Learning