Node SDK to interact with the SMSGlobal REST API endpoints. This SDK provides an easy way to integrate SMSGlobal services into your Node.js applications, allowing you to send SMS, manage contacts, view balances, and more.
To use the SMSGlobal Node SDK, you need to have Node.js installed. You can then install the SDK via npm:
npm install smsglobal-node-sdk
To use the SDK, first, you need to initialize it with your SMSGlobal API key and secret.
To use the SDK, you need to initialize it with your SMSGlobal API key and secret by passing a configuration object to the init
function provided by the SDK.
// Import the SDK
const SmsGlobal = require('smsglobal-node-sdk');
// Your custom configuration
const config = {
apiKey: 'your-api-key', // Replace with your actual API key
apiSecret: 'your-api-secret', // Replace with your actual API secret
};
// Initialize the SDK with your configuration
const smsglobal = SmsGlobal.init(config);
// Destructure the services you want to use
const { autoTopupService, contactGroupService } = smsglobal;
// Example: Fetching Auto-Topup Information
(async () => {
try {
const autoTopupInfo = await autoTopupService.getAutoTopupInfo();
console.log(autoTopupInfo);
} catch (error) {
console.error('Error fetching auto-topup information:', error.message);
}
})();
The SDK provides several services to interact with the SMSGlobal API:
getAutoTopupInfo()
: Fetch auto-topup information for the authenticated account.
getContactGroupById(groupId)
: Fetch a specific contact group by ID.createContactGroup(groupData)
: Create a new contact group.updateContactGroup(groupId, groupData)
: Update a contact group.deleteContactGroup(groupId)
: Delete a contact group by ID.
getDedicatedNumbers()
: Fetch a list of dedicated numbers associated with the account.
getOptOuts()
: Fetch a list of opted-out numbers.optOutNumbers(numbers)
: Opt-out mobile numbers.optInNumber(number)
: Opt-in a mobile number.
getSharedPools()
: Fetch a list of shared pools.getSharedPoolById(sharedPoolId)
: Fetch details of a specific shared pool.
getOutgoingMessages(filters)
: Fetch a list of outgoing SMS messages.sendSms(smsData)
: Send an SMS message.deleteOutgoingMessage(messageId)
: Delete an outgoing SMS message by ID.
getIncomingMessages(filters)
: Fetch a list of incoming SMS messages.deleteIncomingMessage(messageId)
: Delete an incoming SMS message by ID.
getBillingDetails()
: Fetch billing details of the authenticated account.updateBillingDetails(billingData)
: Update billing details.getContactDetails()
: Fetch contact details of the authenticated account.getCreditBalance()
: Fetch the credit balance of the authenticated account.
If you're sending SMS via the HTTP API, you need to locate your Master API keys for your username and password. You can find these keys by logging into your SMSGlobal account and navigating to Integrations.
Below is a sample HTTP API request for sending an SMS:
https://api.smsglobal.com/http-api.php?action=sendsms&user=username&password=password&from=Test&to=61447100250&text=Testmessage
Replace username
and password
with your Master API keys, and update the from
, to
, and text
parameters as needed.
For setting up and using the OTP API, refer to the SMSGlobal OTP API documentation. This API uses REST API keys for authentication and offers robust OTP generation and verification features.
To help you set up the OTP API, we've provided an OTP Setup Guide. Make sure to follow the guide to configure your OTP services properly.
The SDK comes with comprehensive tests for each service module using Mocha, Chai, and Sinon. To run the tests:
npm test
This command will run all tests located in the test/
directory.
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Clone your fork:
git clone https://github.com/yourusername/smsglobal-node-sdk.git
- Create a new branch:
git checkout -b my-feature-branch
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-feature-branch
- Submit a Pull Request.
Please make sure to write tests for your changes and run existing tests to ensure nothing is broken.
This project is licensed under the GNU General Public License v3.0 or later. See the LICENSE file for more details.
© 2024 Mujtaba Shamas. All rights reserved.