# @textmod/textmod-node

> TextMod - nodejs sdk

Latest version **1.0.9** (published 2023-05-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @textmod/textmod-node
pnpm add @textmod/textmod-node
yarn add @textmod/textmod-node
bun add @textmod/textmod-node
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2023-05-10 |
| First published | 2023-05-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14 |
| Dependencies | 3 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | textmod |

## Links

- npm: https://www.npmjs.com/package/@textmod/textmod-node
- Repository: https://github.com/textmod/textmod-node
- Homepage: https://github.com/textmod/textmod-node#readme
- Issues: https://github.com/textmod/textmod-node/issues
- npm.io page: https://npm.io/package/@textmod/textmod-node

## Dependencies (3)

- [axios](https://npm.io/package/axios.md) ^1.4.0
- [lodash.camelcase](https://npm.io/package/lodash.camelcase.md) ^4.0.0
- [lodash.kebabcase](https://npm.io/package/lodash.kebabcase.md) ^4.1.1

## Recent versions

- 1.0.9 (latest) — 2023-05-10
- 1.0.8 — 2023-05-10
- 1.0.6 — 2023-05-10
- 1.0.5 — 2023-05-10
- 1.0.4 — 2023-05-09
- 1.0.3 — 2023-05-09

## README

# TextMod SDK for Node.js

[![codecov](https://codecov.io/gh/textmod/textmod-node/branch/master/graph/badge.svg?token=USRUTFK5KE)](https://codecov.io/gh/textmod/textmod-node)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

This is an SDK for the [TextMod API](https://textmod.xyz/) that allows you to easily moderate text content for various sentiments such as spam, hate, and pornography.

## Installation

```bash
npm install @textmod/textmod-node
```


## Usage

To use the TextMod SDK, you'll need an API authentication token from the [TextMod website](https://textmod.xyz).
Once you have that, you can create an instance of the TextMod class:

```javascript
import { TextMod } from '@textmod/textmod-node';

const textmod = new TextMod({
  authToken: '<YOUR_AUTH_TOKEN>',
  filterSentiments: ['spam', 'hate', 'sexual/minors'],
});
```

The filterSentiments option is optional and defaults to allowing all sentiments.
If specified, only the specified sentiments will be moderated.

You can then use the moderate method to moderate text content:

```javascript
const result = await textmod.moderate('Hello world!');
console.log(result); // { spam: false, hate: false, sexualMinors: false, ... }
```

The moderate method returns a `Promise` that resolves to a `ModerationResult` object.
This object has a boolean property for each sentiment that has been moderated.
The property names are normalized to use camelCase instead of kebab-case.

## API Documentation

### TextMod

The TextMod class is the main class in this SDK. It has one method:

`moderate(text: string): Promise<ModerationResult>`

Moderates the specified text and returns a `ModerationResult` object.
The `text` parameter is a string representing the content to moderate.

### Types
This SDK defines the following types:

- `ModerationResult`: A type that represents the result returned by the moderate method. It is an object with boolean properties for each sentiment that has been moderated. The property names are normalized to use camelCase instead of kebab-case.
- `TextModApiRequestBody`: A type that represents the request body sent to the TextMod API when moderating content.
- `TextModSentiments`: A type that represents the response returned by the TextMod API when moderating content. It is an object with boolean properties for each sentiment that has been moderated.
- `TextModConfig`: A type that represents the configuration options for the `TextMod` class. It has two properties:
  - `authToken`: A string representing the TextMod API authentication token.
  - `filterSentiments`: An optional array of sentiment names to moderate. If specified, only the specified sentiments will be moderated.

## Example
Here's an example of how to use the TextMod class:

```typescript
import { TextMod } from 'textmod-sdk';

const textmod = new TextMod({
  authToken: '<YOUR_AUTH_TOKEN>',
  filterSentiments: ['spam', 'hate', 'sexual/minors'],
});

const result = await textmod.moderate('Hello world!');
console.log(result); // { spam: false, hate: false, sexualMinors: false, ... }
```


## Contributing
If you have suggestions for how this SDK could be improved, or want to report a bug, please open an issue! We welcome contributions from the community.

## License
This SDK is released under the [MIT License](./LICENSE.md).

---
_Source: https://npm.io/package/@textmod/textmod-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
