# @saralsms/sdk-for-node

> SaralSMS SDK for the JavaScript and Node.js applications.

Latest version **1.0.4** (published 2022-09-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @saralsms/sdk-for-node
pnpm add @saralsms/sdk-for-node
yarn add @saralsms/sdk-for-node
bun add @saralsms/sdk-for-node
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2022-09-10 |
| First published | 2020-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | SaralSMS |
| Maintainers | sapkotamadan |

## Links

- npm: https://www.npmjs.com/package/@saralsms/sdk-for-node
- Homepage: https://saralsms.com
- npm.io page: https://npm.io/package/@saralsms/sdk-for-node

## Dependencies (1)

- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.1.5

## Recent versions

- 1.0.4 (latest) — 2022-09-10
- 1.0.3 — 2022-09-10
- 1.0.2 — 2020-08-11
- 1.0.1 — 2020-08-11

## README

# SaralSMS SDK for Node.js

[![Package](https://img.shields.io/npm/v/@saralsms/sdk-for-node?logo=npm)](https://www.npmjs.com/package/@saralsms/sdk-for-node)
![Downloads](https://img.shields.io/npm/dt/@saralsms/sdk-for-node)
![License](https://img.shields.io/npm/l/@saralsms/sdk-for-node)

The **SaralSMS SDK for Node.js** makes it easy for developers to access SaralSMS API service in their Node.js applications, and build robust SMS based applications and software.

# Getting Started
1. **Sign up for SaralSMS** – Before you begin, you need to sign up for an SaralSMS account and retrieve your [Credentials].
2. **Minimum requirements** – To run the SDK, your system will need to meet the minimum requirements, including having **Node.js >= 8.0**.

# Installation
**Install the SDK** – Using [npm] or [Yarn] is the recommended way to install the SaralSMS SDK for Node.js. The SDK is available via [npm] under the [`@saralsms/sdk-for-node`][npm-package] package.
```
// npm
npm install @saralsms/sdk-for-node
// yarn
yarn add @saralsms/sdk-for-node
```

## Getting Help
We use the GitHub issues for tracking bugs and feature requests and address them as quickly as possible.

* Call/Email [SaralSMS Support](https://saralsms.com/#contact) or open ticket in your dashboard.
* If it turns out that you may have found a bug, please [open an issue](https://github.com/saralsms/sdk-for-node/issues/new).

## Quick Examples

### Create a SaralSMS client

```javascript
import SaralSms from '@saralsms/sdk-for-node';
// instantiate a SaralSMS client.
const saral = new SaralSms('f9c6......55c1');
```
where `f9c6......55c1` is the authentication token.

### Send Message
This will send the message to one or multiple numbers in an array.
```javascript
saral
  .sendSms(['9851xxx123', '9801xxx456'], 'This is test message from API.')
  .then((res) => {
    // success
    console.log(res);
  })
  .catch((error) => {
    // error
    console.log(error);
  });
```

Sample Response
```json
{
    "message": "2 messages queued for delivery."
}
```

### Credits
This will return the available credits and total messages sent.

```javascript
saral
  .getCredits()
  .then((res) => {
    // success
    console.log(res);
  })
  .catch((error) => {
    // error
    console.log(error);
  });
```

Sample Response
```json
{
  "credits": 6584,
  "total_sent": 3416
}
```

### Reports
This will return historical messages reports including networks, charges and status.
     
```javascript
const pageNumber = 1;
saral
  .getReports(pageNumber)
  .then((res) => {
    // success
    console.log(res);
  })
  .catch((error) => {
    // error
    console.log(error);
  });
```

Sample Response
```json
{
  "pages": 126,
  "data": [
    {
      "id": 56480058,
      "receiver": "9779851xxx123",
      "network": "ntc",
      "message": "Fruits are an excellent source of essential vitamins and minerals.",
      "api_credit": "1",
      "delivery_at": "2020-07-09 01:45:09"
    },
    {
      "id": 56480057,
      "receiver": "9779801xxx456",
      "network": "ncell",
      "message": "Vegetables are important sources of many nutrients, including potassium, dietary fiber.",
      "api_credit": "1",
      "delivery_at": "2020-07-08 07:25:31"
    }
  ]
}
```

[Credentials]: https://app.saralsms.com

[npm]: https://www.npmjs.com
[Yarn]: https://yarnpkg.com
[npm-package]: https://www.npmjs.com/package/@saralsms/sdk-for-node

---
_Source: https://npm.io/package/@saralsms/sdk-for-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
