JavaScript / TypeScript SDK
Fetch-based, TypeScript-native, zero runtime deps. Works in Node 18+ and every modern browser. MIT.
Install
npm install @rlbwhisk/client
# or pnpm / yarn / bun
Basic use
import { RLBWhisk } from '@rlbwhisk/client';
const c = new RLBWhisk();
// or: new RLBWhisk({ apiKey: 'rlbwhisk_live_...' })
// or: set RLBWHISK_API_KEY in your Node environment
// Manual mode — structured findings
const result = await c.check('Ths is a smple sentnce.', { language: 'en' });
for (const m of result.misspellings) {
console.log(m.word, '->', m.suggestions.slice(0, 3));
}
// Auto mode — get corrected text
const fixed = await c.fix('Ths is a smple sentnce.', { language: 'en' });
console.log(fixed.correctedText);
// "This is a simple sentence."
Error handling
import {
RLBWhisk,
WhiskError,
InvalidApiKey,
RateLimitExceeded,
InvalidLanguage,
InternalError,
} from '@rlbwhisk/client';
try {
const r = await c.check('hi', { language: 'en' });
} catch (e) {
if (e instanceof InvalidApiKey) {
console.log('Bad key');
} else if (e instanceof RateLimitExceeded) {
console.log(`Retry after ${e.retryAfter}s (request ${e.requestId})`);
} else if (e instanceof InvalidLanguage) {
console.log('Language not supported');
} else if (e instanceof InternalError) {
console.log(`Server error, quote request_id=${e.requestId}`);
} else if (e instanceof WhiskError) {
console.log(`[${e.code}] ${e.message}`);
}
}
Auto-retries 429s up to maxRetries: 3, respecting Retry-After.
Options
const c = new RLBWhisk({
apiKey: 'rlbwhisk_live_...', // or process.env.RLBWHISK_API_KEY (Node)
baseUrl: 'https://reglegbrief.com/whisk/api/v1', // default
timeout: 30_000, // ms
maxRetries: 3,
});
Types
interface Misspelling {
word: string;
offset: number;
length: number;
suggestions: string[];
kind: 'spell' | 'repeat';
}
interface CheckResponse {
language: string;
totalWords: number;
misspellings: Misspelling[];
}
interface Change {
offset: number;
before: string;
after: string;
kind: string;
}
interface FixResponse {
language: string;
totalWords: number;
correctedText: string;
changes: Change[];
unresolved: Misspelling[];
}
Browser usage
The SDK is ESM. In modern bundlers (Vite, esbuild, webpack 5+, Parcel 2), just import.
For a raw <script type="module">, use a CDN like esm.sh:
<script type="module">
import { RLBWhisk } from 'https://esm.sh/@rlbwhisk/client';
const c = new RLBWhisk({ apiKey: 'rlbwhisk_live_...' });
const fixed = await c.fix('Ths is a smple test.');
document.body.textContent = fixed.correctedText;
</script>
Never embed a production API key in client-side JavaScript. Use a lightweight backend proxy
that adds the key to requests, or use the anonymous tier + your own rate-limiting.
Source
MIT licensed. Repo: github.com/rlbwhisk/rlbwhisk-js