@translate-api/client
v1.0.0
Published
Official JavaScript/TypeScript SDK for Translate API - Easy text translation
Maintainers
Readme
Translate API - JavaScript/TypeScript SDK
Official JavaScript and TypeScript SDK for Translate API.
🚀 Quick Start (For Beginners)
Step 1: Get Your API Key
- Go to https://translate-api.com
- Click "Login" or "Get Started"
- Create an account (it's free to start!)
- Go to your Dashboard
- Click "Create API Key"
- Copy your API key - you'll need it!
Step 2: Install the SDK
Open your terminal/command prompt and run:
npm install @translate-api/clientOr if you use yarn:
yarn add @translate-api/clientStep 3: Use It!
const TranslateAPI = require('@translate-api/client');
// Replace 'your-api-key' with your actual API key from translate-api.com
const client = new TranslateAPI('your-api-key');
// Translate to one language
const result = await client.translate('Hello world', 'es');
console.log(result.translations.es); // Output: "Hola mundo"
// Translate to multiple languages at once
const multiResult = await client.translate('Hello world', ['es', 'fr', 'de']);
console.log(multiResult.translations);
// Output: { es: "Hola mundo", fr: "Bonjour le monde", de: "Hallo Welt" }📖 Full API Reference
Constructor
const client = new TranslateAPI(apiKey, options);apiKey(required): Your API key from translate-api.comoptions.baseUrl(optional): Custom API URL (default: 'https://translate-api.com/v1')
translate(text, targetLanguage)
Translate text to one or more languages.
Parameters:
text: The text you want to translatetargetLanguage: A language code ('es') or array of codes (['es', 'fr'])
Returns: Promise with translation results
translateBatch(items)
Translate multiple texts at once.
const results = await client.translateBatch([
{ text: 'Hello', targetLanguage: 'es' },
{ text: 'Goodbye', targetLanguage: 'fr' }
]);🌍 Supported Languages
Visit translate-api.com/documentation for a full list of supported language codes.
Common codes: en (English), es (Spanish), fr (French), de (German), it (Italian), pt (Portuguese), zh (Chinese), ja (Japanese), ko (Korean), ar (Arabic)
❓ Need Help?
- Documentation: translate-api.com/documentation
- Support: [email protected]
📝 License
MIT License - feel free to use in your projects!
