SharpAPI.com Node.js SDK for paraphrasing text
npm install @sharpapi/sharpapi-node-paraphraseSharpAPI.com Node.js Paraphrase SDK enables developers to integrate advanced text paraphrasing capabilities into their Node.js applications. This SDK simplifies interaction with the SharpAPI paraphrasing service, providing a seamless way to generate alternative versions of your text content.
See more at SharpAPI.com Website »


- Node.js >= 16.x
``bash`
npm i @sharpapi/sharpapi-node-paraphrase
---
1. Installation
2. Configuration
3. Usage
- Initialization
- Available Methods
4. Examples
5. Contributing
6. License
---
- Node.js v16 or higher
- npm (Node Package Manager)
You can install the SharpAPI Node.js Paraphrase SDK using npm:
`bash`
npm install @sharpapi/sharpapi-node-paraphrase
Alternatively, if you prefer using Yarn:
`bash`
yarn add @sharpapi/sharpapi-node-paraphrase
---
To protect your credentials, it's recommended to use a .env file to store your SharpAPI API key. Follow these steps:
1. Create a .env File
In the root directory of your project, create a file named .env:
`plaintext`
SHARP_API_KEY=your_actual_api_key_here
2. Install dotenv Package
To load environment variables from the .env file, install the dotenv package:
`bash`
npm install dotenv
3. Load Environment Variables
At the beginning of your application (e.g., in app.js or index.js), add the following line to load the environment variables:
`javascript`
require('dotenv').config();
4. Ensure .env is Ignored
Add .env to your .gitignore file to prevent sensitive information from being committed to version control:
`plaintext`
# .gitignore
.env
---
First, import and initialize the SharpApiParaphraseService with your API key:
`javascript
// Load environment variables
require('dotenv').config();
// Import the SharpApiParaphraseService
const { SharpApiParaphraseService } = require('@sharpapi/sharpapi-node-paraphrase');
// Initialize the SharpApiParaphraseService
const apiKey = process.env.SHARP_API_KEY;
const paraphraseService = new SharpApiParaphraseService(apiKey);
`
The SharpApiParaphraseService class provides a method to paraphrase text:
#### paraphrase(text, language, maxLength, voiceTone, context)
- Description: Generates a paraphrased version of the provided text.
- Parameters:
- text (string): The text to paraphrase.language
- (string, optional): Language of the paraphrase (default: 'English').maxLength
- (number, optional): Maximum length of the paraphrased text.voiceTone
- (string, optional): Tone of the voice in the paraphrase (e.g., 'Neutral').context
- (string, optional): Additional context for paraphrasing.`
- Returns: A Promise that resolves to a status URL.
- Usage:
javascript`
const statusUrl = await paraphraseService.paraphrase(
"Original text to paraphrase.",
"English",
100,
"Neutral",
null
);
// Fetch the results using the core service
const { SharpApiCoreService } = require('@sharpapi/sharpapi-node-core');
const coreService = new SharpApiCoreService(apiKey);
const resultJob = await coreService.fetchResults(statusUrl);
console.log(resultJob.getResultJson());
`javascript
require('dotenv').config();
const { SharpApiParaphraseService } = require('@sharpapi/sharpapi-node-paraphrase');
const { SharpApiCoreService } = require('@sharpapi/sharpapi-node-core');
async function paraphraseExample() {
const apiKey = process.env.SHARP_API_KEY;
const paraphraseService = new SharpApiParaphraseService(apiKey);
const coreService = new SharpApiCoreService(apiKey);
try {
// Original text to paraphrase
const originalText = "The quick brown fox jumps over the lazy dog.";
// Paraphrase the text
const statusUrl = await paraphraseService.paraphrase(originalText);
// Fetch the results
const resultJob = await coreService.fetchResults(statusUrl);
const result = resultJob.getResultJson();
console.log("Original Text:", originalText);
console.log("Paraphrased Text:", result.paraphrased_text);
} catch (error) {
console.error("Error:", error.message);
}
}
paraphraseExample();
`
`javascript
require('dotenv').config();
const { SharpApiParaphraseService } = require('@sharpapi/sharpapi-node-paraphrase');
const { SharpApiCoreService } = require('@sharpapi/sharpapi-node-core');
async function advancedParaphraseExample() {
const apiKey = process.env.SHARP_API_KEY;
const paraphraseService = new SharpApiParaphraseService(apiKey);
const coreService = new SharpApiCoreService(apiKey);
try {
// Original text to paraphrase
const originalText = "The company has experienced significant growth in the last quarter, with revenue increasing by 25%.";
// Paraphrase the text with specific options
const statusUrl = await paraphraseService.paraphrase(
originalText,
"English",
150,
"Professional",
"Financial report"
);
// Fetch the results
const resultJob = await coreService.fetchResults(statusUrl);
const result = resultJob.getResultJson();
console.log("Original Text:", originalText);
console.log("Paraphrased Text:", result.paraphrased_text);
} catch (error) {
console.error("Error:", error.message);
}
}
advancedParaphraseExample();
``
---
For detailed usage and API methods, please refer to the SharpAPI.com Documentation.
---
Please see CHANGELOG for more information on what has changed recently.
---
Check CONTRIBUTION.md file for details.
---
This project is licensed under the MIT License.
---
If you encounter any issues or have questions, feel free to open an issue on the GitHub repository or contact support at contact@sharpapi.com.
---
š For the latest news, tutorials, and case studies, don't forget to follow us on:
- SharpAPI X (formerly Twitter)
- SharpAPI YouTube
- SharpAPI Vimeo
- SharpAPI LinkedIn
- SharpAPI Facebook
---
Happy Coding with SharpAPI Node.js Paraphrase SDK!