litmus-api
raw JSON → 0.3.2 verified Sat Apr 25 auth: no javascript
A Node.js client library for the Litmus Customer API, allowing email testing automation. Version 0.3.2 is the latest stable release. It wraps all major API endpoints (tests, versions, etc.) and returns promises via Bluebird. Key differentiator is full promise-based async handling compared to callback-based alternatives. Suitable for integrating email testing into CI/CD pipelines.
Common errors
error TypeError: Litmus is not a constructor ↓
cause Using named import instead of default import or incorrect require.
fix
Use const Litmus = require('litmus-api') or import Litmus from 'litmus-api'.
error Cannot read property 'getTests' of undefined ↓
cause Not waiting for promise resolution; api.getTests() is called without .then or async/await.
fix
Use await api.getTests() or .then() to handle the promise.
error Error: Unauthorized ↓
cause Invalid username, password, or URL.
fix
Verify credentials and URL format (e.g., https://yourcompany.litmus.com).
Warnings
gotcha getTests() returns an array with response and body, not just body. ↓
fix Use array destructuring: const [response, body] = await api.getTests();
gotcha createVersion() for email tests returns a new email address; you must send an email to that address to trigger screenshots. ↓
fix After createVersion, check url_or_guid field and send email to that address.
breaking Authentication expects username and password, not API tokens. ↓
fix Pass username and password in options. For API tokens, use different client.
deprecated updateTest() expects XML body; Litmus may be moving to JSON. ↓
fix Check Litmus API docs for current format.
Install
npm install litmus-api yarn add litmus-api pnpm add litmus-api Imports
- default wrong
const litmus = require('litmus-api')correctimport Litmus from 'litmus-api' - Litmus wrong
const { Litmus } = require('litmus-api')correctconst Litmus = require('litmus-api') - Litmus wrong
import { Litmus } from 'litmus-api'correctimport Litmus from 'litmus-api'
Quickstart
const Litmus = require('litmus-api');
const api = new Litmus({
username: process.env.LITMUS_USERNAME ?? 'your-username',
password: process.env.LITMUS_PASSWORD ?? 'your-password',
url: process.env.LITMUS_URL ?? 'https://company.litmus.com'
});
api.getTests()
.then(([response, body]) => {
console.log('Response:', response);
console.log('Body:', body);
})
.catch(err => console.error('Error:', err));