Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
TextMagic
✓ const TextMagic = require('textmagic-rest-client');
const client = new TextMagic('username', 'apikey');
✗ import TextMagic from 'textmagic-rest-client';
Package uses CommonJS only; ES import will fail. Instantiate with constructor using username and API key.
default import
✓ const TextMagic = require('textmagic-rest-client');
✗ const { TextMagic } = require('textmagic-rest-client');
The default export is the constructor; named destructuring yields undefined.
sendSms
✓ client.Messages.send({ text: 'Hello', phones: '+1234567890' }, callback);
✗ client.sendSms('Hello', '+1234567890');
API uses nested resource objects (e.g., Messages); individual methods not exposed directly. Callback-style, no promises.
Demonstrates creating a TextMagic client and sending an SMS with callback.
const TextMagic = require('textmagic-rest-client');
const username = process.env.TEXTMAGIC_USERNAME ?? '';
const apikey = process.env.TEXTMAGIC_APIKEY ?? '';
const client = new TextMagic(username, apikey);
client.Messages.send({
text: 'Hello from Node.js',
phones: '+1234567890'
}, function(err, res) {
if (err) {
console.error('Error sending SMS:', err);
} else {
console.log('Message sent:', res.id);
}
});
Errors
Common errors & fixes
TypeError: TextMagic is not a constructor
Incorrect import style (ES import or destructured from CommonJS).
fixUse const TextMagic = require('textmagic-rest-client'); Error: Cannot find module 'textmagic-rest-client'
Package not installed or Node version incompatible.
fixRun npm install textmagic-rest-client --save
Audit
Dependencies
No dependency data recorded yet.