Registry / crm / mautic

mautic

JSON →
library0.0.4jsnpmunverified

Unofficial Node.js bindings to the Mautic REST API (version 0.0.4). WIP, low maintenance cadence, limited functionality. Provides a client for contacts, segments, and companies. Key differentiators: asynchronous, promise-based, simple auth with username/password. Less mature than official Mautic PHP SDK but fills gap for Node.js users. Not for production use; security not hardened.

npm install mautic
INSTALL
IMPORT
SIG · MAUTIC
M
mautic
crmjavascriptv0.0.4
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.

Mautic
const Mautic = require('mautic')
import Mautic from 'mautic'
CommonJS only; no default export for ESM
Mautic
import Mautic from 'mautic'
import { Mautic } from 'mautic'
ESM usage requires default import (works in Node >=14 with --experimental-modules or bundler)
Client instance
new Mautic({ baseUrl: '...', auth: { username: '...', password: '...' } })
new Mautic.Mautic(...)
Constructor expects object with baseUrl and auth

Demonstrates initializing the client with environment variables and fetching contacts list.

const Mautic = require('mautic'); require('dotenv').config(); const client = new Mautic({ baseUrl: process.env.MAUTIC_BASE_URL || 'http://localhost/api', auth: { username: process.env.MAUTIC_USERNAME || 'admin', password: process.env.MAUTIC_PASSWORD || 'admin' } }); async function run() { try { const contacts = await client.contacts.list(); console.log('Contacts:', JSON.stringify(contacts, null, 2)); } catch (err) { console.error('Error:', err.message); } } run();
Debug
Known issues
breakingConstructor requires 'auth' object with 'username' and 'password' - not API key or OAuth
fix
Use Basic Auth credentials; configure Mautic to accept basic auth.
affects: >=0.0.1
gotchaAll methods return promises, not callbacks. Must use await or .then()
fix
Wrap calls in async function or use .then().catch().
affects: >=0.0.1
gotchaPackage does not parse Mautic's response envelop; returns raw axios response data
fix
Access response.data (axios) or use the raw data as returned.
affects: >=0.0.1
gotchaContact ID expected as integer, not string. Passing string may cause API errors
fix
Parse IDs with parseInt() before passing.
affects: >=0.0.1
gotchaNo pagination helper; list() returns only first page by default
fix
Manually handle pagination with 'start' and 'limit' parameters.
affects: >=0.0.1
Errors
Common errors & fixes
Error: connect ECONNREFUSED
Mautic instance not running or wrong baseUrl
fix
Ensure Mautic server is accessible and baseUrl is correct (e.g., 'http://localhost:8080/api')
TypeError: Cannot read property 'contacts' of undefined
Mautic constructor called without new
fix
Use 'new Mautic(...)' or 'Mautic.default(...)' if using ES import
SyntaxError: Unexpected token 'const'
Old Node.js version (<10) not supporting ES6
fix
Upgrade Node.js to >=10 or use var/function syntax
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
axiosrequiredHTTP client for API requests
Agent activity
19 hits · last 30 days
node
18
Resources
packagemautic
mautic — npm install mautic · libregistry