@shipi18n/api

Official Node.js client for the Shipi18n translation API. Translate JSON, text, and i18n files with a simple, type-safe API.
Why Shipi18n?
- Stop copy-pasting into Google Translate - One API call translates to 100+ languages
- Placeholders stay intact -
{name}, {{count}}, %s are preserved automatically
- i18next-native - Built-in pluralization, namespaces, ICU MessageFormat support
- 90-day Translation Memory - Same content? Cached. No extra cost.
- Key-based pricing - Pay for unique strings, not characters or API calls
Installation
npm install @shipi18n/api
Quick Start
import { Shipi18n } from '@shipi18n/api';
const shipi18n = new Shipi18n({
apiKey: 'your-api-key',
});
const result = await shipi18n.translateJSON({
content: {
greeting: 'Hello',
farewell: 'Goodbye',
},
sourceLanguage: 'en',
targetLanguages: ['es', 'fr', 'de'],
});
console.log(result.es);
console.log(result.fr);
console.log(result.de);
Features
- JSON Translation - Translate nested JSON objects while preserving structure
- Placeholder Preservation - Keeps
{name}, {{count}}, %s placeholders intact
- i18next Support - Full support for pluralization, namespaces, and ICU MessageFormat
- TypeScript - Full type definitions included
- Zero Dependencies - Uses native fetch (Node.js 18+)
API Reference
Constructor
const shipi18n = new Shipi18n({
apiKey: 'your-api-key',
baseUrl: 'https://api.shipi18n.com',
timeout: 30000,
});
translateJSON(options)
Translate JSON content to multiple languages.
const result = await shipi18n.translateJSON({
content: { greeting: 'Hello' },
sourceLanguage: 'en',
targetLanguages: ['es', 'fr'],
preservePlaceholders: true,
enablePluralization: true,
namespace: 'common',
groupByNamespace: 'auto',
exportPerNamespace: false,
});
translateText(options)
Translate plain text to multiple languages.
const result = await shipi18n.translateText({
content: 'Hello, world!',
sourceLanguage: 'en',
targetLanguages: ['es', 'fr'],
preservePlaceholders: true,
});
translateI18next(options)
Convenience method for i18next files with all features enabled.
const result = await shipi18n.translateI18next({
content: {
common: {
greeting: 'Hello, {{name}}!',
items_one: '{{count}} item',
items_other: '{{count}} items',
},
},
sourceLanguage: 'en',
targetLanguages: ['es', 'fr', 'de'],
});
Fallback Options
Handle missing translations gracefully with built-in fallback support:
const result = await shipi18n.translateJSON({
content: { greeting: 'Hello', farewell: 'Goodbye' },
sourceLanguage: 'en',
targetLanguages: ['es', 'pt-BR', 'zh-TW'],
fallback: {
fallbackToSource: true,
regionalFallback: true,
fallbackLanguage: 'en',
},
});
if (result.fallbackInfo?.used) {
console.log(result.fallbackInfo.regionalFallbacks);
console.log(result.fallbackInfo.languagesFallbackToSource);
console.log(result.fallbackInfo.keysFallback);
}
Fallback behavior:
| Missing translation for language | Falls back to regional variant (pt-BR → pt), then source |
| Missing translation for key | Fills key from source content |
| API error | Returns source content for all languages (if enabled) |
Examples
Nested JSON with Namespaces
const result = await shipi18n.translateJSON({
content: {
common: {
buttons: {
submit: 'Submit',
cancel: 'Cancel',
},
},
checkout: {
total: 'Total: {{amount}}',
pay: 'Pay Now',
},
},
sourceLanguage: 'en',
targetLanguages: ['es'],
});
console.log(result.es);
Pluralization (i18next-style)
const result = await shipi18n.translateJSON({
content: {
items_one: '{{count}} item',
items_other: '{{count}} items',
},
sourceLanguage: 'en',
targetLanguages: ['ru'],
});
console.log(result.ru);
ICU MessageFormat
const result = await shipi18n.translateJSON({
content: {
welcome: '{gender, select, male {Welcome, Mr. {name}} female {Welcome, Ms. {name}} other {Welcome, {name}}}',
},
sourceLanguage: 'en',
targetLanguages: ['es'],
});
Export Per Namespace (for separate files)
const result = await shipi18n.translateJSON({
content: {
common: { greeting: 'Hello' },
checkout: { pay: 'Pay' },
},
sourceLanguage: 'en',
targetLanguages: ['es', 'fr'],
exportPerNamespace: true,
});
Error Handling
import { Shipi18n, Shipi18nError } from '@shipi18n/api';
try {
const result = await shipi18n.translateJSON({ ... });
} catch (error) {
if (error instanceof Shipi18nError) {
console.error(`Error ${error.statusCode}: ${error.message}`);
console.error(`Code: ${error.code}`);
}
}
Error Codes
MISSING_API_KEY | API key not provided |
INVALID_API_KEY | API key is invalid |
QUOTA_EXCEEDED | Monthly character limit reached |
RATE_LIMITED | Too many requests |
TIMEOUT | Request timed out |
NETWORK_ERROR | Network connection failed |
Supported Languages
Over 100 languages supported. Common codes:
en | English |
es | Spanish |
fr | French |
de | German |
it | Italian |
pt | Portuguese |
zh | Chinese |
ja | Japanese |
ko | Korean |
ar | Arabic |
ru | Russian |
hi | Hindi |
Get Your API Key
- Sign up at shipi18n.com
- Go to Dashboard > API Keys
- Generate a new API key
Documentation & Resources
📚 Full Documentation: shipi18n.com/integrations/nodejs-sdk
Related Packages
Examples
License
MIT
shipi18n.com ·
GitHub ·
Pricing