npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sharpapi/sharpapi-node-translate

v1.0.1

Published

SharpAPI.com Node.js SDK for translating text

Readme

SharpAPI GitHub cover

Advanced Text Translator API for Node.js

🌐 Translate text with context-aware AI — powered by SharpAPI.

npm version License

SharpAPI Advanced Text Translator provides context-aware translation that understands nuances, idioms, and industry-specific terminology. Supports multiple languages with high accuracy.


📋 Table of Contents

  1. Requirements
  2. Installation
  3. Usage
  4. API Documentation
  5. Examples
  6. License

Requirements

  • Node.js >= 16.x
  • npm or yarn

Installation

Step 1. Install the package via npm:

npm install @sharpapi/sharpapi-node-translate

Step 2. Get your API key

Visit SharpAPI.com to get your API key.


Usage

const { SharpApiTranslateService } = require('@sharpapi/sharpapi-node-translate');

const apiKey = process.env.SHARP_API_KEY; // Store your API key in environment variables
const service = new SharpApiTranslateService(apiKey);

const text = 'Hello, how are you today?';
const targetLanguage = 'Spanish';

async function translateText() {
  try {
    // Submit translation job
    const statusUrl = await service.translate(text, targetLanguage);
    console.log('Job submitted. Status URL:', statusUrl);

    // Fetch results (polls automatically until complete)
    const result = await service.fetchResults(statusUrl);
    console.log('Translation:', result.getResultJson());
  } catch (error) {
    console.error('Error:', error.message);
  }
}

translateText();

API Documentation

Methods

translate(text: string, targetLanguage: string, sourceLanguage?: string, context?: string): Promise<string>

Translates text from source language to target language with optional context.

Parameters:

  • text (string, required): The text to translate
  • targetLanguage (string, required): The target language (e.g., 'Spanish', 'French', 'Japanese')
  • sourceLanguage (string, optional): The source language (auto-detected if not specified)
  • context (string, optional): Additional context to improve translation accuracy

Returns:

  • Promise: Status URL for polling the job result

Example:

const statusUrl = await service.translate(
  'The company is growing fast',
  'Spanish',
  'English',
  'Business context'
);
const result = await service.fetchResults(statusUrl);

Response Format

The API returns the translated text:

{
  "translated_text": "Hola, ¿cómo estás hoy?",
  "source_language": "English",
  "target_language": "Spanish",
  "confidence": 0.98
}

Examples

Basic Translation

const { SharpApiTranslateService } = require('@sharpapi/sharpapi-node-translate');

const service = new SharpApiTranslateService(process.env.SHARP_API_KEY);

const englishText = 'Welcome to our website. We are glad you are here!';

service.translate(englishText, 'French')
  .then(statusUrl => service.fetchResults(statusUrl))
  .then(result => {
    const translation = result.getResultJson();
    console.log('Original:', englishText);
    console.log('Translation:', translation.translated_text);
  })
  .catch(error => console.error('Translation failed:', error));

Translation with Context

const service = new SharpApiTranslateService(process.env.SHARP_API_KEY);

const technicalText = 'The API returns a 404 error when the resource is not found.';

const statusUrl = await service.translate(
  technicalText,
  'German',
  'English',
  'Software development and API documentation'
);

const result = await service.fetchResults(statusUrl);
console.log('Technical translation:', result.getResultJson().translated_text);

Batch Translation

const service = new SharpApiTranslateService(process.env.SHARP_API_KEY);

const phrases = [
  'Good morning',
  'Thank you',
  'How much does it cost?',
  'Where is the nearest station?'
];

const translations = await Promise.all(
  phrases.map(async (phrase) => {
    const statusUrl = await service.translate(phrase, 'Japanese');
    const result = await service.fetchResults(statusUrl);
    return {
      original: phrase,
      translated: result.getResultJson().translated_text
    };
  })
);

console.log('Translations:', translations);

Use Cases

  • Website Localization: Translate website content for international audiences
  • Customer Support: Provide multilingual customer service
  • E-commerce: Translate product descriptions and reviews
  • Content Marketing: Adapt marketing materials for different regions
  • Documentation: Translate technical documentation and user guides
  • Mobile Apps: Localize app content for global markets

Supported Languages

SharpAPI supports translation between 100+ languages including:

English, Spanish, French, German, Italian, Portuguese, Russian, Chinese, Japanese, Korean, Arabic, Hindi, Dutch, Swedish, Polish, Turkish, and many more.


API Endpoint

POST /content/translate

For detailed API specifications, refer to:


Related Packages


License

This project is licensed under the MIT License. See the LICENSE.md file for details.


Support


Powered by SharpAPI - AI-Powered API Workflow Automation