SDKs Overview
mailiam provides official SDKs for Node.js and browser environments, making it easy to integrate transactional email and forms into your applications.
Available SDKs
Section titled “Available SDKs”@mailiam/node - Server-Side SDK
Section titled “@mailiam/node - Server-Side SDK”The Node.js SDK is designed for server-side applications and provides full access to mailiam’s email sending capabilities.
npm install @mailiam/nodeUse cases:
- API routes (Next.js, Express, Fastify, etc.)
- Background jobs and workers
- Server-side email sending
- Webhooks and integrations
Key features:
- Send transactional emails
- Batch email operations
- Automatic retries with exponential backoff
- Built-in rate limit handling
- Full TypeScript support
- Zero dependencies (uses native fetch)
@mailiam/client - Browser Client
Section titled “@mailiam/client - Browser Client”The browser client is designed for client-side applications and provides safe form submission without exposing server secrets.
npm install @mailiam/clientUse cases:
- Contact forms
- Newsletter signups
- Lead capture forms
- Client-side form handling
Key features:
- Browser-safe (no server secrets)
- Optional public key authentication
- CORS-friendly
- Lightweight bundle size
- TypeScript support
Comparison
Section titled “Comparison”| Feature | @mailiam/node | @mailiam/client |
|---|---|---|
| Environment | Server-side | Browser |
| Authentication | Usage/Admin keys | Public keys (optional) |
| Email sending | ✅ Full access | ❌ |
| Form submissions | ✅ | ✅ |
| Batch operations | ✅ | ❌ |
| Automatic retries | ✅ | ❌ |
| Rate limits | 1000-10000/hour | 100/hour |
| Bundle size | ~7 KB | ~3 KB |
When to Use Which SDK
Section titled “When to Use Which SDK”Use @mailiam/node when:
Section titled “Use @mailiam/node when:”- Sending transactional emails from your backend
- You need automatic retries and rate limit handling
- You’re building API endpoints
- You need batch sending capabilities
Use @mailiam/client when:
Section titled “Use @mailiam/client when:”- Building contact or signup forms
- You want to submit directly from the browser
- You don’t want to expose server secrets
- You need a lightweight client-side solution
Use both when:
Section titled “Use both when:”- You have both server-side emails AND client-side forms
- You want consistent error handling across your app
- You’re building a full-stack application
Quick Start
Section titled “Quick Start”Node.js SDK
Section titled “Node.js SDK”import { mailiam } from '@mailiam/node';
const mailiam = new mailiam({ apiKey: process.env.MAILIAM_API_KEY});
await mailiam.emails.send({ from: 'hello@mycompany.com', to: 'customer@example.com', subject: 'Welcome!', html: '<h1>Welcome to our service</h1>'});Browser Client
Section titled “Browser Client”import { mailiamClient } from '@mailiam/client';
const client = new mailiamClient({ publicKey: 'mlm_pk_...' // Optional});
await client.submitForm('mycompany.com', { name: 'John Doe', email: 'john@example.com', message: 'Hello!'});API Key Types
Section titled “API Key Types”mailiam uses different key types for different use cases:
| Type | Prefix | Usage | Rate Limit | SDK |
|---|---|---|---|---|
| Public | mlm_pk_* | Client-safe | 100/hour | @mailiam/client |
| Usage | mlm_sk_* | Server-side | 1000/hour | @mailiam/node |
| Admin | mlm_sk_admin_* | Full access | 10000/hour | @mailiam/node |
Create API keys using the mailiam CLI:
# Server-side keymailiam keys create --name "Production" --type usage
# Client-safe keymailiam keys create --name "Website" --type public --domain mycompany.comNext Steps
Section titled “Next Steps”- Getting Started Guide - Quick installation and setup
- Node.js SDK Documentation - Complete Node.js SDK guide
- Browser Client Documentation - Complete browser client guide
- Examples - Framework-specific examples
- Migration Guide - Migrate from raw API calls