MODRACXKENNETH D'SILVA

← Archive & Insights

Square POS Integration for Retail & E-Commerce Sync

Bridging brick-and-mortar retail transactions with web store inventory via Square Inventory API v2 ensures stock counts update instantly on physical sales.

By Kenneth D'SilvaReading Time: 35 min readCategory: Integrations & Systems

Square Inventory API v2 Client Node.js Code

// Node.js Square Inventory API v2 Fetch
const { Client, Environment } = require('square');

const client = new Client({
  accessToken: process.env.SQUARE_ACCESS_TOKEN,
  environment: Environment.Production,
});

async function getSquareStock(catalogObjectId) {
  const response = await client.inventoryApi.retrieveInventoryCount(catalogObjectId);
  return response.result.counts[0].quantity;
}

Suggested & Related Reading

Explore related engineering guides from Kenneth D'Silva: