censorly

1.0.3 • Public • Published

Censorly

Censorly is a Node.js SDK for interacting with the Censorly API, a powerful AI-powered text moderation service. This package simplifies integration by providing easy-to-use methods for analyzing text.

Installation

Install the package using npm:

npm install censorly

Usage

First, import the Censorly SDK and create an instance with your API token.

Requirement: API Token

To use this SDK, you must sign up for an account on Censorly and obtain an API token in Dashboard.

Example Using Censorly Class

import Censorly from 'censorly';

// Initialize the SDK with your API token
const censorly = new Censorly('your_api_token');

// Analyze a message
async function analyzeText() {
  try {
    const result = await censorly.analyzeMessage('This is the text to analyze.');
    console.log('Analysis result:', result);
  } catch (error) {
    console.error('Error analyzing text:', error.message);
  }
}
analyzeText();

Example Using Standalone Function

import Censorly from 'censorly';

Censorly.analyzeMessage({ apiToken: 'your_api_token', text: "Text to analyze" }) // Must be a valid Object
  .then((result) => {
    console.log(result);
  })
  .catch((error) => {
    console.error(error.message);
  });

Using CommonJS

If your project uses CommonJS instead of ES Modules, you can use the following syntax to import the package:

const { Censorly, analyzeMessage } = require('censorly');

The rest of the usage remains the same.

Methods

analyzeMessage(text: string): Promise<object>

Analyzes a given text for flagged topics.

Parameters:

  • text (string): The text to be analyzed.

Returns:

A Promise resolving to the analysis result(JSON)

Example Response

{
  "flagged": boolean,    // Whether the content was flagged as inappropriate
  "topics": string[],    // Array of main topics identified in the text
  "confidence": number,  // Number from 0 to 1.0 indicating AI's certainty
  "language": string     // Two-letter language code (e.g., "en", "es") or "Unknown"
}

License

This project is licensed under the MIT License.

Package Sidebar

Install

npm i censorly

Weekly Downloads

20

Version

1.0.3

License

MIT

Unpacked Size

5.73 kB

Total Files

4

Last publish

Collaborators

  • kaayoos