SDKs & Libraries
Use our official JavaScript SDK or the raw API via curl to integrate Galatext into your application.
JavaScript / Node.js
Works in the browser, Node.js, and any JavaScript environment.
Installation
bash
npm install galatext-apiCDN (script tag)
html
<script src="https://unpkg.com/galatext-api"></script>
<script>
const client = new Galatext('YOUR_API_KEY');
</script>Usage
javascript
import Galatext from 'galatext-api';
const client = new Galatext(process.env.GALATEXT_API_KEY);
// Send SMS
const response = await client.sms.send('+254****5678', 'Hello from Galatext SDK!', 'YOURBRAND');
// Send bulk SMS
const bulkResponse = await client.sms.bulk(
[{ phoneNumber: '+254****5678' }, { phoneNumber: '+254****5432' }],
'Welcome to our platform!',
'YOURBRAND'
);
// Check balance
const balance = await client.account.balance();
console.log('SMS credits:', balance.smsBalance);
// Purchase credits
const payment = await client.account.buyCredits('sms', 100);
// Redirect user to Paystack
window.location.href = payment.authorizationUrl;
// Purchase credits with custom redirect URL
const payment = await client.account.buyCredits(
'sms', 1000, null,
'https://myapp.com/payment/success'
);
window.location.href = payment.authorizationUrl;
// Verify payment after Paystack redirects back
const params = new URLSearchParams(window.location.search);
const ref = params.get('reference');
if (ref) {
const result = await client.account.verifyPayment(ref);
if (result.verified) {
console.log('Payment successful! Credits added.');
}
}
// Get sent messages
const messages = await client.sms.list(0, 20);
// Purchase history
const purchases = await client.account.purchases();
// List sender IDs
const senderIds = await client.senderIds.list();API Reference
| Method | Description |
|---|---|
client.sms.send(phone, message, senderId?) | Send a single SMS |
client.sms.bulk(recipients[], message, senderId?) | Send bulk SMS |
client.sms.list(skip?, take?) | Get sent messages |
client.account.balance() | Get credit balances |
client.account.purchases() | Get purchase history |
client.account.buyCredits(product, quantity?, amount?, callbackUrl?) | Initiate Paystack purchase. Use callbackUrl to redirect back to your app after payment |
client.account.verifyPayment(reference) | Verify a payment after Paystack redirect. Call this from your callbackUrl handler |
client.senderIds.list() | List registered sender IDs |
Configuration
js
const client = new Galatext('YOUR_API_KEY', {
baseURL: 'https://api.galatext.com/api', // default
timeout: 30000, // default (ms)
});Error Handling
javascript
import Galatext, { GalatextError } from 'galatext-api';
try {
const result = await client.sms.send('+2547...', 'Hello', 'BRAND');
} catch (err) {
if (err instanceof GalatextError) {
console.log(err.message); // Human-readable error
console.log(err.status); // HTTP status code
console.log(err.code); // Error code
}
}Links:
Direct API Access (curl)
All endpoints accept the x-api-key header for authentication. Get your API key from the Galatext dashboard.
Send SMS
bash
curl -X POST https://api.galatext.com/api/sms/send-api \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"recipients": [{"phoneNumber": "+254****5678"}],
"message": "Hello from the API!",
"senderId": "GALATEX"
}'Check Balance
bash
curl -s https://api.galatext.com/api/developer/balance \
-H "x-api-key: YOUR_API_KEY"Purchase Credits
bash
curl -X POST https://api.galatext.com/api/developer/credits/purchase \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"product": "sms", "quantity": 100}'Returns an authorizationUrl — redirect the user to Paystack to complete payment.
Verify Payment
bash
curl -s https://api.galatext.com/api/developer/credits/verify/REFERENCE_HERE \
-H "x-api-key: YOUR_API_KEY"Get Sent Messages
bash
curl -s "https://api.galatext.com/api/developer/messages?skip=0&take=20" \
-H "x-api-key: YOUR_API_KEY"Purchase History
bash
curl -s https://api.galatext.com/api/developer/purchases \
-H "x-api-key: YOUR_API_KEY"List Sender IDs
bash
curl -s https://api.galatext.com/api/developer/senderids \
-H "x-api-key: YOUR_API_KEY"