Skip to content
Legend108 edited this page Jun 17, 2022 · 3 revisions

Welcome to the perspectiveapi-wrapper wiki!

Connecting to the API is very simple

Firstly, import the package:

const client = require("perspectiveapi-wrapper");

Next step, connect with the API

const police = new client({
  apiKey: "Your top secret api key",
});

Here, we create a client instance and set it to police. Client takes one argument, that's "apiKey" Where you will paste your key you get from the cloud console

A well documented page on how to get the API key > Click Here!

Finally, we will be checking the toxicity levels.

// Don't keep variable names these long, not a good practice...
let whatYouWantToAnalyze = "Some text, or maybe a slang?";

police.Analyze(whatYouWantToAnalyze, (toxicity) => {
	console.log(toxicity);
});

This should return the toxicity level as an integer.

That's all!

Don't forget to star the repo if you like it, and join the support server for further help and bugs.

More changes coming soon...

Clone this wiki locally