Dictionary SDK Reference

Official JavaScript/TypeScript SDK for the Dictionary API. Build language tools, educational apps, and AI-powered text processing with our comprehensive word intelligence platform.

Installation

Install the Dictionary SDK using your preferred package manager:

npm / yarn / pnpm
npm install @dictionary/sdk
# or
yarn add @dictionary/sdk
# or
pnpm add @dictionary/sdk

Initialization

Import and configure the SDK with your API credentials. You can obtain your API key from the Dictionary Developer Dashboard.

TypeScript
import { Dictionary } from '@dictionary/sdk';

const client = new Dictionary({
  apiKey: process.env.DICTIONARY_API_KEY,
  region: 'us-east-1', // Optional
  timeout: 5000        // Optional (ms)
});

getSynonyms() async

Retrieve context-aware synonyms and antonyms for a given word.

client.getSynonyms(
  word: string,
  options?: { includeAntonyms?: boolean }
) => Promise<SynonymResult>
TypeScript
const syns = await client.getSynonyms('joyful', { includeAntonyms: true });
// Returns: { synonyms: ['happy', 'elated', 'cheerful'], antonyms: ['sad', 'gloomy'] }

translate() async

Context-aware translation across 100+ languages with dialect support.

client.translate(
  text: string,
  targetLang: string,
  options?: { sourceLang?: string; context?: string }
) => Promise<TranslationResult>

Configuration

The SDK accepts a configuration object during initialization. All options are optional unless marked required.

OptionTypeDefaultDescription
apiKeystring-Your secret API key
regionstring'us-east-1'API endpoint region
timeoutnumber5000Request timeout in milliseconds
retriesnumber3Automatic retry count on failure
cachebooleantrueEnable local response caching

Error Handling

The SDK throws standardized error objects for all API failures. Catch and handle them gracefully in your application.

TypeScript
import { DictionaryError } from '@dictionary/sdk';

try {
  const result = await client.search('word');
} catch (error) {
  if (error instanceof DictionaryError) {
    console.error(`[${error.code}] ${error.message}`);
    // Handle: INVALID_API_KEY, RATE_LIMITED, NOT_FOUND, etc.
  }
}

Rate Limits

API requests are throttled based on your subscription tier:

  • Free Tier: 100 requests/minute
  • Pro Tier: 1,000 requests/minute
  • Enterprise: Custom limits with dedicated throughput

When rate limited, the SDK automatically queues and retries requests with exponential backoff up to the configured retry limit.

}