mnotify-ts-sdk
v3.0.0
Published
Modern, zero-dependency TypeScript SDK for mNotify BMS API - SMS, contacts, and account management with Railway-Oriented Programming
Downloads
61
Maintainers
Readme
mNotify TypeScript SDK
Zero-dependency TypeScript SDK for mNotify BMS API — send SMS, manage contacts and groups, and handle account operations with railway-oriented programming.
- Zero runtime dependencies — uses native
fetch - Runtime-agnostic — Node 18+, Deno, Bun, Cloudflare Workers, browsers
- Functional error handling — every method returns a
Resulttype - Dual-published — npm + JSR
Quick Start
npm install mnotify-ts-sdkimport { MNotify } from "mnotify-ts-sdk";
const mnotify = new MNotify({
apiKey: process.env.MNOTIFY_API_KEY!,
});
const result = await mnotify.sms.send({
recipient: "233200000000",
sender: "MyApp",
message: "Hello from mNotify!",
});
result.match({
ok: (res) => console.log(`Sent! ID: ${res.summary.message_id}`),
err: (err) => console.error(`Failed: ${err.message}`),
});Services
| Service | Methods | Description |
|---------|---------|-------------|
| mnotify.sms | send, getStatus | Send SMS and check delivery |
| mnotify.contacts | create, list | Manage contacts |
| mnotify.groups | create, list, get, addContact, removeContact, delete | Contact groups |
| mnotify.templates | create, list, get, delete | SMS templates |
| mnotify.account | getBalance, registerSender, checkSender | Account & sender IDs |
Every method returns Result<T, MNotifyError> — see Error Handling.
Error Handling
No try/catch needed. Every method returns a Result type:
const result = await mnotify.account.getBalance();
if (result.isOk()) {
console.log(`Balance: ${result.value.balance}`);
} else {
console.error(result.error.message, result.error.statusCode);
}Chain operations with .map() and .andThen():
import { ok, err, tryCatch, combine } from "mnotify-ts-sdk";
const final = await result
.map((data) => transform(data))
.andThen((transformed) => doMore(transformed));Installation
npm
npm install mnotify-ts-sdkJSR
npx jsr add @adjanour/mnotifyDeno
deno add @adjanour/mnotifyConfiguration
const mnotify = new MNotify({
apiKey: "your-api-key", // required
baseUrl: "https://...", // optional (default: https://api.mnotify.com/api)
timeout: 10000, // optional (default: 10000ms)
maxRetries: 3, // optional (default: 3, only on 429)
});Docs
Full documentation at https://adjanour.github.io/mnotify-ts-sdk or run locally:
npm run docs:devScripts
| Script | Description |
|--------|-------------|
| npm run build | Build ESM + CJS |
| npm test | Run tests |
| npm run lint | Biome lint |
| npm run format | Biome format |
| npm run docs:dev | Start docs dev server |
| npm run docs:build | Build static docs |
License
MIT
