The official JavaScript/TypeScript SDK for VIUCraft provides a type-safe, chainable API for image transformations, uploads, and management.
Installation
cURL
npm install viucraft
Quick Start
Typescript
import { ViucraftClient } from 'viucraft';
const client = new ViucraftClient({
apiKey: process.env.VIUCRAFT_API_KEY,
subdomain: 'mycompany',
});
const url = client.image('image-uuid')
.resize(800, 600)
.grayscale()
.quality(85)
.toURL();
const result = await client.uploadImage(buffer);
console.log(result.image_id);
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | (required) | Your VIUCraft API key |
subdomain | string | — | Your dedicated subdomain (paid plans) |
baseUrl | string | https://api.viucraft.com | API base URL |
accountId | string | — | Account ID for free-tier shared endpoint |
timeout | number | 30000 | Request timeout in milliseconds |
retry | RetryConfig | false | See below | Retry configuration |
enforceHttps | boolean | true | Warn when using HTTP |
TypeScript Support
The SDK ships with full type definitions. All interfaces are exported.
Security Tips
- Never hardcode API keys in source code. Use environment variables.
getMaskedApiKey() for logging.