Programming
Node.js + QuickBooks Desktop
Connect your Node.js application to QuickBooks Desktop using the pg package. Build APIs, integrations, and automations with real accounting data.
Using TypeScript? The
TypeScript SDK
@syntraodbc/client package gives you full IntelliSense on every QuickBooks table and column with zero configuration.
Quick Start
- Install Syntra ODBC and ensure the server is running on
localhost:5433. - Install the pg package. Run
npm install pgin your project. - Create a connection pool pointing to
localhost:5433. - Query any QuickBooks table with standard SQL.
Connection Pool Setup
Use a connection pool for efficient resource management:
// db.js
import pg from "pg";
const pool = new pg.Pool({
host: "localhost",
port: 5433,
database: "quickbooks",
user: "qbconnect",
password: process.env.SYNTRA_PASSWORD, // from config.toml
max: 10,
});
export default pool; Querying Customers
Use async/await with parameterized queries:
import pool from "./db.js";
async function getActiveCustomers(minBalance = 0) {
const { rows } = await pool.query(
`SELECT
list_id,
full_name,
email,
phone,
balance
FROM customers
WHERE is_active = true
AND balance >= $1
ORDER BY balance DESC`,
[minBalance]
);
return rows;
}
// Usage
const customers = await getActiveCustomers(500);
console.log(`Found ${customers.length} customers with balance >= $500`);
customers.forEach((c) => {
console.log(` ${c.full_name}: $${c.balance}`);
}); Express API Example
Expose QuickBooks data through a REST API:
import express from "express";
import pool from "./db.js";
const app = express();
app.get("/api/customers", async (req, res) => {
try {
const { rows } = await pool.query(
"SELECT list_id, full_name, email, balance FROM customers WHERE is_active = true"
);
res.json(rows);
} catch (err) {
console.error("Query failed:", err.message);
res.status(500).json({ error: "Failed to fetch customers" });
}
});
app.get("/api/customers/:id", async (req, res) => {
const { rows } = await pool.query(
"SELECT * FROM customers WHERE list_id = $1",
[req.params.id]
);
if (rows.length === 0) return res.status(404).json({ error: "Not found" });
res.json(rows[0]);
});
app.listen(3000, () => console.log("API running on :3000")); Tips
- ✓ Always use parameterized queries (
$1,$2). Never string-concatenate user input into SQL. - ✓ Store credentials in environment variables, not in source code.
- ✓ Set
maxon the pool to control concurrent connections to Syntra. - ✓ For TypeScript, install
@types/pgfor full type definitions.
Full reference: Node.js docs →
Build Node.js apps with QuickBooks data
Download Syntra ODBC and start querying in minutes.
Download Free Trial