https://github.com/ndolestudio/httpsms-node
Node client for the httpSMS API https://httpsms.com
https://github.com/ndolestudio/httpsms-node
Last synced: 3 months ago
JSON representation
Node client for the httpSMS API https://httpsms.com
- Host: GitHub
- URL: https://github.com/ndolestudio/httpsms-node
- Owner: NdoleStudio
- License: mit
- Created: 2024-01-21T12:59:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-01T10:02:23.000Z (6 months ago)
- Last Synced: 2025-03-20T22:09:32.916Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 41 KB
- Stars: 4
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# httpsms-node
[](https://www.npmjs.org/package/httpsms)
[](https://github.com/NdoleStudio/httpsms-node/actions/workflows/main.yml)
[](https://github.com/NdoleStudio/httpsms-node/graphs/contributors)
[](https://github.com/NdoleStudio/httpsms-node/blob/master/LICENSE)
[](https://www.npmjs.com/package/httpsms)This library provides a server side client for the [httpSMS](https://httpsms.com/) API to help you send and receive SMS messages from your Node.js applications in TypeScript or JavaScript.
## Install
```sh
pnpm install httpsms
# or
yarn install httpsms
```## Implemented
- [x] **[Messages](#messages)**
- [x] `POST /v1/messages/send`: Send a new SMS
- [x] **Cipher**
- [x] `Encrypt`: Encrypt the content of a message to cipher text
- [x] `Decrypt`: Decrypt an encrypted message content to plain text## Usage
### Initializing the Client
An instance of the client can be created using `httpsms.New()`.
```js
import HttpSms from "httpsms"const client = new HttpSms(""/* Get API Key from https://httpsms.com/settings */);
```### Error handling
All API calls return a `Promise` as the return object. You can handle the response in the `then` and `catch` methods.
### Messages
#### `POST /v1/messages/send`: Send an SMS Message
```js
await client.messages.postSend({
content: 'This is a sample text message',
from: '+18005550199',
to: '+18005550100',
})
.then((message) => {
console.log(message.id);
})
.catch((err) => {
console.error(err);
});
```### Encrypt an SMS message before sending
```js
const encryptionKey = "Password123";
const encryptedContent = await client.cipher.encrypt("This is a sample text message", encryptionKey);await client.messages.postSend({
content: encryptedContent,
from: '+18005550199',
encrypted: true,
to: '+18005550100',
})
.then((message) => {
console.log(message.id);
})
.catch((err) => {
console.error(err);
});
```## Testing
You can run the unit tests for this client from the root directory using the command below:
```bash
pnpm run test
```## License
This project is licensed under the MIT License - see the [LICENSE](license) file for details