
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
sms-typescript
Advanced tools
Official TypeScript SDK for SMS.ir API - Send SMS, verification codes, and bulk messages
Official TypeScript/JavaScript SDK for SMS.ir API - Send SMS, verification codes, and bulk messages with full TypeScript support.
✅ Full TypeScript Support - Complete type definitions for all APIs
✅ Multiple Module Formats - Works with CommonJS, ES Modules, and TypeScript
✅ Modern & Legacy Support - Class-based (v1.x compatible) and functional APIs
✅ Tree Shakeable - Import only what you need
✅ Zero Dependencies - Uses native fetch API (Node.js 18+)
✅ Comprehensive Documentation - JSDoc comments for IntelliSense
npm install sms-typescript
import { Smsir } from "sms-typescript";
const sms = new Smsir("your-api-key", 30007732000000);
// Send bulk SMS
const result = await sms.sendBulk("Hello!", ["09123456789"]);
console.log("Pack ID:", result.data.packId);
// Send verification code
await sms.sendVerifyCode("09123456789", 12345, [
{ name: "Code", value: "123456" },
]);
// Get account credit
const credit = await sms.getCredit();
console.log("Credit:", credit.data);
import { smsBuilder } from "sms-typescript";
const sms = smsBuilder({
apiKey: "your-api-key",
lineNumber: 30007732000000,
});
// Same methods as class-based API
const result = await sms.sendBulk("Hello!", ["09123456789"]);
Note: The functional API does not include deprecated v1.x methods.
// Class-based (backward compatible with v1.x)
const { Smsir } = require("sms-typescript");
const sms = new Smsir("your-api-key", 30007732000000);
// Functional
const smsBuilder = require("sms-typescript").default;
const sms = smsBuilder({ apiKey: "your-api-key", lineNumber: 30007732000000 });
sendBulk(messageText, mobiles, sendDateTime?, customLineNumber?)Send the same message to multiple recipients.
const result = await sms.sendBulk(
"Hello World!",
["09123456789", "09987654321"],
Date.now() + 3600000, // Optional: schedule for 1 hour later
30007732000000 // Optional: custom line number
);
sendLikeToLike(messageTexts, mobiles, sendDateTime?, customLineNumber?)Send different messages to different recipients (1-to-1 pairing).
await sms.sendLikeToLike(
["Hello Ali", "Hello Sara"],
["09121111111", "09122222222"]
);
sendVerifyCode(mobile, templateId, parameters)Send verification code using a predefined template.
await sms.sendVerifyCode("09123456789", 12345, [
{ name: "Code", value: "123456" },
{ name: "Name", value: "John" },
]);
deleteScheduled(packId)Delete a scheduled SMS pack.
await sms.deleteScheduled("pack-id-here");
sendByURL(username, mobile, text, customLine?)Legacy URL-based sending method (for backward compatibility).
await sms.sendByURL("username", "09123456789", "Hello World!");
reportMessage(messageId)Get delivery status of a specific message.
const report = await sms.reportMessage("876240022");
console.log("Delivery State:", report.data.deliveryState);
reportPackById(packId)Get all messages in a specific pack.
const pack = await sms.reportPackById("pack-id");
reportDailyPack(pageNumber, pageSize)Get daily pack statistics with pagination.
const dailyPack = await sms.reportDailyPack(1, 10);
reportTodayLive(pageNumber, pageSize)Get today's sent messages with pagination.
const today = await sms.reportTodayLive(1, 10);
reportArchive(fromDate, toDate, pageNumber, pageSize)Get archived sent messages within a date range.
const archived = await sms.reportArchive(
Date.now() - 86400000, // Yesterday
Date.now(),
1,
10
);
reportLatestReceive(count)Get latest received messages.
const received = await sms.reportLatestReceive(100);
reportReceiveLive(pageNumber, pageSize, sortByNewest)Get live received messages with pagination.
const live = await sms.reportReceiveLive(1, 10, true);
reportReceiveArchive(fromDate, toDate, pageNumber, pageSize)Get archived received messages.
const archived = await sms.reportReceiveArchive(
Date.now() - 86400000,
Date.now(),
1,
10
);
getCredit()Get current account credit balance.
const credit = await sms.getCredit();
console.log("Credit:", credit.data);
getLineNumbers()Get all available line numbers for your account.
const lines = await sms.getLineNumbers();
console.log("Lines:", lines.data);
For users migrating from v1.x, all old method names are still supported via the class-based API:
These methods are deprecated but still functional for backward compatibility. Use the new camelCase methods instead.
// ⚠️ Deprecated - Use sendBulk() instead
await sms.SendBulk("message", ["09123456789"]);
// ⚠️ Deprecated - Use sendLikeToLike() instead
await sms.SendLikeToLike(["msg1", "msg2"], ["09121111111", "09122222222"]);
// ⚠️ Deprecated - Use sendVerifyCode() instead
await sms.SendVerifyCode("09123456789", 12345, [
{ name: "Code", value: "123456" },
]);
// ⚠️ Deprecated - Use reportMessage() instead
await sms.ReportMessage(876240022);
// ⚠️ Deprecated - Use reportPackById() instead
await sms.ReportPack("pack-id");
// ⚠️ Deprecated - Use reportTodayLive() instead
await sms.ReportToday(1, 10);
// ⚠️ Deprecated - Use reportArchive() instead
await sms.ReportArchived(fromDate, toDate, 1, 10);
// ⚠️ Deprecated - Use reportLatestReceive() instead
await sms.ReportLatestReceived(100);
// ⚠️ Deprecated - Use reportReceiveLive() instead
await sms.ReportTodayReceived(1, 10);
// ⚠️ Deprecated - Use reportReceiveArchive() instead
await sms.ReportArchivedReceived(fromDate, toDate, 1, 10);
Note: Deprecated methods are only available in the Smsir class, not in the functional smsBuilder API.
For detailed examples including Angular, React, Vue.js, and various use cases, see USAGE_EXAMPLES.md.
Full TypeScript support with comprehensive type definitions:
import {
Smsir,
SendBulkResponse,
ResponseModel,
SmsConfig,
} from "sms-typescript";
const config: SmsConfig = {
apiKey: "your-api-key",
lineNumber: 30007732000000,
};
const sms = new Smsir(config.apiKey, config.lineNumber);
const result: ResponseModel<SendBulkResponse> = await sms.sendBulk("Hello!", [
"09123456789",
]);
// TypeScript knows the structure:
console.log(result.data.packId); // string
console.log(result.data.messageIds); // number[]
console.log(result.data.cost); // number
The SDK is fully backward compatible! Your existing code will continue to work:
// v1.x code - Still works!
const { Smsir } = require("sms-typescript");
const sms = new Smsir("api-key", lineNumber);
// Old PascalCase methods still work (but are deprecated)
sms.SendBulk("Hello", ["09123456789"]).then((result) => console.log(result));
// New camelCase methods (recommended)
sms.sendBulk("Hello", ["09123456789"]).then((result) => console.log(result));
Migration recommendations:
SendBulk → sendBulk)smsBuilder API for cleaner codefetch API).js extensionsRecommendation: Use CommonJS (require) for Node.js projects, or use a bundler for ESM projects.
import { Smsir } from "sms-typescript";
export class AppComponent implements OnInit {
private smsService: Smsir;
constructor() {
this.smsService = new Smsir("your-api-key", 30007732000000);
}
async sendMessage() {
const result = await this.smsService.sendBulk("Hello!", ["09123456789"]);
console.log("Sent!", result.data.packId);
}
}
import { Smsir } from "sms-typescript";
const sms = new Smsir("your-api-key", 30007732000000);
function MyComponent() {
const handleSend = async () => {
const result = await sms.sendBulk("Hello!", ["09123456789"]);
console.log("Sent!", result.data);
};
return <button onClick={handleSend}>Send SMS</button>;
}
import { Smsir } from "sms-typescript";
export default {
data() {
return {
sms: new Smsir("your-api-key", 30007732000000),
};
},
methods: {
async sendMessage() {
const result = await this.sms.sendBulk("Hello!", ["09123456789"]);
console.log("Sent!", result.data);
},
},
};
All methods return promises. Handle errors appropriately:
try {
const result = await sms.sendBulk("Hello", ["09123456789"]);
console.log("Success:", result.data);
} catch (error) {
console.error("Error:", error.message);
// Handle error (retry, show message to user, etc.)
}
We welcome contributions from the community! Whether you want to report a bug, suggest a feature, or submit code improvements, your help is appreciated.
mainWe review all contributions and will provide feedback. Thank you for helping make this SDK better!
The MIT License (MIT). Please see License File for more information.
FAQs
Official TypeScript SDK for SMS.ir API - Send SMS, verification codes, and bulk messages
We found that sms-typescript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.