Registry / communication / sendpulse-api

sendpulse-api

JSON →
library1.1.7jsnpmunverified

A simple Node.js REST client library for the SendPulse email marketing and messaging API. Current stable version is 1.1.7. The library provides methods to manage address books, send emails, and interact with other SendPulse features. It is maintained by SendPulse but has low release cadence. Compared to alternatives like nodemailer, this library is official and simplifies authentication via API user ID and secret. However, it uses a callback-based API and stores tokens on disk, which may require adaptation for modern async patterns.

npm install sendpulse-api
INSTALL
IMPORT
SIG · SENDPULSE-API
S
sendpulse-api
communicationjavascriptv1.1.7
harness data pending
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.

sendpulse
import sendpulse from 'sendpulse-api'
const sendpulse = require('sendpulse-api')
ESM-compatible; default import provides the main module.
init
sendpulse.init(API_USER_ID, API_SECRET, TOKEN_STORAGE, callback)
sendpulse.init(API_USER_ID, API_SECRET, callback)
init requires exactly 4 arguments: userId, secret, tokenStoragePath, callback. Omitting tokenStoragePath causes token not found errors.
listAddressBooks
sendpulse.listAddressBooks(callback)
sendpulse.listAddressBooks()
All methods are callback-based and require a callback function to handle the response.
addAddressBook
sendpulse.addAddressBook(bookName, callback)
sendpulse.addAddressBook(bookName)
Callback is mandatory; omitting it will cause a runtime error.

Initialize the client and list address books. Requires API credentials from SendPulse settings. Uses a callback to handle the response.

import sendpulse from 'sendpulse-api'; const API_USER_ID = process.env.SENDPULSE_USER_ID ?? ''; const API_SECRET = process.env.SENDPULSE_SECRET ?? ''; const TOKEN_STORAGE = '/tmp/'; sendpulse.init(API_USER_ID, API_SECRET, TOKEN_STORAGE, () => { sendpulse.listAddressBooks((err, data) => { if (err) console.error(err); else console.log('Address books:', data); }); });
Debug
Known issues
gotchaTOKEN_STORAGE path must be writable; if using a read-only filesystem (e.g., some serverless environments), the library fails to store the access token.
fix
Use a writable directory like /tmp or an absolute path. Alternatively, implement custom token storage by modifying the library.
affects: >=0.0.0
deprecatedAll methods use callbacks; no promise or async/await support. This leads to callback hell in complex workflows.
fix
Wrap calls in a Promise manually or use util.promisify from Node.js core.
affects: >=0.0.0
gotchaThe library does not return the raw HTTP response; it parses JSON internally and passes only the parsed data to the callback. Error handling may miss HTTP status codes.
fix
Check the 'error' parameter in callback; it may contain a parsed error object with status code and message.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Token not found
TOKEN_STORAGE path is incorrect or not writable. The library tries to read a cached token file.
fix
Ensure TOKEN_STORAGE points to a writable directory; e.g., '/tmp/' on Unix systems.
TypeError: callback is not a function
Omitting the callback function when calling an API method.
fix
Always provide a callback function as the last argument to methods like listAddressBooks(callback).
Upgrade
Version history
1.1.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources