npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sms-ir-api

v1.2.1

Published

SMS.IR API client for JS/TS/ESM/Node.js

Downloads

28

Readme

SMS.ir API

sms-ir-api allows you to communicate with the SMS.ir API to send and receive SMS messages. The API key and default line number for your SMS.ir account are required to create a new instance of the Smsir class.

Installation

This package is available on npm as sms-ir-api. You can install it using either npm or yarn.

With npm:

npm install sms-ir-api

With yarn:

yarn add sms-ir-api

Usage

To use this class in your JavaScript or TypeScript code, first import it:

import { Smsir } from "sms-ir-api";

Then create a new instance of the Smsir class using your SMS.ir API key and default line number:

const sms = new Smsir("YOUR_API_KEY", YOUR_LINE_NUMBER);

You can then use the methods of the Smsir class to interact with the SMS.ir API. For example, to send a single SMS message to a single recipient:

sms.Send("Hello World!", "RECIPIENT_MOBILE_NUMBER");

Methods

The following methods are available in the Smsir class:

constructor()

constructor(apiKey: string, lineNumber: number)

Create a new instance of the Smsir class.

  • apiKey: The API key for your SMS.ir account.
  • lineNumber: The default line number to use for sending messages.

Example

const sms = new Smsir("YOUR_API_KEY", YOUR_LINE_NUMBER);

Send()

Send(MessageText: string, Mobile: string, SendDateTime: number | null = null, lineNumber: number = this.DefaultLineNumber): Promise<any>

Send a single SMS message to a single recipient.

  • MessageText: The text of the message to send.
  • Mobile: The mobile number of the recipient.
  • SendDateTime: (optional) The Unix timestamp of when to send the message (null for immediate sending).
  • lineNumber: (optional) The line number to use for sending the message.

Example

sms.Send("Hello World!", "RECIPIENT_MOBILE_NUMBER");

SendBulk()

SendBulk(MessageText: string, Mobiles: Array<string>, SendDateTime: number | null = null, lineNumber: number = this.DefaultLineNumber): Promise<any>

Send a single SMS message to multiple recipients.

  • MessageText: The text of the message to send.
  • Mobiles: An array of mobile numbers of the recipients.
  • SendDateTime: (optional) The Unix timestamp of when to send the message (null for immediate sending).
  • lineNumber: (optional) The line number to use for sending the message.

Example

sms.SendBulk("Hello World!", ["RECIPIENT_MOBILE_NUMBER_1", "RECIPIENT_MOBILE_NUMBER_2"]);

SendLikeToLike()

SendLikeToLike(MessageTexts: string, Mobiles: Array<string>, SendDateTime: number | null = null, lineNumber: number | null = null): Promise<any>

Send multiple SMS messages to multiple recipients (one message per recipient).

  • MessageTexts: The text of the messages to send.
  • Mobiles: An array of mobile numbers of the recipients.
  • SendDateTime: (optional) The Unix timestamp of when to send the message (null for immediate sending).
  • lineNumber: (optional) The line number to use for sending the message (null for default line number).

Example

sms.SendLikeToLike(["Hello World 1!", "Hello World 2!"], ["RECIPIENT_MOBILE_NUMBER_1", "RECIPIENT_MOBILE_NUMBER_2"]);

DeleteScheduled()

DeleteScheduled(PackId: number): Promise<any>

Delete a scheduled SMS message.

  • PackId: The ID of the scheduled message pack to delete.

Example

sms.DeleteScheduled(SCHEDULED_MESSAGE_PACK_ID);

SendVerifyCode()

SendVerifyCode(Mobile: string, TemplateId: number, Parameters: Array<any>): Promise<any>

Send a verification code via SMS.

  • Mobile: The mobile number of the recipient.
  • TemplateId: The ID of the verification code template to use.
  • Parameters: An array of parameters to use in the verification code template.

Example

sms.SendVerifyCode("RECIPIENT_MOBILE_NUMBER", TEMPLATE_ID, [PARAMETER_1, PARAMETER_2]);

ReportMessage()

ReportMessage(MessageId: number): Promise<any>

Get a report on a specific sent SMS message.

  • MessageId: The ID of the sent message to get a report on.

Example

sms.ReportMessage(MESSAGE_ID);

ReportPack()

ReportPack(PackId: number): Promise<any>

Get a report on a specific sent SMS message pack.

  • PackId: The ID of the sent message pack to get a report on.

Example

sms.ReportPack(PACK_ID);

ReportToday()

ReportToday(pageSize: number = 10, pageNumber: number = 1): Promise<any>

Get a report on today's sent SMS messages.

  • pageSize: (optional) The number of results to return per page.
  • pageNumber: (optional) The page number to return results for.

Example

sms.ReportToday(PAGE_SIZE, PAGE_NUMBER);

ReportArchived()

ReportArchived(fromDate: number | null = null, toDate: number | null = null, pageSize: number = 10, pageNumber: number = 1): Promise<any>

Get a report on archived sent SMS messages.

  • fromDate: (optional) The start date to get results for (null for no start date).
  • toDate: (optional) The end date to get results for (null for no end date).
  • pageSize: (optional) The number of results to return per page.
  • pageNumber: (optional) The page number to return results for.

Example

sms.ReportArchived(FROM_DATE, TO_DATE, PAGE_SIZE, PAGE_NUMBER);

ReportLatestReceived()

ReportLatestReceived(count: number = 100): Promise<any>

Get a report on the latest received SMS messages.

  • count: (optional) The number of results to return.

Example

sms.ReportLatestReceived(COUNT);

ReportTodayReceived()

ReportTodayReceived(pageSize: number = 10, pageNumber: number = 1): Promise<any>

Get a report on today's received SMS messages.

  • pageSize: (optional) The number of results to return per page.
  • pageNumber: (optional) The page number to return results for.

Example

sms.ReportTodayReceived(PAGE_SIZE, PAGE_NUMBER);

ReportArchivedReceived()

ReportArchivedReceived(fromDate: number | null = null, toDate: number | null = null, pageSize: number = 10, pageNumber: number = 1): Promise<any>

Get a report on archived received SMS messages.

  • fromDate: (optional) The start date to get results for (null for no start date).
  • toDate: (optional) The end date to get results for (null for no end date).
  • pageSize: (optional) The number of results to return per page.
  • pageNumber: (optional) The page number to return results for.

Example

sms.ReportArchivedReceived(FROM_DATE, TO_DATE, PAGE_SIZE, PAGE_NUMBER);

GetCredit()

GetCredit(): Promise<any>

Get the remaining credit balance for your SMS.ir account.

Example

sms.GetCredit();

GetLineNumbers()

GetLineNumbers(): Promise<any>

Get a list of available line numbers for your SMS.ir account.

Example

sms.GetLineNumbers();

License

Developed by Shahab Movahhedi

MIT Licensed.