Node.js SDK
Official Splashify Pro SDK for Node.js (works with TypeScript out of the box).
Package: @splashifypro/sdk
Install
npm install @splashifypro/sdk
# or
yarn add @splashifypro/sdk
# or
pnpm add @splashifypro/sdkRequires Node 18+ (uses native fetch).
Configure
Get your API key from Settings → Developer → Generate Secret Key.
import { Splashify } from '@splashifypro/sdk';
const splashify = new Splashify({
apiKey: process.env.SPLASHIFY_API_KEY!,
// optional:
baseUrl: 'https://apis.splashifypro.com', // override for testing
timeout: 30_000, // ms, default 30s
retries: 3, // 5xx auto-retry with backoff
});First message — under 10 lines
import { Splashify } from '@splashifypro/sdk';
const splashify = new Splashify({ apiKey: process.env.SPLASHIFY_API_KEY! });
const result = await splashify.messages.sendText({
to: '919876543210',
text: 'Hello from Splashify Pro!',
});
console.log('Sent:', result.messageId);Common patterns
Send a template
await splashify.messages.sendTemplate({
to: '919876543210',
templateName: 'order_confirmation',
language: 'en',
bodyParameters: ['Aditya', '#1234', '₹2,499'],
});Send media
await splashify.messages.sendMedia({
to: '919876543210',
type: 'image',
mediaUrl: 'https://your-cdn.com/photo.jpg',
caption: 'Check this out!',
});Create a broadcast
const broadcast = await splashify.broadcasts.create({
name: 'Diwali sale',
templateName: 'diwali_offer_v1',
language: 'en',
audienceType: 'segments',
segmentIds: ['<segment-uuid>'],
scheduledAt: null, // send immediately
});
console.log('Broadcast', broadcast.id, 'queued');
// Poll progress
const report = await splashify.broadcasts.report(broadcast.id);
console.log(`${report.sent}/${report.total} sent`);List contacts with pagination
let cursor: string | null = null;
do {
const page = await splashify.contacts.list({ limit: 100, cursor });
for (const c of page.edges) {
console.log(c.phone, c.name);
}
cursor = page.pageInfo.hasNextPage ? page.pageInfo.endCursor : null;
} while (cursor);Verify a webhook
import express from 'express';
app.post('/splashify/webhook', express.raw({ type: 'application/json' }), (req, res) => {
const isValid = splashify.webhooks.verify({
rawBody: req.body,
signature: req.headers['x-splashify-signature'] as string,
});
if (!isValid) return res.status(401).end();
const event = JSON.parse(req.body.toString());
console.log('Event:', event.type, event.payload);
res.status(200).end();
});Error handling
The SDK throws typed errors:
import { SplashifyError, SplashifyRateLimitError } from '@splashifypro/sdk';
try {
await splashify.messages.sendText({ to: '919876543210', text: 'Hi' });
} catch (err) {
if (err instanceof SplashifyRateLimitError) {
console.log(`Rate limited, retry after ${err.retryAfterSec}s`);
} else if (err instanceof SplashifyError) {
console.error(`API error ${err.code}: ${err.message}`);
} else {
throw err; // network / unexpected
}
}| Error class | When |
|---|---|
SplashifyError | Base — any 4xx/5xx with parsed body |
SplashifyRateLimitError | 429 — has retryAfterSec |
SplashifyAuthError | 401 — invalid API key |
SplashifyValidationError | 400 — has field + reason |
SplashifyNotFoundError | 404 — resource doesn’t exist |
TypeScript types
Every method has full input + output types — no need to consult the docs once you’ve installed:
import type { SendTextInput, SendResult, Contact } from '@splashifypro/sdk';Auto-completion works in VS Code, IntelliJ, Vim/Neovim with TypeScript LSP.
Source + issues
- npm: https://www.npmjs.com/package/@splashifypro/sdk
- GitHub: https://github.com/splashifypro/sdk-node
- Issues: file at the GitHub repo above; we triage daily